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
271 additions
and
136 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
113 changes: 113 additions & 0 deletions
113
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,113 @@ | ||
import React from 'react'; | ||
import { Alert, AlertActionCloseButton, StackItem } from '@patternfly/react-core'; | ||
|
||
type RegisterModelErrorProp = { | ||
submitLabel: string; | ||
submitError: Error; | ||
errorName?: string; | ||
versionName?: string; | ||
modelName?: string; | ||
}; | ||
|
||
const RegisterModelErrors: React.FC<RegisterModelErrorProp> = ({ | ||
submitLabel, | ||
submitError, | ||
errorName, | ||
versionName, | ||
modelName, | ||
}) => { | ||
const [showAlert, setShowAlert] = React.useState<boolean>(true); | ||
|
||
if (submitLabel === 'Register model' && errorName === 'modelVersion') { | ||
return ( | ||
<> | ||
{showAlert && ( | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="success" | ||
title={`${modelName} model registered`} | ||
actionClose={<AlertActionCloseButton onClose={() => setShowAlert(false)} />} | ||
/> | ||
</StackItem> | ||
)} | ||
<StackItem> | ||
<Alert isInline variant="danger" title={`Failed to register ${versionName} version`}> | ||
{submitError.message} | ||
</Alert> | ||
</StackItem> | ||
</> | ||
); | ||
} | ||
|
||
if (submitLabel === 'Register new version' && errorName === 'modelVersion') { | ||
return ( | ||
<StackItem> | ||
<Alert isInline variant="danger" title={`Failed to register ${versionName} version`}> | ||
{submitError.message} | ||
</Alert> | ||
</StackItem> | ||
); | ||
} | ||
|
||
if (submitLabel === 'Register model' && errorName === 'modelArtifact') { | ||
return ( | ||
<> | ||
{showAlert && ( | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="success" | ||
title={`${modelName} model and ${versionName} version registered`} | ||
actionClose={<AlertActionCloseButton onClose={() => setShowAlert(false)} />} | ||
/> | ||
</StackItem> | ||
)} | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="danger" | ||
title={`Failed to create artifact for ${versionName} version`} | ||
> | ||
{submitError.message} | ||
</Alert> | ||
</StackItem> | ||
</> | ||
); | ||
} | ||
|
||
if (submitLabel === 'Register new version' && errorName === 'modelArtifact') { | ||
return ( | ||
<> | ||
{showAlert && ( | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="success" | ||
title={`${versionName} version registered`} | ||
actionClose={<AlertActionCloseButton onClose={() => setShowAlert(false)} />} | ||
/> | ||
</StackItem> | ||
)} | ||
<StackItem> | ||
<Alert | ||
isInline | ||
variant="danger" | ||
title={`Failed to create artifact for ${versionName} version`} | ||
> | ||
{submitError.message} | ||
</Alert> | ||
</StackItem> | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<StackItem> | ||
<Alert isInline variant="danger" title={`Failed to register ${modelName} model`}> | ||
{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
36 changes: 15 additions & 21 deletions
36
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.