From 752e521a42144dc2ce612f302c8ef8e47223413d Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Fri, 30 Sep 2022 10:22:39 -0700 Subject: [PATCH] Moved module out of definition file --- ui/src/app/metadata/copy/CopySource.js | 2 +- .../source/definition/SourceDefinition.js | 31 ------------------ .../definition/SourceDefinition.test.js | 1 - .../domain/source/definition/sections.js | 32 +++++++++++++++++++ ui/src/app/metadata/hooks/schema.test.js | 2 -- 5 files changed, 33 insertions(+), 35 deletions(-) create mode 100644 ui/src/app/metadata/domain/source/definition/sections.js diff --git a/ui/src/app/metadata/copy/CopySource.js b/ui/src/app/metadata/copy/CopySource.js index 60e866d7e..2a7a6b183 100644 --- a/ui/src/app/metadata/copy/CopySource.js +++ b/ui/src/app/metadata/copy/CopySource.js @@ -9,7 +9,7 @@ import { Translate } from '../../i18n/components/translate'; import { EntityTypeahead } from './EntityTypeahead'; import kebabCase from 'lodash/kebabCase'; import { useMetadataSources } from '../hooks/api'; -import { useMetadataSourceSections } from '../domain/source/definition/SourceDefinition'; +import { useMetadataSourceSections } from '../domain/source/definition/sections'; export function CopySource({ copy, onNext }) { diff --git a/ui/src/app/metadata/domain/source/definition/SourceDefinition.js b/ui/src/app/metadata/domain/source/definition/SourceDefinition.js index 69bdc156b..542dd83a4 100644 --- a/ui/src/app/metadata/domain/source/definition/SourceDefinition.js +++ b/ui/src/app/metadata/domain/source/definition/SourceDefinition.js @@ -5,7 +5,6 @@ import defaultsDeep from 'lodash/defaultsDeep'; import {removeNull} from '../../../../core/utility/remove_null'; import { detailedDiff } from 'deep-object-diff'; import isNil from 'lodash/isNil'; -import { useMetadataSchemaContext } from '../../../hoc/MetadataSchema'; export const SourceBase = { @@ -521,33 +520,3 @@ export const SourceWizard = { ] } -export const sections = [ - { i18nKey: 'organizationInformation', property: 'organization' }, - { i18nKey: 'contacts', property: 'contacts' }, - { i18nKey: 'uiMduiInfo', property: 'mdui' }, - { i18nKey: 'spSsoDescriptorInfo', property: 'serviceProviderSsoDescriptor' }, - { i18nKey: 'logoutEndpoints', property: 'logoutEndpoints' }, - { i18nKey: 'securityDescriptorInfo', property: 'securityInfo' }, - { i18nKey: 'assertionConsumerServices', property: 'assertionConsumerServices' }, - { i18nKey: 'relyingPartyOverrides', property: 'relyingPartyOverrides' }, - { i18nKey: 'attributeRelease', property: 'attributeRelease' } -]; - -export function useMetadataSourceSections() { - const schema = useMetadataSchemaContext(); - - const keys = Object.keys(schema.properties); - const properties = sections.map((s) => s.property); - - const reduced = keys.reduce( - (collection, key) => { - if (properties.indexOf(key) > -1) { - collection.push(sections.find(s => s.property === key)); - } - return collection; - }, - [] - ); - - return reduced; -} \ No newline at end of file diff --git a/ui/src/app/metadata/domain/source/definition/SourceDefinition.test.js b/ui/src/app/metadata/domain/source/definition/SourceDefinition.test.js index 51a3d3217..92801c052 100644 --- a/ui/src/app/metadata/domain/source/definition/SourceDefinition.test.js +++ b/ui/src/app/metadata/domain/source/definition/SourceDefinition.test.js @@ -1,5 +1,4 @@ import { SourceBase } from './SourceDefinition'; -jest.mock('../../metadata/hoc/MetadataSchema'); jest.mock('../../../../App.constant', () => ({ get API_BASE_PATH() { diff --git a/ui/src/app/metadata/domain/source/definition/sections.js b/ui/src/app/metadata/domain/source/definition/sections.js new file mode 100644 index 000000000..3746ccd61 --- /dev/null +++ b/ui/src/app/metadata/domain/source/definition/sections.js @@ -0,0 +1,32 @@ +import { useMetadataSchemaContext } from '../../../hoc/MetadataSchema'; + +export const sections = [ + { i18nKey: 'organizationInformation', property: 'organization' }, + { i18nKey: 'contacts', property: 'contacts' }, + { i18nKey: 'uiMduiInfo', property: 'mdui' }, + { i18nKey: 'spSsoDescriptorInfo', property: 'serviceProviderSsoDescriptor' }, + { i18nKey: 'logoutEndpoints', property: 'logoutEndpoints' }, + { i18nKey: 'securityDescriptorInfo', property: 'securityInfo' }, + { i18nKey: 'assertionConsumerServices', property: 'assertionConsumerServices' }, + { i18nKey: 'relyingPartyOverrides', property: 'relyingPartyOverrides' }, + { i18nKey: 'attributeRelease', property: 'attributeRelease' } +]; + +export function useMetadataSourceSections() { + const schema = useMetadataSchemaContext(); + + const keys = Object.keys(schema.properties); + const properties = sections.map((s) => s.property); + + const reduced = keys.reduce( + (collection, key) => { + if (properties.indexOf(key) > -1) { + collection.push(sections.find(s => s.property === key)); + } + return collection; + }, + [] + ); + + return reduced; +} \ No newline at end of file diff --git a/ui/src/app/metadata/hooks/schema.test.js b/ui/src/app/metadata/hooks/schema.test.js index cd881e6eb..b1d68e55a 100644 --- a/ui/src/app/metadata/hooks/schema.test.js +++ b/ui/src/app/metadata/hooks/schema.test.js @@ -15,8 +15,6 @@ jest.mock('../../App.constant', () => ({ } })); -jest.mock('../../metadata/hoc/MetadataSchema'); - describe('useUiSchema', () => { let realUseMemo; let useMemoMock;