diff --git a/plugins/cad/src/components/ResourceEditorDialog/components/FirstClassEditors/CapacityEditor/CapacityEditor.tsx b/plugins/cad/src/components/ResourceEditorDialog/components/FirstClassEditors/CapacityEditor/CapacityEditor.tsx deleted file mode 100644 index 468fe667..00000000 --- a/plugins/cad/src/components/ResourceEditorDialog/components/FirstClassEditors/CapacityEditor/CapacityEditor.tsx +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Copyright 2024 The Nephio Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { TextField } from '@material-ui/core'; -import React, { useState } from 'react'; -import { useSetStateAndCall } from '../../../../../hooks/useSetStateAndCall'; -import { getNumber } from '../../../../../utils/string'; -import { - Capacity, - CapacityMetadata, - CapacitySpec, -} from '../../../../../types/Capacity'; -import { dumpYaml, loadYaml } from '../../../../../utils/yaml'; -import { EditorAccordion, ResourceMetadataAccordion } from '../Controls'; -import { useEditorStyles } from '../styles'; - -type OnUpdatedYamlFn = (yaml: string) => void; - -type ResourceEditorProps = { - yaml: string; - onUpdatedYaml: OnUpdatedYamlFn; -}; - -type State = { - metadata: CapacityMetadata; - spec: CapacitySpec; -}; - -export const CapacityEditor = ({ - yaml, - onUpdatedYaml, -}: ResourceEditorProps) => { - const classes = useEditorStyles(); - const resourceYaml = loadYaml(yaml) as Capacity; - - const createResourceState = (): State => ({ - metadata: resourceYaml.metadata, - spec: resourceYaml.spec, - }); - - const [state, setState] = useState(createResourceState()); - const [expanded, setExpanded] = useState(); - - const setStateAndCall = useSetStateAndCall([state, setState], newState => { - onUpdatedYaml(dumpYaml({ ...resourceYaml, ...newState })); - }); - - return ( -
- setStateAndCall(s => ({ ...s, metadata }))} - /> - - - {/* TODO Consider adding regex-based validation of both throughput values. */} - { - setStateAndCall(s => ({ - ...s, - spec: { ...s.spec, maxUplinkThroughput: e.target.value }, - })); - }} - fullWidth - /> - - { - setStateAndCall(s => ({ - ...s, - spec: { ...s.spec, maxDownlinkThroughput: e.target.value }, - })); - }} - fullWidth - /> - - { - setStateAndCall(s => ({ - ...s, - spec: { ...s.spec, maxNFConnections: getNumber(e.target.value) }, - })); - }} - fullWidth - /> - - { - setStateAndCall(s => ({ - ...s, - spec: { ...s.spec, maxSessions: getNumber(e.target.value) }, - })); - }} - fullWidth - /> - - { - setStateAndCall(s => ({ - ...s, - spec: { ...s.spec, maxSubscribers: getNumber(e.target.value) }, - })); - }} - fullWidth - /> - -
- ); -}; diff --git a/plugins/cad/src/components/ResourceEditorDialog/components/FirstClassEditors/CapacityEditor/index.ts b/plugins/cad/src/components/ResourceEditorDialog/components/FirstClassEditors/CapacityEditor/index.ts deleted file mode 100644 index 6be676e5..00000000 --- a/plugins/cad/src/components/ResourceEditorDialog/components/FirstClassEditors/CapacityEditor/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright 2024 The Nephio Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { CapacityEditor } from './CapacityEditor'; diff --git a/plugins/cad/src/components/ResourceEditorDialog/components/FirstClassEditors/NephioTokenEditor/NephioTokenEditor.tsx b/plugins/cad/src/components/ResourceEditorDialog/components/FirstClassEditors/NephioTokenEditor/NephioTokenEditor.tsx deleted file mode 100644 index 92a5b4a4..00000000 --- a/plugins/cad/src/components/ResourceEditorDialog/components/FirstClassEditors/NephioTokenEditor/NephioTokenEditor.tsx +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Copyright 2024 The Nephio Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { SelectItem } from '@backstage/core-components'; -import React, { useState } from 'react'; -import { Select } from '../../../../Controls'; -import { useSetStateAndCall } from '../../../../../hooks/useSetStateAndCall'; -import { dumpYaml, loadYaml } from '../../../../../utils/yaml'; -import { - NephioToken, - NephioTokenMetadata, - NephioTokenSpec, -} from '../../../../../types/Token'; -import { EditorAccordion, ResourceMetadataAccordion } from '../Controls'; -import { useEditorStyles } from '../styles'; - -const DELETION_POLICY_DEFAULT = 'default'; -const DELETION_POLICY_SELECT_ITEMS: SelectItem[] = [ - { value: DELETION_POLICY_DEFAULT, label: 'Default' }, - { value: 'delete', label: 'Delete' }, - { value: 'orphan', label: 'Orphan' }, -]; - -type OnUpdatedYamlFn = (yaml: string) => void; - -type ResourceEditorProps = { - yaml: string; - onUpdatedYaml: OnUpdatedYamlFn; -}; - -type State = { - metadata: NephioTokenMetadata; - spec: NephioTokenSpec; -}; - -const getNephioTokenDescription = (spec: NephioTokenSpec) => - `Deletion policy: ${ - spec.lifecycle?.deletionPolicy ?? DELETION_POLICY_DEFAULT - }`; - -export const NephioTokenEditor = ({ - yaml, - onUpdatedYaml, -}: ResourceEditorProps) => { - const classes = useEditorStyles(); - const resourceYaml = loadYaml(yaml) as NephioToken; - - const createResourceState = (): State => ({ - metadata: resourceYaml.metadata, - spec: resourceYaml.spec, - }); - - const [state, setState] = useState(createResourceState()); - const [expanded, setExpanded] = useState(); - - const setStateAndCall = useSetStateAndCall([state, setState], newState => { - onUpdatedYaml(dumpYaml({ ...resourceYaml, ...newState })); - }); - - return ( -
- setStateAndCall(s => ({ ...s, metadata }))} - /> - - -