-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
- Loading branch information
There are no files selected for viewing
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); | ||
Check warning on line 20 in frontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx Codecov / codecov/patchfrontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx#L14-L20
|
||
|
||
if (submitLabel === SubmitLabel.REGISTER_MODEL && errorName === ErrorName.MODEL_VERSION) { | ||
return ( | ||
Check warning on line 23 in frontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx Codecov / codecov/patchfrontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx#L22-L23
|
||
<> | ||
{showAlert && ( | ||
<StackItem> | ||
Check warning on line 26 in frontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx Codecov / codecov/patchfrontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx#L25-L26
|
||
<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 ( | ||
Check warning on line 45 in frontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx Codecov / codecov/patchfrontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx#L44-L45
|
||
<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 ( | ||
Check warning on line 55 in frontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx Codecov / codecov/patchfrontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx#L54-L55
|
||
<> | ||
{showAlert && ( | ||
<StackItem> | ||
Check warning on line 58 in frontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx Codecov / codecov/patchfrontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx#L57-L58
|
||
<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 ( | ||
Check warning on line 81 in frontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx Codecov / codecov/patchfrontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx#L80-L81
|
||
<> | ||
{showAlert && ( | ||
<StackItem> | ||
Check warning on line 84 in frontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx Codecov / codecov/patchfrontend/src/pages/modelRegistry/screens/RegisterModel/RegisterModelErrors.tsx#L83-L84
|
||
<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; |
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', | ||
} |
This file was deleted.