fix(k8s): fixerror handling for namespace restricted user EE-1703 (#5693)

* fix error handler for namespace when user have no namespace access
pull/5709/head
Richard Wei 2021-09-22 16:01:42 +12:00 committed by GitHub
parent 092d217985
commit bcdc342cbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 82 additions and 69 deletions

View File

@ -39,7 +39,7 @@
Configuration Configuration
</div> </div>
<!-- namespace-input --> <!-- namespace-input -->
<div class="form-group"> <div class="form-group" ng-if="$ctrl.state.resourcePool">
<label for="resource-pool-selector" class="col-sm-2 control-label text-left">Namespace</label> <label for="resource-pool-selector" class="col-sm-2 control-label text-left">Namespace</label>
<div class="col-sm-10"> <div class="col-sm-10">
<select <select
@ -52,13 +52,7 @@
></select> ></select>
</div> </div>
</div> </div>
<div class="form-group" ng-if="!$ctrl.state.resourcePool">
<div class="col-sm-12 small text-danger">
<i class="fa fa-exclamation-circle red-icon" aria-hidden="true" style="margin-right: 2px;"></i>
This namespace has exhausted its resource capacity and you will not be able to deploy the application. Contact your administrator to expand the capacity of the
namespace.
</div>
</div>
<div class="form-group" ng-if="!$ctrl.state.resourcePool"> <div class="form-group" ng-if="!$ctrl.state.resourcePool">
<div class="col-sm-12 small text-muted"> <div class="col-sm-12 small text-muted">
<i class="fa fa-exclamation-circle orange-icon" aria-hidden="true" style="margin-right: 2px;"></i> <i class="fa fa-exclamation-circle orange-icon" aria-hidden="true" style="margin-right: 2px;"></i>

View File

@ -141,6 +141,7 @@
<div class="col-sm-12"> <div class="col-sm-12">
<por-image-registry <por-image-registry
model="ctrl.formValues.ImageModel" model="ctrl.formValues.ImageModel"
ng-if="ctrl.formValues.ResourcePool"
auto-complete="false" auto-complete="false"
label-class="col-sm-1" label-class="col-sm-1"
input-class="col-sm-11" input-class="col-sm-11"
@ -152,7 +153,7 @@
></por-image-registry> ></por-image-registry>
</div> </div>
</div> </div>
<div ng-if="ctrl.formValues.ResourcePool">
<div class="col-sm-12 form-section-title"> <div class="col-sm-12 form-section-title">
Stack Stack
</div> </div>
@ -1608,6 +1609,7 @@
old-form-values="ctrl.savedFormValues" old-form-values="ctrl.savedFormValues"
></kubernetes-summary-view> ></kubernetes-summary-view>
</div> </div>
</div>
<div class="col-sm-12 form-section-title" ng-if="ctrl.state.appType !== ctrl.KubernetesDeploymentTypes.GIT"> <div class="col-sm-12 form-section-title" ng-if="ctrl.state.appType !== ctrl.KubernetesDeploymentTypes.GIT">
Actions Actions

View File

@ -49,7 +49,7 @@
</div> </div>
<!-- resource-pool --> <!-- resource-pool -->
<div class="form-group"> <div class="form-group" ng-if="ctrl.formValues.ResourcePool">
<label for="resource-pool-selector" class="col-sm-1 control-label text-left">Namespace</label> <label for="resource-pool-selector" class="col-sm-1 control-label text-left">Namespace</label>
<div class="col-sm-11"> <div class="col-sm-11">
<select <select
@ -57,6 +57,7 @@
id="resource-pool-selector" id="resource-pool-selector"
ng-model="ctrl.formValues.ResourcePool" ng-model="ctrl.formValues.ResourcePool"
ng-options="resourcePool.Namespace.Name for resourcePool in ctrl.resourcePools" ng-options="resourcePool.Namespace.Name for resourcePool in ctrl.resourcePools"
ng-change="ctrl.onResourcePoolSelectionChange()"
data-cy="k8sConfigCreate-namespaceDropdown" data-cy="k8sConfigCreate-namespaceDropdown"
></select> ></select>
</div> </div>
@ -68,8 +69,14 @@
namespace. namespace.
</div> </div>
</div> </div>
<div class="form-group" ng-if="!ctrl.formValues.ResourcePool">
<div class="col-sm-12 small text-muted">
<i class="fa fa-exclamation-circle orange-icon" aria-hidden="true" style="margin-right: 2px;"></i>
You do not have access to any namespace. Contact your administrator to get access to a namespace.
</div>
</div>
<!-- !resource-pool --> <!-- !resource-pool -->
<div ng-if="ctrl.formValues.ResourcePool">
<div class="col-sm-12 form-section-title"> <div class="col-sm-12 form-section-title">
Configuration type Configuration type
</div> </div>
@ -130,7 +137,7 @@
ng-if="!(!kubernetesConfigurationCreationForm.$valid || !ctrl.isFormValid() || ctrl.state.actionInProgress)" ng-if="!(!kubernetesConfigurationCreationForm.$valid || !ctrl.isFormValid() || ctrl.state.actionInProgress)"
form-values="ctrl.formValues" form-values="ctrl.formValues"
></kubernetes-summary-view> ></kubernetes-summary-view>
</div>
<!-- actions --> <!-- actions -->
<div class="col-sm-12 form-section-title" style="margin-top: 10px;"> <div class="col-sm-12 form-section-title" style="margin-top: 10px;">
Actions Actions
@ -140,7 +147,7 @@
<button <button
type="button" type="button"
class="btn btn-primary btn-sm" class="btn btn-primary btn-sm"
ng-disabled="!kubernetesConfigurationCreationForm.$valid || !ctrl.isFormValid() || ctrl.state.actionInProgress" ng-disabled="!kubernetesConfigurationCreationForm.$valid || !ctrl.isFormValid() || ctrl.state.actionInProgress || !ctrl.formValues.ResourcePool"
ng-click="ctrl.createConfiguration()" ng-click="ctrl.createConfiguration()"
button-spinner="ctrl.state.actionInProgress" button-spinner="ctrl.state.actionInProgress"
data-cy="k8sConfigCreate-CreateConfigButton" data-cy="k8sConfigCreate-CreateConfigButton"

View File

@ -16,12 +16,18 @@
<uib-tab-heading> <i class="fa fa-code space-right" aria-hidden="true"></i> Deploy </uib-tab-heading> <uib-tab-heading> <i class="fa fa-code space-right" aria-hidden="true"></i> Deploy </uib-tab-heading>
<form class="form-horizontal" style="margin-top: 20px;"> <form class="form-horizontal" style="margin-top: 20px;">
<div class="form-group"> <div class="form-group" ng-if="ctrl.formValues.Namespace">
<label for="target_node" class="col-lg-1 col-sm-2 control-label text-left">Namespace</label> <label for="target_node" class="col-lg-1 col-sm-2 control-label text-left">Namespace</label>
<div class="col-lg-11 col-sm-10"> <div class="col-lg-11 col-sm-10">
<select class="form-control" ng-model="ctrl.formValues.Namespace" ng-options="namespace.Name as namespace.Name for namespace in ctrl.namespaces"></select> <select class="form-control" ng-model="ctrl.formValues.Namespace" ng-options="namespace.Name as namespace.Name for namespace in ctrl.namespaces"></select>
</div> </div>
</div> </div>
<div class="form-group" ng-if="!ctrl.formValues.Namespace">
<div class="col-sm-12 small text-muted">
<i class="fa fa-exclamation-circle orange-icon" aria-hidden="true" style="margin-right: 2px;"></i>
You do not have access to any namespace. Contact your administrator to get access to a namespace.
</div>
</div>
<div class="col-sm-12 form-section-title"> <div class="col-sm-12 form-section-title">
Build method Build method

View File

@ -107,7 +107,9 @@ class KubernetesDeployController {
this.state.BuildMethod === KubernetesDeployBuildMethods.WEB_EDITOR && _.isEmpty(this.formValues.EditorContent) && _.isEmpty(this.formValues.Namespace); this.state.BuildMethod === KubernetesDeployBuildMethods.WEB_EDITOR && _.isEmpty(this.formValues.EditorContent) && _.isEmpty(this.formValues.Namespace);
const isURLFormInvalid = this.state.BuildMethod == KubernetesDeployBuildMethods.WEB_EDITOR.URL && _.isEmpty(this.formValues.ManifestURL); const isURLFormInvalid = this.state.BuildMethod == KubernetesDeployBuildMethods.WEB_EDITOR.URL && _.isEmpty(this.formValues.ManifestURL);
return isGitFormInvalid || isWebEditorInvalid || isURLFormInvalid || this.state.actionInProgress; const isNamespaceInvalid = _.isEmpty(this.formValues.Namespace);
return isGitFormInvalid || isWebEditorInvalid || isURLFormInvalid || this.state.actionInProgress || isNamespaceInvalid;
} }
onChangeFormValues(values) { onChangeFormValues(values) {
@ -230,7 +232,9 @@ class KubernetesDeployController {
}); });
this.namespaces = namespaces; this.namespaces = namespaces;
if (this.namespaces.length > 0) {
this.formValues.Namespace = this.namespaces[0].Name; this.formValues.Namespace = this.namespaces[0].Name;
}
} catch (err) { } catch (err) {
this.Notifications.error('Failure', err, 'Unable to load namespaces data'); this.Notifications.error('Failure', err, 'Unable to load namespaces data');
} }