-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-studio-component-for-search
- Loading branch information
Showing
23 changed files
with
228 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
frontend/app-development/features/appContentLibrary/utils/mapToCodeListsUsage.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { CodeListIdSource } from '@studio/content-library'; | ||
import { mapToCodeListsUsage } from './mapToCodeListsUsage'; | ||
import type { OptionListsReferences } from 'app-shared/types/api/OptionsLists'; | ||
|
||
const optionListId: string = 'optionListId'; | ||
const optionListIdSources: CodeListIdSource[] = [ | ||
{ | ||
layoutSetId: 'layoutSetId', | ||
layoutName: 'layoutName', | ||
componentIds: ['componentId1', 'componentId2'], | ||
}, | ||
]; | ||
const optionListsUsages: OptionListsReferences = [ | ||
{ | ||
optionListId, | ||
optionListIdSources, | ||
}, | ||
]; | ||
|
||
describe('mapToCodeListsUsage', () => { | ||
it('maps optionListsUsage to codeListUsage', () => { | ||
const codeListUsage = mapToCodeListsUsage({ optionListsUsages }); | ||
expect(codeListUsage).toEqual([ | ||
{ | ||
codeListId: optionListId, | ||
codeListIdSources: optionListIdSources, | ||
}, | ||
]); | ||
}); | ||
|
||
it('maps undefined optionListsUsage to empty array', () => { | ||
const codeListUsage = mapToCodeListsUsage({ optionListsUsages: undefined }); | ||
expect(codeListUsage).toEqual([]); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
frontend/app-development/features/appContentLibrary/utils/mapToCodeListsUsage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { OptionListsReferences } from 'app-shared/types/api/OptionsLists'; | ||
import type { CodeListReference } from '@studio/content-library'; | ||
|
||
type MapToCodeListsUsageProps = { | ||
optionListsUsages: OptionListsReferences; | ||
}; | ||
|
||
export const mapToCodeListsUsage = ({ | ||
optionListsUsages, | ||
}: MapToCodeListsUsageProps): CodeListReference[] => { | ||
const codeListsUsages: CodeListReference[] = []; | ||
if (!optionListsUsages) return codeListsUsages; | ||
optionListsUsages.map((optionListsUsage) => | ||
codeListsUsages.push({ | ||
codeListId: optionListsUsage.optionListId, | ||
codeListIdSources: optionListsUsage.optionListIdSources, | ||
}), | ||
); | ||
return codeListsUsages; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...nd/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { CodeListPage } from './CodeListPage'; | ||
export type { CodeListWithMetadata, CodeListData, CodeListPageProps } from './CodeListPage'; | ||
export type { CodeListIdSource, CodeListReference } from './types/CodeListReference'; |
10 changes: 10 additions & 0 deletions
10
...tent-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/types/CodeListReference.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export type CodeListReference = { | ||
codeListId: string; | ||
codeListIdSources: CodeListIdSource[]; | ||
}; | ||
|
||
export type CodeListIdSource = { | ||
layoutSetId: string; | ||
layoutName: string; | ||
componentIds: string[]; | ||
}; |
7 changes: 6 additions & 1 deletion
7
frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
export type { CodeListWithMetadata, CodeListData } from './CodeListPage'; | ||
export type { | ||
CodeListWithMetadata, | ||
CodeListData, | ||
CodeListIdSource, | ||
CodeListReference, | ||
} from './CodeListPage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
export { ResourceContentLibraryImpl } from './config/ContentResourceLibraryImpl'; | ||
export type { CodeListWithMetadata, CodeListData } from './ContentLibrary/LibraryBody/pages'; | ||
export type { | ||
CodeListWithMetadata, | ||
CodeListData, | ||
CodeListIdSource, | ||
CodeListReference, | ||
} from './ContentLibrary/LibraryBody/pages'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.