Skip to content

Commit

Permalink
SHIBUI-944 Base copy off of JSON Schema
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jul 13, 2022
1 parent 5d5dc4d commit b6ba7ef
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
17 changes: 5 additions & 12 deletions ui/src/app/metadata/copy/CopySource.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,9 @@ 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';


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 CopySource({ copy, onNext }) {

Expand Down Expand Up @@ -64,6 +55,8 @@ export function CopySource({ copy, onNext }) {

const sourceIds = data.map(p => p.entityId);

const sections = useMetadataSourceSections();

return (
<>
<div className="row">
Expand Down Expand Up @@ -162,7 +155,7 @@ export function CopySource({ copy, onNext }) {
<td><span className="mb-0" id={`property-checkbox-${i}`}><Translate value={`label.${kebabCase(item.i18nKey)}`} /></span></td>
<td>
<Form.Check
custom
custom={'true'}
type={'checkbox'}
id={`property-checkbox-${i}-check`}
onChange={({ target: { checked } }) => onSelect(item, checked)}
Expand Down
32 changes: 32 additions & 0 deletions ui/src/app/metadata/domain/source/definition/SourceDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import API_BASE_PATH from '../../../../App.constant';
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 = {
label: 'Metadata Source',
Expand Down Expand Up @@ -534,4 +535,35 @@ export const SourceWizard = {
fields: []
}
]
}

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;
}

0 comments on commit b6ba7ef

Please sign in to comment.