mirror of
https://github.com/portainer/portainer.git
synced 2025-07-20 05:49:40 +02:00
refactor(app): placement form section [EE-6386] (#10818)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
Co-authored-by: testa113 <testa113>
This commit is contained in:
parent
2d77e71085
commit
9fc7187e24
16 changed files with 349 additions and 220 deletions
|
@ -13,14 +13,12 @@ import {
|
|||
KubernetesApplicationPublishingTypes,
|
||||
KubernetesApplicationQuotaDefaults,
|
||||
KubernetesApplicationTypes,
|
||||
KubernetesApplicationPlacementTypes,
|
||||
KubernetesDeploymentTypes,
|
||||
} from 'Kubernetes/models/application/models';
|
||||
import {
|
||||
KubernetesApplicationEnvironmentVariableFormValue,
|
||||
KubernetesApplicationFormValues,
|
||||
KubernetesApplicationPersistedFolderFormValue,
|
||||
KubernetesApplicationPlacementFormValue,
|
||||
KubernetesFormValidationReferences,
|
||||
} from 'Kubernetes/models/application/formValues';
|
||||
import KubernetesFormValidationHelper from 'Kubernetes/helpers/formValidationHelper';
|
||||
|
@ -36,7 +34,6 @@ import { confirmUpdateAppIngress } from '@/react/kubernetes/applications/CreateV
|
|||
import { confirm, confirmUpdate, confirmWebEditorDiscard } from '@@/modals/confirm';
|
||||
import { buildConfirmButton } from '@@/modals/utils';
|
||||
import { ModalType } from '@@/modals';
|
||||
import { placementOptions } from '@/react/kubernetes/applications/CreateView/placementTypes';
|
||||
|
||||
class KubernetesCreateApplicationController {
|
||||
/* #region CONSTRUCTOR */
|
||||
|
@ -80,13 +77,10 @@ class KubernetesCreateApplicationController {
|
|||
this.ApplicationDeploymentTypes = KubernetesApplicationDeploymentTypes;
|
||||
this.ApplicationDataAccessPolicies = KubernetesApplicationDataAccessPolicies;
|
||||
this.ApplicationPublishingTypes = KubernetesApplicationPublishingTypes;
|
||||
this.ApplicationPlacementTypes = KubernetesApplicationPlacementTypes;
|
||||
this.ApplicationTypes = KubernetesApplicationTypes;
|
||||
this.ServiceTypes = KubernetesServiceTypes;
|
||||
this.KubernetesDeploymentTypes = KubernetesDeploymentTypes;
|
||||
|
||||
this.placementOptions = placementOptions;
|
||||
|
||||
this.state = {
|
||||
appType: this.KubernetesDeploymentTypes.APPLICATION_FORM,
|
||||
updateWebEditorInProgress: false,
|
||||
|
@ -148,7 +142,6 @@ class KubernetesCreateApplicationController {
|
|||
this.onDataAccessPolicyChange = this.onDataAccessPolicyChange.bind(this);
|
||||
this.onChangeDeploymentType = this.onChangeDeploymentType.bind(this);
|
||||
this.supportGlobalDeployment = this.supportGlobalDeployment.bind(this);
|
||||
this.onChangePlacementType = this.onChangePlacementType.bind(this);
|
||||
this.onServicesChange = this.onServicesChange.bind(this);
|
||||
this.onEnvironmentVariableChange = this.onEnvironmentVariableChange.bind(this);
|
||||
this.onConfigMapsChange = this.onConfigMapsChange.bind(this);
|
||||
|
@ -157,12 +150,14 @@ class KubernetesCreateApplicationController {
|
|||
this.onChangeResourceReservation = this.onChangeResourceReservation.bind(this);
|
||||
this.onChangeReplicaCount = this.onChangeReplicaCount.bind(this);
|
||||
this.onAutoScaleChange = this.onAutoScaleChange.bind(this);
|
||||
this.onChangePlacements = this.onChangePlacements.bind(this);
|
||||
}
|
||||
/* #endregion */
|
||||
|
||||
onChangePlacementType(value) {
|
||||
this.$scope.$evalAsync(() => {
|
||||
this.formValues.PlacementType = value;
|
||||
onChangePlacements(values) {
|
||||
return this.$async(async () => {
|
||||
this.formValues.Placements = values.placements;
|
||||
this.formValues.PlacementType = values.placementType;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -410,50 +405,6 @@ class KubernetesCreateApplicationController {
|
|||
}
|
||||
/* #endregion */
|
||||
|
||||
/* #region PLACEMENT UI MANAGEMENT */
|
||||
addPlacement() {
|
||||
const placement = new KubernetesApplicationPlacementFormValue();
|
||||
const label = this.nodesLabels[0];
|
||||
placement.Label = label;
|
||||
placement.Value = label.Values[0];
|
||||
this.formValues.Placements.push(placement);
|
||||
this.onChangePlacement();
|
||||
}
|
||||
|
||||
restorePlacement(index) {
|
||||
this.formValues.Placements[index].NeedsDeletion = false;
|
||||
this.onChangePlacement();
|
||||
}
|
||||
|
||||
removePlacement(index) {
|
||||
if (this.state.isEdit && !this.formValues.Placements[index].IsNew) {
|
||||
this.formValues.Placements[index].NeedsDeletion = true;
|
||||
} else {
|
||||
this.formValues.Placements.splice(index, 1);
|
||||
}
|
||||
this.onChangePlacement();
|
||||
}
|
||||
|
||||
// call all validation functions when a placement is added/removed/restored
|
||||
onChangePlacement() {
|
||||
this.onChangePlacementLabelValidate();
|
||||
}
|
||||
|
||||
onChangePlacementLabel(index) {
|
||||
this.formValues.Placements[index].Value = this.formValues.Placements[index].Label.Values[0];
|
||||
this.onChangePlacementLabelValidate();
|
||||
}
|
||||
|
||||
onChangePlacementLabelValidate() {
|
||||
const state = this.state.duplicates.placements;
|
||||
const source = _.map(this.formValues.Placements, (p) => (p.NeedsDeletion ? undefined : p.Label.Key));
|
||||
const duplicates = KubernetesFormValidationHelper.getDuplicates(source);
|
||||
state.refs = duplicates;
|
||||
state.hasRefs = Object.keys(duplicates).length > 0;
|
||||
}
|
||||
|
||||
/* #endregion */
|
||||
|
||||
/* #region SERVICES UI MANAGEMENT */
|
||||
onServicesChange(services) {
|
||||
return this.$async(async () => {
|
||||
|
@ -675,15 +626,6 @@ class KubernetesCreateApplicationController {
|
|||
}
|
||||
/* #endregion */
|
||||
|
||||
isEditAndNotNewPlacement(index) {
|
||||
return this.state.isEdit && !this.formValues.Placements[index].IsNew;
|
||||
}
|
||||
|
||||
showPlacementPolicySection() {
|
||||
const placements = _.filter(this.formValues.Placements, { NeedsDeletion: false });
|
||||
return placements.length !== 0;
|
||||
}
|
||||
|
||||
isNonScalable() {
|
||||
const scalable = this.supportScalableReplicaDeployment();
|
||||
const global = this.supportGlobalDeployment();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue