-
Notifications
You must be signed in to change notification settings - Fork 13
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
Bai 1456 fix model and datacard tab loading #1796
base: main
Are you sure you want to change the base?
Conversation
{!dataCard || isDataCardLoading || isCurrentUserLoading || isUiConfigLoading ? ( | ||
<Loading /> | ||
) : ( | ||
dataCard && ( |
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.
Nesting additional conditional logic within a ternary is generally considered something to avoid, simply for the fact that it becomes difficult to read.
In this case it's unnecessary to include the dataCard &&
condition due to the fact that if the first check (which includes the condition !dataCard) returns false, then dataCard must be truthy (i.e. not undefined
in this case).
Also, and this is my fault, the loading condition for data cards is simpler than models. That's my mistake for not clarifying in the ticket.
In short, you can do the following:
{!dataCard || isDataCardLoading ? (
<Loading />
) : (
<PageWithTabs
title={dataCard.name}
subheading={`ID: ${dataCard.id}`}
tabs={tabs}
requiredUrlParams={{ dataCardId: dataCard.id }}
titleToCopy={dataCard.name}
subheadingToCopy={dataCard.id}
/>
)}
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.
Yeah, makes sense as the and operator is doing the same thing as my ternary operator so its redundant.
frontend/pages/model/[modelId].tsx
Outdated
{!model || isModelLoading || isCurrentUserLoading || isUiConfigLoading ? ( | ||
<Loading /> | ||
) : ( | ||
model && ( |
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.
Same here, we don't need this second condition to check the model exists. If it fails the first check then we know the model exists.
{!model || isModelLoading || isCurrentUserLoading || isUiConfigLoading ? (
<Loading />
) : (
<PageWithTabs
title={model.name}
subheading={`ID: ${model.id}`}
additionalInfo={model.description}
tabs={tabs}
displayActionButton={model.card !== undefined}
actionButtonTitle='Request access'
actionButtonOnClick={requestAccess}
requiredUrlParams={{ modelId: model.id }}
titleToCopy={model.name}
subheadingToCopy={model.id}
sourceModelId={model.settings.mirror?.sourceModelId}
/>
)}
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.
Fixed
@@ -18,6 +20,8 @@ export default function DataCard() { | |||
isModelLoading: isDataCardLoading, | |||
isModelError: isDataCardError, | |||
} = useGetModel(dataCardId, EntryKind.DATA_CARD) | |||
const { isCurrentUserLoading } = useGetCurrentUser() |
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.
These two hooks aren't needed for data cards. Apologies for the ticket being unclear.
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.
Fixed
No description provided.