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
7 changed files
with
288 additions
and
140 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
114 changes: 114 additions & 0 deletions
114
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,114 @@ | ||
import React from 'react'; | ||
import { Alert, AlertActionCloseButton, StackItem } from '@patternfly/react-core'; | ||
import { ErrorName, SubmitLabel } from './const'; | ||
|
||
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 === SubmitLabel.REGISTER_MODEL && errorName === ErrorName.MODEL_VERSION) { | ||
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 === SubmitLabel.REGISTER_VERSION && errorName === ErrorName.MODEL_VERSION) { | ||
return ( | ||
<StackItem> | ||
<Alert isInline variant="danger" title={`Failed to register ${versionName} version`}> | ||
{submitError.message} | ||
</Alert> | ||
</StackItem> | ||
); | ||
} | ||
|
||
if (submitLabel === SubmitLabel.REGISTER_MODEL && errorName === ErrorName.MODEL_ARTIFACT) { | ||
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 === SubmitLabel.REGISTER_VERSION && errorName === ErrorName.MODEL_ARTIFACT) { | ||
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
11 changes: 11 additions & 0 deletions
11
frontend/src/pages/modelRegistry/screens/RegisterModel/const.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,12 @@ | ||
export const MR_CHARACTER_LIMIT = 128; | ||
|
||
export enum SubmitLabel { | ||
REGISTER_MODEL = 'Register model', | ||
REGISTER_VERSION = 'Register new version', | ||
} | ||
|
||
export enum ErrorName { | ||
REGISTERED_MODEL = 'registeredModel', | ||
MODEL_VERSION = 'modelVersion', | ||
MODEL_ARTIFACT = 'modelArtifact', | ||
} |
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.