diff --git a/src/components/Secrets/SecretsForm/AddSecretForm.tsx b/src/components/Secrets/SecretsForm/AddSecretForm.tsx index 32635e5be..61772d0b1 100644 --- a/src/components/Secrets/SecretsForm/AddSecretForm.tsx +++ b/src/components/Secrets/SecretsForm/AddSecretForm.tsx @@ -5,12 +5,7 @@ import { OpenDrawerRightIcon } from '@patternfly/react-icons/dist/esm/icons/open import { Formik } from 'formik'; import { isEmpty } from 'lodash-es'; import FormFooter from '../../../shared/components/form-components/FormFooter'; -import { - AddSecretFormValues, - SecretFor, - SecretTypeDropdownLabel, - TargetDropdownDefaults, -} from '../../../types'; +import { AddSecretFormValues, SecretFor, SecretTypeDropdownLabel } from '../../../types'; import { addSecret } from '../../../utils/create-utils'; import { useWorkspaceInfo } from '../../../utils/workspace-context-utils'; import { HelpTopicLink } from '../../HelpTopicLink/HelpTopicLink'; @@ -26,10 +21,6 @@ const AddSecretForm = () => { type: SecretTypeDropdownLabel.opaque, name: '', secretFor: SecretFor.Build, - targets: { - application: '', - component: TargetDropdownDefaults.ALL_COMPONENTS, - }, opaque: { keyValues: [{ key: '', value: '' }], }, diff --git a/src/components/Secrets/SecretsForm/SecretTypeSubForm.tsx b/src/components/Secrets/SecretsForm/SecretTypeSubForm.tsx index 258f3085e..4eb02a942 100644 --- a/src/components/Secrets/SecretsForm/SecretTypeSubForm.tsx +++ b/src/components/Secrets/SecretsForm/SecretTypeSubForm.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { SelectVariant } from '@patternfly/react-core/deprecated'; import { useFormikContext } from 'formik'; -import { DropdownItemObject, InputField, RadioGroupField, SelectInputField } from '../../../shared'; +import { DropdownItemObject, InputField, SelectInputField } from '../../../shared'; import KeyValueField from '../../../shared/components/formik-fields/key-value-input-field/KeyValueInputField'; import { AddSecretFormValues, SecretFor, SecretTypeDropdownLabel } from '../../../types'; import SecretTypeSelector from '../SecretTypeSelector'; @@ -11,8 +11,6 @@ import { isPartnerTask, isPartnerTaskAvailable, } from '../utils/secret-utils'; -import { ApplicationDropdown } from './ApplicationDropdown'; -import { ComponentDropdown } from './ComponentDropdown'; import { ImagePullSecretForm } from './ImagePullSecretForm'; import { KeyValueSecretForm } from './KeyValueSecretForm'; import { SourceSecretForm } from './SourceSecretForm'; @@ -94,23 +92,6 @@ export const SecretTypeSubForm: React.FC> = () return ( <> - { - setFieldValue('secretFor', type); - setFieldValue('type', availableTypes[0]); - if (type === SecretFor.Deployment) { - name && isPartnerTask(name) && setFieldValue('name', ''); - clearKeyValues(); - } - }} - required - /> > = () } }} /> - {secretFor === SecretFor.Build && isPartnerTaskAvailable(currentTypeRef.current) ? ( + {isPartnerTaskAvailable(currentTypeRef.current) ? ( > = () /> )} - {secretFor === SecretFor.Deployment && ( - <> - - - - )} {selectedForm && selectedForm.component} { title: 'Name', props: { className: secretsTableColumnClasses.name }, }, - { - title: 'Target', - props: { className: secretsTableColumnClasses.target }, - }, { title: 'Labels', props: { className: secretsTableColumnClasses.labels }, diff --git a/src/components/Secrets/SecretsListView/SecretsListRow.tsx b/src/components/Secrets/SecretsListView/SecretsListRow.tsx index b4c1e4f73..59f9a2bb9 100644 --- a/src/components/Secrets/SecretsListView/SecretsListRow.tsx +++ b/src/components/Secrets/SecretsListView/SecretsListRow.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Label, Skeleton } from '@patternfly/react-core'; +import { Label } from '@patternfly/react-core'; import { RowFunctionArgs, TableData } from '../../../shared'; import ActionMenu from '../../../shared/components/action-menu/ActionMenu'; import { RemoteSecretKind } from '../../../types/secret'; @@ -14,31 +14,20 @@ export enum RemoteSecretStatus { Failed = 'Failed', } -const SecretsListRow: React.FC> = ({ - obj, - customData = {}, -}) => { - const { environmentsLoaded = true } = customData; +const SecretsListRow: React.FC> = ({ obj }) => { const actions = useSecretActions(obj); - const { secretName, secretFor, secretTarget, secretLabels, secretType, secretStatus } = - getSecretRowData(obj); + const { secretName, secretFor, secretLabels, secretType, secretStatus } = getSecretRowData(obj); const labels = secretLabels !== '-' ? secretLabels.split(', ').map((s) => ) : secretLabels; - const environmentsTarget = environmentsLoaded ? ( - secretTarget - ) : ( - - ); return ( <> {secretFor} {secretType} {secretName} - {environmentsTarget} {labels} {secretStatus} diff --git a/src/components/Secrets/__tests___/AddSecretForm.spec.tsx b/src/components/Secrets/__tests___/AddSecretForm.spec.tsx index fb1bec129..38c1349b2 100644 --- a/src/components/Secrets/__tests___/AddSecretForm.spec.tsx +++ b/src/components/Secrets/__tests___/AddSecretForm.spec.tsx @@ -56,7 +56,6 @@ describe('AddSecretForm', () => { render(); await waitFor(() => { - screen.getByText('Secret for'); screen.getByText('Secret type'); screen.getByText('Secret name'); screen.getByText('Labels'); diff --git a/src/components/Secrets/__tests___/SecretTypeSubForm.spec.tsx b/src/components/Secrets/__tests___/SecretTypeSubForm.spec.tsx index 31b1a668f..850490dfe 100644 --- a/src/components/Secrets/__tests___/SecretTypeSubForm.spec.tsx +++ b/src/components/Secrets/__tests___/SecretTypeSubForm.spec.tsx @@ -44,19 +44,11 @@ describe('SecretTypeSubForm', () => { }); it('should render Secret type sub form and fields', () => { - expect(screen.getByText('Secret for')).toBeVisible(); expect(screen.getByText('Secret type')).toBeVisible(); expect(screen.getByText('Secret name')).toBeVisible(); }); it('should render subforms correctly for specified targets', async () => { - await fireEvent.click(screen.getByRole('radio', { name: 'Deployment' })); - await waitFor(() => { - expect(screen.getByRole('button', { name: 'Key/value secret' })).toBeDisabled(); - expect(screen.getByText('Key value sub form')).toBeVisible(); - }); - - await fireEvent.click(screen.getByRole('radio', { name: 'Build' })); await waitFor(() => { expect(screen.getByRole('button', { name: 'Key/value secret' })).toBeEnabled(); }); @@ -67,25 +59,10 @@ describe('SecretTypeSubForm', () => { }); it('should render correct variant of name field', async () => { - await fireEvent.click(screen.getByRole('radio', { name: 'Deployment' })); - await waitFor(() => { - expect(screen.getByRole('textbox', { name: 'Secret name' })).toBeVisible(); - }); - - await fireEvent.click(screen.getByRole('radio', { name: 'Build' })); await waitFor(async () => { expect(screen.getByRole('button', { name: 'Secret name' })).toBeVisible(); await fireEvent.click(screen.getByRole('button', { name: 'Secret name' })); expect(screen.getByText('snyk-secret')).toBeVisible(); }); }); - - it('should render target fields for Deployment secret', async () => { - await fireEvent.click(screen.getByRole('radio', { name: 'Deployment' })); - - await waitFor(() => { - expect(screen.getByRole('button', { name: 'Select application' })).toBeVisible(); - expect(screen.getByRole('button', { name: 'All components' })).toBeVisible(); - }); - }); }); diff --git a/src/components/Secrets/__tests___/SecretsListView.spec.tsx b/src/components/Secrets/__tests___/SecretsListView.spec.tsx index 416d55f88..337682855 100644 --- a/src/components/Secrets/__tests___/SecretsListView.spec.tsx +++ b/src/components/Secrets/__tests___/SecretsListView.spec.tsx @@ -78,7 +78,6 @@ describe('Secrets List', () => { screen.getByText('test-secret-one'); screen.getByText('AwaitingData'); - screen.getByText('Deployment'); screen.getByText('Image pull'); }); diff --git a/src/components/Secrets/__tests___/secret-utils.spec.ts b/src/components/Secrets/__tests___/secret-utils.spec.ts index 1ab235bb8..03fdd08e9 100644 --- a/src/components/Secrets/__tests___/secret-utils.spec.ts +++ b/src/components/Secrets/__tests___/secret-utils.spec.ts @@ -10,7 +10,6 @@ import { SecretType, SecretTypeDropdownLabel, SourceSecretType, - TargetDropdownDefaults, } from '../../../types'; import { createRemoteSecretResource, @@ -155,7 +154,6 @@ describe('getSecretRowData', () => { secretLabels: '-', secretName: 'test-secret-two', secretStatus: 'Injected', - secretTarget: '-', secretType: 'Key/value (1)', }); }); @@ -173,7 +171,6 @@ describe('getSecretRowData', () => { secretLabels: '-', secretName: 'test-secret-two', secretStatus: '-', - secretTarget: '-', secretType: 'Key/value', }); }); @@ -251,10 +248,6 @@ const formValues: AddSecretFormValues = { type: 'Key/value secret', name: 'test', secretFor: SecretFor.Build, - targets: { - application: 'test-application', - component: TargetDropdownDefaults.ALL_COMPONENTS, - }, opaque: { keyValues: [ { @@ -384,57 +377,17 @@ describe('getTargetLabelsForRemoteSecret', () => { expect( getTargetLabelsForRemoteSecret({ ...formValues, - targets: { application: null, component: null }, }), ).toEqual({ 'ui.appstudio.redhat.com/secret-for': 'Build', }); }); - it('should return application target labels for remote secret', () => { - expect(getTargetLabelsForRemoteSecret(formValues)).toEqual({ - 'appstudio.redhat.com/application': 'test-application', - 'ui.appstudio.redhat.com/secret-for': 'Build', - }); - }); - - it('should return application and component target labels for remote secret', () => { - const fValues = { - ...formValues, - targets: { - ...formValues.targets, - component: 'test-component', - }, - }; - expect(getTargetLabelsForRemoteSecret(fValues)).toEqual({ - 'appstudio.redhat.com/application': 'test-application', - 'appstudio.openshift.io/component': 'test-component', - 'ui.appstudio.redhat.com/secret-for': 'Build', - }); - }); - - it('should return application, component and environment target labels for remote secret', () => { - const fValues = { - ...formValues, - targets: { - ...formValues.targets, - component: 'test-component', - environment: 'test-environment', - }, - }; - expect(getTargetLabelsForRemoteSecret(fValues)).toEqual({ - 'appstudio.redhat.com/application': 'test-application', - 'appstudio.openshift.io/component': 'test-component', - 'ui.appstudio.redhat.com/secret-for': 'Build', - }); - }); - it('should return correct label for build secret', () => { expect( getTargetLabelsForRemoteSecret({ ...formValues, secretFor: SecretFor.Build, - targets: { application: null, component: null }, }), ).toEqual({ 'ui.appstudio.redhat.com/secret-for': 'Build', @@ -446,7 +399,6 @@ describe('getTargetLabelsForRemoteSecret', () => { getTargetLabelsForRemoteSecret({ ...formValues, secretFor: SecretFor.Deployment, - targets: { application: null, component: null }, }), ).toEqual({ 'ui.appstudio.redhat.com/secret-for': 'Deployment', diff --git a/src/components/Secrets/__tests___/secret-validation.spec.ts b/src/components/Secrets/__tests___/secret-validation.spec.ts index 7da187f1f..3f189d0ed 100644 --- a/src/components/Secrets/__tests___/secret-validation.spec.ts +++ b/src/components/Secrets/__tests___/secret-validation.spec.ts @@ -1,9 +1,4 @@ -import { - ImagePullSecretType, - SecretFor, - SecretTypeDropdownLabel, - SourceSecretType, -} from '../../../types'; +import { ImagePullSecretType, SecretTypeDropdownLabel, SourceSecretType } from '../../../types'; import { secretFormValidationSchema } from '../utils/secret-validation'; describe('validation-utils', () => { @@ -89,16 +84,4 @@ describe('validation-utils', () => { }), ).rejects.toThrow('Required'); }); - - it('should validate targets field', async () => { - await expect(() => - secretFormValidationSchema.validate({ - secretFor: SecretFor.Deployment, - name: 'test-resource', - targets: { - application: '', - }, - }), - ).rejects.toThrow('Required'); - }); }); diff --git a/src/components/Secrets/utils/secret-utils.ts b/src/components/Secrets/utils/secret-utils.ts index c396a3b40..c232b3b18 100644 --- a/src/components/Secrets/utils/secret-utils.ts +++ b/src/components/Secrets/utils/secret-utils.ts @@ -15,12 +15,10 @@ import { SecretCondition, SecretFor, SecretKind, - SecretSPILabel, SecretType, SecretTypeDisplayLabel, SecretTypeDropdownLabel, SourceSecretType, - TargetDropdownDefaults, } from '../../../types'; export type PartnerTask = { @@ -171,17 +169,10 @@ export const getSecretFormData = (values: AddSecretFormValues, namespace: string export const getTargetLabelsForRemoteSecret = ( values: AddSecretFormValues, ): { [key: string]: string } => { - const { targets, secretFor } = values; + const { secretFor } = values; const labels = { [SecretByUILabel]: secretFor, }; - const { application, component } = targets; - - if (application) labels[SecretSPILabel.APPLICATION] = application; - - if (component && component !== TargetDropdownDefaults.ALL_COMPONENTS) - labels[SecretSPILabel.COMPONENT] = component; - return labels; }; @@ -216,8 +207,7 @@ export const getSecretRowData = (obj: RemoteSecretKind): any => { const keys = obj?.status?.secret?.keys; const secretName = obj?.spec?.secret?.name || '-'; - const secretFor = obj?.metadata?.labels?.[SecretByUILabel] ?? SecretFor.Deployment; - const secretTarget = obj?.metadata?.labels?.['appstudio.redhat.com/environment'] ?? '-'; + const secretFor = obj?.metadata?.labels?.[SecretByUILabel] ?? SecretFor.Build; const secretLabels = obj ? Object.keys(obj?.spec?.secret?.labels || {}) .map((k) => `${k}=${obj.spec?.secret?.labels[k]}`) @@ -230,7 +220,6 @@ export const getSecretRowData = (obj: RemoteSecretKind): any => { return { secretName, secretFor, - secretTarget, secretLabels, secretType, secretStatus, @@ -286,11 +275,6 @@ export const createRemoteSecretResource = ( type: secret.type, ...(labels?.secret && { labels: labels.secret }), }, - targets: [ - { - namespace, - }, - ], }, }; diff --git a/src/components/Secrets/utils/secret-validation.ts b/src/components/Secrets/utils/secret-validation.ts index 275aa6003..1ee2976be 100644 --- a/src/components/Secrets/utils/secret-validation.ts +++ b/src/components/Secrets/utils/secret-validation.ts @@ -2,12 +2,7 @@ import { Base64 } from 'js-base64'; import attempt from 'lodash-es/attempt'; import isError from 'lodash-es/isError'; import * as yup from 'yup'; -import { - ImagePullSecretType, - SecretFor, - SecretTypeDropdownLabel, - SourceSecretType, -} from '../../../types'; +import { ImagePullSecretType, SecretTypeDropdownLabel, SourceSecretType } from '../../../types'; import { MAX_RESOURCE_NAME_LENGTH, RESOURCE_NAME_LENGTH_ERROR_MSG, @@ -78,15 +73,4 @@ export const secretFormValidationSchema = yup.object({ }), }), }), - targets: yup.object().when('secretFor', { - is: SecretFor.Deployment, - then: yup.object({ - application: yup - .string() - .required('Required') - .test('application-label-test', 'Select an application', (application) => { - return application !== 'All applications'; - }), - }), - }), }); diff --git a/src/types/secret.ts b/src/types/secret.ts index 6c7aef140..ef098d4a9 100644 --- a/src/types/secret.ts +++ b/src/types/secret.ts @@ -51,7 +51,6 @@ export type RemoteSecretKind = K8sResourceCommon & { [key: string]: string; }; }; - targets: { namespace: string }[]; }; status?: RemoteSecretStatus; }; @@ -59,7 +58,6 @@ export type RemoteSecretKind = K8sResourceCommon & { export interface RemoteSecretStatus { conditions?: SecretCondition[]; secret?: Secret; - targets?: Target[]; } export enum RemoteSecretStatusReason { @@ -145,7 +143,6 @@ export interface AddSecretFormValues { type: string; name: string; secretFor: SecretFor; - targets: Targets; opaque: Opaque; image: Image; source: Source; diff --git a/src/utils/__tests__/create-utils.spec.ts b/src/utils/__tests__/create-utils.spec.ts index 5304e0672..dc9dae416 100644 --- a/src/utils/__tests__/create-utils.spec.ts +++ b/src/utils/__tests__/create-utils.spec.ts @@ -14,7 +14,6 @@ import { SPIAccessTokenBindingKind, SecretFor, SecretTypeDropdownLabel, - TargetDropdownDefaults, } from '../../types'; import { ApplicationModel } from './../../models/application'; import { ComponentDetectionQueryModel, ComponentModel } from './../../models/component'; @@ -168,10 +167,6 @@ const addSecretFormValues: AddSecretFormValues = { type: 'Image pull secret', name: 'test', secretFor: SecretFor.Build, - targets: { - application: 'test-application', - component: TargetDropdownDefaults.ALL_COMPONENTS, - }, opaque: { keyValues: [ {