Skip to content

Commit

Permalink
Moved module out of definition file
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Sep 30, 2022
1 parent 007caf7 commit 752e521
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/metadata/copy/CopySource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {

Expand Down
31 changes: 0 additions & 31 deletions ui/src/app/metadata/domain/source/definition/SourceDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {

Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SourceBase } from './SourceDefinition';
jest.mock('../../metadata/hoc/MetadataSchema');

jest.mock('../../../../App.constant', () => ({
get API_BASE_PATH() {
Expand Down
32 changes: 32 additions & 0 deletions ui/src/app/metadata/domain/source/definition/sections.js
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 0 additions & 2 deletions ui/src/app/metadata/hooks/schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jest.mock('../../App.constant', () => ({
}
}));

jest.mock('../../metadata/hoc/MetadataSchema');

describe('useUiSchema', () => {
let realUseMemo;
let useMemoMock;
Expand Down

0 comments on commit 752e521

Please sign in to comment.