Skip to content

Commit

Permalink
Bug 1505712 - Fix canI check when project preselected
Browse files Browse the repository at this point in the history
Make sure the select-project form exists when projects load so we can
correctly set form validity for project viewers.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1505712
  • Loading branch information
spadgett committed Oct 24, 2017
1 parent 4a30081 commit 8f03129
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/origin-web-catalogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ webpackJsonp([ 0, 1 ], [ function(e, t) {
}, function(e, t) {
e.exports = '<div class="select-plans">\n <h3 ng-if="$ctrl.availablePlans.length > 1">Select a Plan</h3>\n <div ng-if="$ctrl.availablePlans.length" ng-repeat="plan in $ctrl.availablePlans track by plan.metadata.uid" ng-class="{\'radio\': $ctrl.availablePlans.length > 1}">\n <label>\n <input ng-if="$ctrl.availablePlans.length > 1"\n type="radio"\n ng-model="$ctrl.planIndex"\n ng-change="$ctrl.onPlanSelect(plan)"\n value="{{$index}}">\n <span class="plan-name">{{plan.spec.externalMetadata.displayName || plan.spec.externalName}}</span>\n <div class="plan-description" ng-if="plan.spec.description" ng-bind-html="plan.spec.description | linkify : \'_blank\'"></div>\n </label>\n </div>\n <div ng-if="!$ctrl.availablePlans.length" class="blank-slate-pf">\n <div class="blank-slate-pf-icon">\n <span class="pficon pficon-info"></span>\n </div>\n <h1>\n No Plans Available\n </h1>\n <p>\n There are no plans currently available for this service.\n </p>\n </div>\n</div>\n';
}, function(e, t) {
e.exports = '<span ng-if="$ctrl.noProjectsCantCreate" class="no-projects-cant-create">\n <pf-empty-state config="$ctrl.noProjectsConfig"></pf-empty-state>\n <p ng-if="!$ctrl.noProjectsCantCreateMessage">\n A cluster admin can create a project for you by running the command:\n <div class="code-block">\n <code>oc adm <span class="command-arg">new-project</span> &lt;projectname&gt; <span class="command-arg">--admin={{$ctrl.user.metadata.name || \'&lt;YourUsername&gt;\'}}</span></code>\n </div>\n </p>\n <div ng-if="$ctrl.noProjectsCantCreateMessage" ng-bind-html="$ctrl.noProjectsCantCreateMessage | linky : \'_blank\'"></div>\n</span>\n\n<ng-form name="$ctrl.forms.selectProjectForm" ng-if="$ctrl.numProjectChoices >= 1">\n <div class="form-group" ng-class="{\'has-error\' : $ctrl.forms.selectProjectForm.selectProject.$error.cannotAddToProject ||\n ($ctrl.forms.selectProjectForm.selectProject.$touched &&\n $ctrl.forms.selectProjectForm.selectProject.$invalid)}">\n <h3 ng-if="$ctrl.canOnlyCreateProject()">Create Project</h3>\n <label ng-if="!$ctrl.canOnlyCreateProject()" class="control-label required">Add to Project</label>\n <ui-select\n ng-if="!$ctrl.canOnlyCreateProject()"\n ng-disabled="$ctrl.numProjectChoices === 1"\n name="selectProject"\n ng-model="$ctrl.selectedProject"\n ng-change="$ctrl.onSelectProjectChange()"\n ng-required="true"\n search-enabled="$ctrl.searchEnabled">\n <ui-select-match placeholder="{{$ctrl.placeholder}}">\n {{$select.selected | displayName}}\n </ui-select-match>\n \x3c!-- refresh-delay must be set using ng-attr-refresh-delay to work as a dynamic value --\x3e\n <ui-select-choices\n repeat="project in $ctrl.getProjectChoices() track by (project | uid)"\n refresh="$ctrl.refreshChoices($select.search)"\n ng-attr-refresh-delay="{{$ctrl.refreshDelay}}"\n group-by="$ctrl.groupChoicesBy">\n <span ng-bind-html="project | displayName | highlightKeywords : $select.search"></span>\n <span ng-if="project | displayName : true" class="small text-muted">\n <span ng-if="project.metadata.name">&ndash;</span>\n <span ng-bind-html="project.metadata.name | highlightKeywords : $select.search"></span>\n </span>\n </ui-select-choices>\n </ui-select>\n <div ng-if="$ctrl.forms.selectProjectForm.selectProject.$error.cannotAddToProject">\n <span class="help-block">\n You are not authorized to add to this project.\n </span>\n </div>\n <div class="has-error" ng-if="$ctrl.forms.selectProjectForm.selectProject.$error.required &&\n $ctrl.forms.selectProjectForm.selectProject.$touched">\n <span class="help-block">\n Please select <span ng-if="$ctrl.canCreate">or create</span> a project.\n </span>\n </div>\n </div>\n</ng-form>\n\n<ng-form name="$ctrl.forms.createProjectForm"\n ng-if="$ctrl.isNewProject()">\n <div class="form-group">\n <label for="name" class="control-label required">Project Name</label>\n <div ng-class="{\'has-error\': ($ctrl.forms.createProjectForm.name.$error.pattern && $ctrl.forms.createProjectForm.name.$touched) || $ctrl.nameTaken}">\n <input class="form-control"\n name="name"\n id="name"\n placeholder="my-project"\n type="text"\n required\n take-focus\n minlength="2"\n maxlength="63"\n pattern="[a-z0-9]([-a-z0-9]*[a-z0-9])?"\n aria-describedby="nameHelp"\n ng-model="$ctrl.selectedProject.metadata.name"\n osc-unique="$ctrl.existingProjectNames"\n ng-model-options="{ updateOn: \'default blur\' }"\n ng-change="$ctrl.onNewProjectNameChange()"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false">\n <div class="help-block">A unique name for the project.</div>\n <div class="has-error" ng-if="$ctrl.forms.createProjectForm.name.$error.minlength && $ctrl.forms.createProjectForm.name.$touched">\n <span id="nameHelp" class="help-block">\n Name must have at least two characters.\n </span>\n </div>\n <div class="has-error" ng-if="$ctrl.forms.createProjectForm.name.$error.pattern && $ctrl.forms.createProjectForm.name.$touched">\n <span id="nameHelp" class="help-block">\n Project names may only contain lower-case letters, numbers, and dashes.\n They may not start or end with a dash.\n </span>\n </div>\n <div class="has-error" ng-if="$ctrl.nameTaken || $ctrl.forms.createProjectForm.name.$error.oscUnique">\n <span class="help-block">\n This name is already in use. Please choose a different name.\n </span>\n </div>\n </div>\n </div>\n\n <div class="form-group">\n <label for="displayName" class="control-label">Project Display Name</label>\n <input class="form-control"\n name="displayName"\n id="displayName"\n placeholder="My Project"\n type="text"\n ng-model="$ctrl.selectedProject.metadata.annotations[\'new-display-name\']">\n </div>\n\n <div class="form-group">\n <label for="description" class="control-label">Project Description</label>\n <textarea class="form-control"\n name="description"\n id="description"\n placeholder="A short description."\n ng-model="$ctrl.selectedProject.metadata.annotations[\'openshift.io/description\']"></textarea>\n </div>\n</ng-form>\n<div ng-if="!$ctrl.noProjectsCantCreate && $ctrl.showDivider" class="select-project-divider"></div>\n\n';
e.exports = '<span ng-if="$ctrl.noProjectsCantCreate" class="no-projects-cant-create">\n <pf-empty-state config="$ctrl.noProjectsConfig"></pf-empty-state>\n <p ng-if="!$ctrl.noProjectsCantCreateMessage">\n A cluster admin can create a project for you by running the command:\n <div class="code-block">\n <code>oc adm <span class="command-arg">new-project</span> &lt;projectname&gt; <span class="command-arg">--admin={{$ctrl.user.metadata.name || \'&lt;YourUsername&gt;\'}}</span></code>\n </div>\n </p>\n <div ng-if="$ctrl.noProjectsCantCreateMessage" ng-bind-html="$ctrl.noProjectsCantCreateMessage | linky : \'_blank\'"></div>\n</span>\n\n\x3c!-- Use `ng-show` instead of `ng-if` so that the form exists and the `canI` works when projects load. --\x3e\n<ng-form name="$ctrl.forms.selectProjectForm" ng-show="$ctrl.numProjectChoices >= 1">\n <div class="form-group" ng-class="{\'has-error\' : $ctrl.forms.selectProjectForm.selectProject.$error.cannotAddToProject ||\n ($ctrl.forms.selectProjectForm.selectProject.$touched &&\n $ctrl.forms.selectProjectForm.selectProject.$invalid)}">\n <h3 ng-if="$ctrl.canOnlyCreateProject()">Create Project</h3>\n <label ng-if="!$ctrl.canOnlyCreateProject()" class="control-label required">Add to Project</label>\n <ui-select\n ng-if="!$ctrl.canOnlyCreateProject()"\n ng-disabled="$ctrl.numProjectChoices === 1"\n name="selectProject"\n ng-model="$ctrl.selectedProject"\n ng-change="$ctrl.onSelectProjectChange()"\n ng-required="true"\n search-enabled="$ctrl.searchEnabled">\n <ui-select-match placeholder="{{$ctrl.placeholder}}">\n {{$select.selected | displayName}}\n </ui-select-match>\n \x3c!-- refresh-delay must be set using ng-attr-refresh-delay to work as a dynamic value --\x3e\n <ui-select-choices\n repeat="project in $ctrl.getProjectChoices() track by (project | uid)"\n refresh="$ctrl.refreshChoices($select.search)"\n ng-attr-refresh-delay="{{$ctrl.refreshDelay}}"\n group-by="$ctrl.groupChoicesBy">\n <span ng-bind-html="project | displayName | highlightKeywords : $select.search"></span>\n <span ng-if="project | displayName : true" class="small text-muted">\n <span ng-if="project.metadata.name">&ndash;</span>\n <span ng-bind-html="project.metadata.name | highlightKeywords : $select.search"></span>\n </span>\n </ui-select-choices>\n </ui-select>\n <div ng-if="$ctrl.forms.selectProjectForm.selectProject.$error.cannotAddToProject">\n <span class="help-block">\n You are not authorized to add to this project.\n </span>\n </div>\n <div class="has-error" ng-if="$ctrl.forms.selectProjectForm.selectProject.$error.required &&\n $ctrl.forms.selectProjectForm.selectProject.$touched">\n <span class="help-block">\n Please select <span ng-if="$ctrl.canCreate">or create</span> a project.\n </span>\n </div>\n </div>\n</ng-form>\n\n<ng-form name="$ctrl.forms.createProjectForm"\n ng-if="$ctrl.isNewProject()">\n <div class="form-group">\n <label for="name" class="control-label required">Project Name</label>\n <div ng-class="{\'has-error\': ($ctrl.forms.createProjectForm.name.$error.pattern && $ctrl.forms.createProjectForm.name.$touched) || $ctrl.nameTaken}">\n <input class="form-control"\n name="name"\n id="name"\n placeholder="my-project"\n type="text"\n required\n take-focus\n minlength="2"\n maxlength="63"\n pattern="[a-z0-9]([-a-z0-9]*[a-z0-9])?"\n aria-describedby="nameHelp"\n ng-model="$ctrl.selectedProject.metadata.name"\n osc-unique="$ctrl.existingProjectNames"\n ng-model-options="{ updateOn: \'default blur\' }"\n ng-change="$ctrl.onNewProjectNameChange()"\n autocorrect="off"\n autocapitalize="off"\n spellcheck="false">\n <div class="help-block">A unique name for the project.</div>\n <div class="has-error" ng-if="$ctrl.forms.createProjectForm.name.$error.minlength && $ctrl.forms.createProjectForm.name.$touched">\n <span id="nameHelp" class="help-block">\n Name must have at least two characters.\n </span>\n </div>\n <div class="has-error" ng-if="$ctrl.forms.createProjectForm.name.$error.pattern && $ctrl.forms.createProjectForm.name.$touched">\n <span id="nameHelp" class="help-block">\n Project names may only contain lower-case letters, numbers, and dashes.\n They may not start or end with a dash.\n </span>\n </div>\n <div class="has-error" ng-if="$ctrl.nameTaken || $ctrl.forms.createProjectForm.name.$error.oscUnique">\n <span class="help-block">\n This name is already in use. Please choose a different name.\n </span>\n </div>\n </div>\n </div>\n\n <div class="form-group">\n <label for="displayName" class="control-label">Project Display Name</label>\n <input class="form-control"\n name="displayName"\n id="displayName"\n placeholder="My Project"\n type="text"\n ng-model="$ctrl.selectedProject.metadata.annotations[\'new-display-name\']">\n </div>\n\n <div class="form-group">\n <label for="description" class="control-label">Project Description</label>\n <textarea class="form-control"\n name="description"\n id="description"\n placeholder="A short description."\n ng-model="$ctrl.selectedProject.metadata.annotations[\'openshift.io/description\']"></textarea>\n </div>\n</ng-form>\n<div ng-if="!$ctrl.noProjectsCantCreate && $ctrl.showDivider" class="select-project-divider"></div>\n\n';
}, function(e, t) {
e.exports = '<div class="services-view" ng-style="$ctrl.viewStyle">\n <div ng-if="!$ctrl.loaded" class="spinner-container">\n <div class="spinner spinner-xl"></div>\n </div>\n <div ng-if="$ctrl.loaded" class="services-view-container mobile-{{$ctrl.mobileView}}-view">\n <div class="add-methods">\n <h1>Browse Catalog</h1>\n <div ng-if="$ctrl.onDeployImageSelected || $ctrl.onFromFileSelected || $ctrl.onCreateFromProject">\n <ul class="add-other hidden-md hidden-lg">\n <li uib-dropdown="" class="dropdown">\n <a uib-dropdown-toggle="" class="dropdown-toggle" id="add-methods-dropdown" href="" aria-haspopup="true" aria-expanded="false">\n Custom Add\n <span class="caret" aria-hidden="true"></span>\n </a>\n <ul class="uib-dropdown-menu dropdown-menu pull-right" aria-labelledby="add-methods-dropdown">\n \x3c!-- note these are duplicated below --\x3e\n <li ng-if="$ctrl.onDeployImageSelected">\n <a href="" ng-click="$ctrl.onDeployImageSelected()">Deploy Image</a>\n </li>\n <li ng-if="$ctrl.onFromFileSelected">\n <a href="" ng-click="$ctrl.onFromFileSelected()">Import YAML / JSON</a>\n </li>\n <li ng-if="$ctrl.onCreateFromProject">\n <a href="" ng-click="$ctrl.onCreateFromProject()">Select from Project</a>\n </li>\n </ul>\n </li>\n </ul>\n <ul class="add-other hidden-xs hidden-sm">\n \x3c!-- note these are duplicated above --\x3e\n <li ng-if="$ctrl.onDeployImageSelected">\n <a href="" ng-click="$ctrl.onDeployImageSelected()">Deploy Image</a>\n </li>\n <li ng-if="$ctrl.onFromFileSelected">\n <a href="" ng-click="$ctrl.onFromFileSelected()">Import YAML / JSON</a>\n </li>\n <li ng-if="$ctrl.onCreateFromProject">\n <a href="" ng-click="$ctrl.onCreateFromProject()">Select from Project</a>\n </li>\n </ul>\n </div>\n </div>\n <ul class="nav nav-tabs nav-tabs-pf services-categories">\n <li ng-repeat="category in $ctrl.categories"\n ng-if="category.hasItems"\n ng-class="{ active: $ctrl.currentFilter === category.id }">\n <a href="" id="{{\'category-\'+category.id}}" class="services-category-heading" ng-click="$ctrl.selectCategory(category.id)">{{category.label}}</a>\n <a ng-click="$ctrl.mobileView = \'categories\'" class="services-back-link" href="">Back</a>\n </li>\n </ul>\n\n <div class="services-inner-container">\n \x3c!-- Do not show sub-category items for \'All\' or \'Other\' main categories --\x3e\n <ul class="services-sub-categories"\n ng-if="$ctrl.currentFilter !== \'other\' && $ctrl.currentFilter !== \'all\'">\n <li ng-repeat="subCategory in $ctrl.subCategories track by subCategory.id"\n ng-if="subCategory.hasItems"\n ng-attr-id="{{subCategory.id}}"\n class="services-sub-category"\n ng-class="{ active: $ctrl.currentSubFilter === subCategory.id }">\n <a href="" id="{{\'services-sub-category-\'+subCategory.id}}"\n class="services-sub-category-tab" ng-click="$ctrl.selectSubCategory(subCategory.id)">\n <div class="services-sub-category-tab-image" ng-if="imageUrl = (subCategory.imageUrl || (subCategory.icon | imageForIconClass))">\n <img ng-src="{{imageUrl}}" alt="">\n </div>\n <div class="services-sub-category-tab-icon {{subCategory.icon}}"\n ng-class="{ \'font-icon\': !subCategory.icon.contains(\'fa \') }"\n ng-if="subCategory.icon && !subCategory.imageUrl && !(subCategory.icon | imageForIconClass)"></div>\n <div class="services-sub-category-tab-name">{{subCategory.label}}</div>\n </a>\n <a ng-click="$ctrl.mobileView = \'subcategories\'" class="services-back-link" href="">Back</a>\n <div ng-if="$ctrl.currentSubFilter === subCategory.id" class="services-items">\n <catalog-filter class="services-items-filter"\n config="$ctrl.filterConfig"\n filter-on-keyword="$ctrl.keywordFilterValue"\n apply-filters="$ctrl.applyFilters($event)">\n </catalog-filter>\n <div class="pf-empty-state" ng-if="$ctrl.filterConfig.appliedFilters.length > 0 && $ctrl.filterConfig.resultsCount === 0">\n <pf-empty-state config="$ctrl.emptyFilterConfig"></pf-empty-state>\n </div>\n <a href="" class="services-item" ng-repeat="item in $ctrl.filteredItems track by item.resource.metadata.uid" ng-click="$ctrl.serviceViewItemClicked(item)">\n <div ng-if="!item.imageUrl" class="services-item-icon">\n <span class="{{item.iconClass}}"></span>\n </div>\n <div ng-if="item.imageUrl" class="services-item-icon">\n <img ng-src="{{item.imageUrl}}" alt="">\n </div>\n <div class="services-item-name" title="{{item.name}}">\n {{item.name}}\n </div>\n </a>\n </div>\n </li>\n </ul>\n\n \x3c!-- Show catalog item for \'All\' and \'Other\' main categories --\x3e\n <div ng-if="$ctrl.currentFilter === \'other\' || $ctrl.currentFilter === \'all\'" class="services-no-sub-categories">\n <div class="services-items">\n <div ng-if="$ctrl.isEmpty">There are no catalog items.</div>\n <catalog-filter ng-if="!$ctrl.isEmpty"\n class="services-items-filter"\n config="$ctrl.filterConfig"\n filter-on-keyword="$ctrl.keywordFilterValue"\n apply-filters="$ctrl.applyFilters($event)">\n </catalog-filter>\n <div class="pf-empty-state" ng-if="$ctrl.filterConfig.appliedFilters.length > 0 && $ctrl.filterConfig.resultsCount === 0">\n <pf-empty-state config="$ctrl.emptyFilterConfig"></pf-empty-state>\n </div>\n <a href="" class="services-item" ng-repeat="item in $ctrl.filteredItems track by item.resource.metadata.uid" ng-click="$ctrl.serviceViewItemClicked(item)">\n <div ng-if="!item.imageUrl" class="services-item-icon">\n <span class="{{item.iconClass}}"></span>\n </div>\n <div ng-if="item.imageUrl" class="services-item-icon">\n <img ng-src="{{item.imageUrl}}" alt="">\n </div>\n <div class="services-item-name" title="{{item.name}}">\n {{item.name}}\n </div>\n </a>\n </div>\n </div>\n </div>\n </div>\n</div>\n';
}, function(e, t) {
Expand Down
Loading

0 comments on commit 8f03129

Please sign in to comment.