forked from opendatahub-io/odh-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error message for model registration
- Loading branch information
Showing
6 changed files
with
270 additions
and
135 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
118 changes: 118 additions & 0 deletions
118
frontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx
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,118 @@ | ||
import { Alert, AlertActionCloseButton, StackItem } from '@patternfly/react-core'; | ||
import React from 'react'; | ||
import { RegisterModelFormData } from './useRegisterModelData'; | ||
|
||
type RegisterModelErrorProp<D extends RegisterModelFormData> = { | ||
submitLabel: string; | ||
submitError: Error; | ||
setSubmitError: (e?: Error) => void; | ||
formData: D; | ||
errorName?: string; | ||
}; | ||
|
||
const RegisterModelErrors = <D extends RegisterModelFormData>({ | ||
submitLabel, | ||
submitError, | ||
setSubmitError, | ||
errorName, | ||
formData, | ||
}: RegisterModelErrorProp<D>): React.ReactElement => { | ||
if (submitLabel === 'Register model' && errorName === 'modelVersion') { | ||
return ( | ||
<> | ||
<StackItem> | ||
<Alert isInline variant="success" title={`${formData.modelName} model registered`} /> | ||
</StackItem> | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="danger" | ||
title={`Failed to register ${formData.versionName} version`} | ||
actionClose={<AlertActionCloseButton onClose={() => setSubmitError(undefined)} />} | ||
> | ||
{submitError.message} | ||
</Alert> | ||
</StackItem> | ||
</> | ||
); | ||
} | ||
|
||
if (submitLabel === 'Register new version' && errorName === 'modelVersion') { | ||
return ( | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="danger" | ||
title={`Failed to register ${formData.versionName} version`} | ||
data-testid="versionFailureAlert" | ||
actionClose={<AlertActionCloseButton onClose={() => setSubmitError(undefined)} />} | ||
> | ||
{submitError.message} | ||
</Alert> | ||
</StackItem> | ||
); | ||
} | ||
|
||
if (submitLabel === 'Register model' && errorName === 'modelArtifact') { | ||
return ( | ||
<> | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="success" | ||
title={`${formData.modelName} model and ${formData.versionName} version registered`} | ||
/> | ||
</StackItem> | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="danger" | ||
title={`Failed to create artifact for ${formData.versionName} version`} | ||
actionClose={<AlertActionCloseButton onClose={() => setSubmitError(undefined)} />} | ||
> | ||
{submitError.message} | ||
</Alert> | ||
</StackItem> | ||
</> | ||
); | ||
} | ||
|
||
if (submitLabel === 'Register new version' && errorName === 'modelArtifact') { | ||
return ( | ||
<> | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="success" | ||
title={`${formData.versionName} version registered | ||
`} | ||
/> | ||
</StackItem> | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="danger" | ||
title={`Failed to create artifact for ${formData.versionName} version`} | ||
actionClose={<AlertActionCloseButton onClose={() => setSubmitError(undefined)} />} | ||
> | ||
{submitError.message} | ||
</Alert> | ||
</StackItem> | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="danger" | ||
title={`Failed to register ${formData.modelName} model`} | ||
actionClose={<AlertActionCloseButton onClose={() => setSubmitError(undefined)} />} | ||
> | ||
{submitError.message} | ||
</Alert> | ||
</StackItem> | ||
); | ||
}; | ||
export default RegisterModelErrors; |
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
39 changes: 17 additions & 22 deletions
39
frontend/src/pages/modelRegistry/screens/RegisterModel/RegistrationFormFooter.tsx
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
41 changes: 0 additions & 41 deletions
41
frontend/src/pages/modelRegistry/screens/RegisterModel/useRegistrationCommonState.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.