From 8e97d5925b1cc1781d1651ae0acdc681175c3edb Mon Sep 17 00:00:00 2001 From: Ethan Rogers Date: Thu, 16 May 2019 13:53:37 -0400 Subject: [PATCH] refactor(kubernetes): namespace selector component (#7012) create a namespace selector component which can be reused. optional creatable functionality to support cases where SpEL is allowable. --- .../ManifestDeploymentOptions.tsx | 20 ++++------ .../deployManifest/NamespaceSelector.tsx | 38 +++++++++++++++++++ 2 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 app/scripts/modules/kubernetes/src/v2/pipelines/stages/deployManifest/NamespaceSelector.tsx diff --git a/app/scripts/modules/kubernetes/src/v2/pipelines/stages/deployManifest/ManifestDeploymentOptions.tsx b/app/scripts/modules/kubernetes/src/v2/pipelines/stages/deployManifest/ManifestDeploymentOptions.tsx index c01b8a50bff..a8543c0161d 100644 --- a/app/scripts/modules/kubernetes/src/v2/pipelines/stages/deployManifest/ManifestDeploymentOptions.tsx +++ b/app/scripts/modules/kubernetes/src/v2/pipelines/stages/deployManifest/ManifestDeploymentOptions.tsx @@ -1,12 +1,13 @@ import * as DOMPurify from 'dompurify'; import * as React from 'react'; -import { cloneDeep, find, get, map, set, split } from 'lodash'; +import { cloneDeep, map, set, split } from 'lodash'; import Select, { Option } from 'react-select'; import { IAccountDetails, IDeploymentStrategy, StageConfigField } from '@spinnaker/core'; import { ManifestKindSearchService } from 'kubernetes/v2/manifest/ManifestKindSearch'; import { rolloutStrategies } from 'kubernetes/v2/rolloutStrategy'; +import { NamespaceSelector } from './NamespaceSelector'; export interface ITrafficManagementConfig { enabled: boolean; @@ -66,13 +67,6 @@ export class ManifestDeploymentOptions extends React.Component< }); }; - private getNamespaceOptions = (): Array> => { - const { accounts, selectedAccount } = this.props; - const selectedAccountDetails = find(accounts, a => a.name === selectedAccount); - const namespaces = get(selectedAccountDetails, 'namespaces', []); - return map(namespaces, n => ({ label: n, value: n })); - }; - private strategyOptionRenderer = (option: IDeploymentStrategy) => { return (
@@ -125,11 +119,11 @@ export class ManifestDeploymentOptions extends React.Component< {config.enabled && ( <> - ; + } +}