-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 14508/get code lists for org #14653
feat: 14508/get code lists for org #14653
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## org-library-mvp #14653 +/- ##
================================================
Coverage 95.74% 95.74%
================================================
Files 1919 1919
Lines 24954 24978 +24
Branches 2838 2839 +1
================================================
+ Hits 23891 23914 +23
- Misses 802 803 +1
Partials 261 261 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
const { data: codeListsResponseList, status: codeListDataListStatus } = | ||
useOrgCodeListsQuery(selectedContext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For API data transfer objects, we are using the type CodeListsResponse
, so maybe we should name the variables to match that type?
const { data: codeListsResponseList, status: codeListDataListStatus } = | |
useOrgCodeListsQuery(selectedContext); | |
const { data: codeListsResponse, status: codeListResponseStatus } = | |
useOrgCodeListsQuery(selectedContext); |
type OrgContentLibraryWithContextAndDataProps = { | ||
codeListsData: CodeListData[]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming the variable codeListData
might make people assume that it has the type CodeListData
and not CodeListData[]
. I suggest naming it CodeListDataList
to avoid possible future confusion.
type OrgContentLibraryWithContextAndDataProps = { | |
codeListsData: CodeListData[]; | |
}; | |
type OrgContentLibraryWithContextAndDataProps = { | |
codeListsDataList: CodeListData[]; | |
}; |
@@ -181,5 +181,5 @@ export const getProcessTaskType = (org: string, app: string, taskId: string) => | |||
export const fetchBelongsToGiteaOrg = () => get(belongsToOrg()); | |||
|
|||
// Organisation library | |||
export const getCodeListsForOrg = async (org: string): Promise<CodeListsResponse> => Promise.resolve(codeListsResponse); // Todo: Replace with real API call when endpoint is ready. https://github.com/Altinn/altinn-studio/issues/14505 | |||
export const getCodeListsForOrg = (org: string) => get<CodeListsResponse>(orgCodeListsPath(org)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great that you saw this needed fixing 😄
Hi o/ After testing locally and getting both the backend and frontend to work, I've come up with possible changes. I'll make a PR with the needed backend changes, and give a few solutions for frontend changes below. The changes needed to backend can be found here: #14667 Possible solutions for our frontendI suggest we implement solution 2, as it allows the component to handle Solution 1Set a default value for the prop Before codeListsUsages, After codeListsUsages = [], The example refers to line 39 Solution 2Update export const getCodeListSourcesById = (
codeListsUsages: CodeListReference[],
codeListTitle: string,
): CodeListIdSource[] => {
const codeListUsages: CodeListReference | undefined = codeListsUsages.find(
(codeListUsage) => codeListUsage.codeListId === codeListTitle,
);
return codeListUsages?.codeListIdSources ?? [];
}; After: export const getCodeListSourcesById = (
codeListsUsages: CodeListReference[] | undefined,
codeListTitle: string,
): CodeListIdSource[] => {
const codeListUsages: CodeListReference | undefined = codeListsUsages?.find(
(codeListUsage) => codeListUsage.codeListId === codeListTitle,
);
return codeListUsages?.codeListIdSources ?? [];
}; |
I think it's a good idea to make |
It's a required change for this pull request to work. The frontend breaks without handling this nullable value in some way. Edit: |
Sure, we can make it nullable now. I meant that we should wait with the other considerations I mentioned. |
Is the prop not already nullable? This change handles the null/undefined prop. I'm ok with it being done in a different PR |
Changes mentioned in my comments have been moved out into a different PR #14670 |
Great comments! 😄 |
Description
Related Issue(s)
Verification