Skip to content

Commit

Permalink
Merge branch 'feature/shibui-1788' of bitbucket.org:unicon/shib-idp-u…
Browse files Browse the repository at this point in the history
…i into feature/shibui-1788
  • Loading branch information
chasegawa committed Jun 30, 2021
2 parents 111e55b + 01c8b22 commit 7c249c3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 37 deletions.
55 changes: 23 additions & 32 deletions ui/src/app/metadata/domain/attribute/CustomAttributeDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const CustomAttributeDefinition = {
return data;
}
const { attributeType } = data;
let { defaultValueBoolean, defaultValueString, ...parsed } = data;
let { defaultValueBoolean, ...parsed } = data;
if (attributeType === 'SELECTION_LIST') {
parsed = {
...parsed,
Expand All @@ -77,13 +77,6 @@ export const CustomAttributeDefinition = {
}
}

if (attributeType === 'STRING') {
parsed = {
...parsed,
defaultValue: defaultValueString
}
}

return parsed;
},

Expand All @@ -94,30 +87,28 @@ export const CustomAttributeDefinition = {
let { defaultValue, ...formatted } = changes;
const { attributeType } = changes;

if (attributeType === 'SELECTION_LIST') {
formatted = {
...formatted,
customAttrListDefinitions: formatted.customAttrListDefinitions.map(d => ({
value: d,
default: d === defaultValue
}))
}
}

if (attributeType === 'BOOLEAN') {
formatted = {
...formatted,
defaultValueBoolean: formatted.defaultValue === 'true' ? true : false,
invert: formatted.invert === 'true' ? true : false
// defaultValueBoolean: defaultValue === 'true' ? true : false
}
}

if (attributeType === 'STRING') {
formatted = {
...formatted,
defaultValueString: defaultValue
}
switch (attributeType) {
case 'SELECTION_LIST':
formatted = {
...formatted,
customAttrListDefinitions: formatted.customAttrListDefinitions.map(d => ({
value: d,
default: d === defaultValue
}))
}
break;
case 'BOOLEAN':
formatted = {
...formatted,
defaultValueBoolean: defaultValue === 'true' ? true : false,
invert: formatted.invert === 'true' ? true : false
}
break;
default:
formatted = {
...formatted,
defaultValue
}
}

return formatted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ describe('formatter', () => {

expect(CustomAttributeDefinition.formatter({
attributeType: 'BOOLEAN',
defaultValue: 'true'
defaultValue: 'true',
invert: 'true'
})).toEqual({
attributeType: 'BOOLEAN',
defaultValueBoolean: true
defaultValueBoolean: true,
invert: true
});

expect(CustomAttributeDefinition.formatter({
attributeType: 'STRING',
defaultValue: 'true'
})).toEqual({
attributeType: 'STRING',
defaultValueString: 'true'
defaultValue: 'true'
});
});
});
Expand Down Expand Up @@ -72,7 +74,7 @@ describe('parser', () => {

expect(CustomAttributeDefinition.parser({
attributeType: 'STRING',
defaultValueString: 'true'
defaultValue: 'true'
})).toEqual({
attributeType: 'STRING',
defaultValue: 'true'
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/metadata/domain/transform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const errors = [
it('should transform error messages', () => {
expect(transformErrors(errors)).toEqual([
{ name: 'pattern', property: '/email', message: 'message.valid-email' },
{ name: 'pattern', property: 'foo', message: 'message.valid-duration' },
{ name: 'pattern', property: 'foo', message: 'message.duration' },
{ name: 'type', message: 'bar' },
{ name: 'type', message: 'message.required' }
]);
Expand Down

0 comments on commit 7c249c3

Please sign in to comment.