-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Model Registry Settings view (#423)
Signed-off-by: lucferbux <[email protected]>
- Loading branch information
Showing
10 changed files
with
251 additions
and
8 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
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
116 changes: 116 additions & 0 deletions
116
clients/ui/frontend/src/__tests__/cypress/cypress/pages/modelRegistrySettings.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 |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { appChrome } from './appChrome'; | ||
|
||
export enum FormFieldSelector { | ||
NAME = '#mr-name', | ||
RESOURCENAME = '#resource-mr-name', | ||
HOST = '#mr-host', | ||
PORT = '#mr-port', | ||
USERNAME = '#mr-username', | ||
PASSWORD = '#mr-password', | ||
DATABASE = '#mr-database', | ||
} | ||
|
||
export enum FormErrorTestId { | ||
HOST = 'mr-host-error', | ||
PORT = 'mr-port-error', | ||
USERNAME = 'mr-username-error', | ||
PASSWORD = 'mr-password-error', | ||
DATABASE = 'mr-database-error', | ||
} | ||
|
||
export enum DatabaseDetailsTestId { | ||
HOST = 'mr-db-host', | ||
PORT = 'mr-db-port', | ||
USERNAME = 'mr-db-username', | ||
PASSWORD = 'mr-db-password', | ||
DATABASE = 'mr-db-database', | ||
} | ||
|
||
class ModelRegistrySettings { | ||
visit(wait = true) { | ||
cy.visit('/modelRegistrySettings'); | ||
if (wait) { | ||
this.wait(); | ||
} | ||
} | ||
|
||
navigate() { | ||
this.findNavItem().click(); | ||
this.wait(); | ||
} | ||
|
||
private wait() { | ||
this.findHeading(); | ||
cy.testA11y(); | ||
} | ||
|
||
private findHeading() { | ||
cy.findByTestId('app-page-title').should('exist'); | ||
cy.findByTestId('app-page-title').contains('Model Registry Settings'); | ||
} | ||
|
||
findNavItem() { | ||
return appChrome.findNavItem('Model registry settings', 'Settings'); | ||
} | ||
|
||
findEmptyState() { | ||
return cy.findByTestId('mr-settings-empty-state'); | ||
} | ||
|
||
// findCreateButton() { | ||
// return cy.findByText('Create model registry'); | ||
// } | ||
|
||
findFormField(selector: FormFieldSelector) { | ||
return cy.get(selector); | ||
} | ||
|
||
clearFormFields() { | ||
Object.values(FormFieldSelector).forEach((selector) => { | ||
this.findFormField(selector).clear(); | ||
this.findFormField(selector).blur(); | ||
}); | ||
} | ||
|
||
findFormError(testId: FormErrorTestId) { | ||
return cy.findByTestId(testId); | ||
} | ||
|
||
shouldHaveAllErrors() { | ||
Object.values(FormErrorTestId).forEach((testId) => this.findFormError(testId).should('exist')); | ||
} | ||
|
||
shouldHaveNoErrors() { | ||
Object.values(FormErrorTestId).forEach((testId) => | ||
this.findFormError(testId).should('not.exist'), | ||
); | ||
} | ||
|
||
findSubmitButton() { | ||
return cy.findByTestId('modal-submit-button'); | ||
} | ||
|
||
findTable() { | ||
return cy.findByTestId('model-registries-table'); | ||
} | ||
|
||
findModelRegistryRow(registryName: string) { | ||
return this.findTable().findByText(registryName).closest('tr'); | ||
} | ||
|
||
findDatabaseDetail(testId: DatabaseDetailsTestId) { | ||
return cy.findByTestId(testId); | ||
} | ||
|
||
findDatabasePasswordHiddenButton() { | ||
return this.findDatabaseDetail(DatabaseDetailsTestId.PASSWORD).findByTestId( | ||
'password-hidden-button', | ||
); | ||
} | ||
|
||
findConfirmDeleteNameInput() { | ||
return cy.findByTestId('confirm-delete-input'); | ||
} | ||
} | ||
|
||
export const modelRegistrySettings = new ModelRegistrySettings(); |
File renamed without changes.
49 changes: 49 additions & 0 deletions
49
.../__tests__/cypress/cypress/tests/mocked/modelRegistrySettings/modelRegistrySettings.cy.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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { mockModelRegistry } from '~/__mocks__/mockModelRegistry'; | ||
import type { ModelRegistry } from '~/app/types'; | ||
import { mockBFFResponse } from '~/__mocks__/mockBFFResponse'; | ||
import { modelRegistrySettings } from '~/__tests__/cypress/cypress/pages/modelRegistrySettings'; | ||
|
||
type HandlersProps = { | ||
modelRegistries?: ModelRegistry[]; | ||
}; | ||
|
||
const MODEL_REGISTRY_API_VERSION = 'v1'; | ||
|
||
const initIntercepts = ({ | ||
modelRegistries = [ | ||
mockModelRegistry({ | ||
name: 'modelregistry-sample', | ||
description: 'New model registry', | ||
displayName: 'Model Registry Sample', | ||
}), | ||
mockModelRegistry({ | ||
name: 'modelregistry-sample-2', | ||
description: 'New model registry 2', | ||
displayName: 'Model Registry Sample 2', | ||
}), | ||
], | ||
}: HandlersProps) => { | ||
cy.interceptApi( | ||
`GET /api/:apiVersion/model_registry`, | ||
{ | ||
path: { apiVersion: MODEL_REGISTRY_API_VERSION }, | ||
}, | ||
mockBFFResponse(modelRegistries), | ||
); | ||
}; | ||
|
||
it('Shows empty state when there are no registries', () => { | ||
initIntercepts({ modelRegistries: [] }); | ||
modelRegistrySettings.visit(true); | ||
modelRegistrySettings.findEmptyState().should('exist'); | ||
}); | ||
|
||
describe('ModelRegistriesTable', () => { | ||
it('Shows table when there are registries', () => { | ||
initIntercepts({}); | ||
modelRegistrySettings.visit(true); | ||
modelRegistrySettings.findEmptyState().should('not.exist'); | ||
modelRegistrySettings.findTable().should('exist'); | ||
modelRegistrySettings.findModelRegistryRow('Model Registry Sample').should('exist'); | ||
}); | ||
}); |
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
22 changes: 22 additions & 0 deletions
22
clients/ui/frontend/src/app/pages/settings/ModelRegistriesTable.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,22 @@ | ||
import React from 'react'; | ||
import { ModelRegistry } from '~/app/types'; | ||
import { Table } from '~/app/components/table'; | ||
import { modelRegistryColumns } from './columns'; | ||
import ModelRegistriesTableRow from './ModelRegistriesTableRow'; | ||
|
||
type ModelRegistriesTableProps = { | ||
modelRegistries: ModelRegistry[]; | ||
}; | ||
|
||
const ModelRegistriesTable: React.FC<ModelRegistriesTableProps> = ({ modelRegistries }) => ( | ||
// TODO: Add toolbar once we manage permissions | ||
<Table | ||
data-testid="model-registries-table" | ||
data={modelRegistries} | ||
columns={modelRegistryColumns} | ||
rowRenderer={(mr) => <ModelRegistriesTableRow key={mr.name} modelRegistry={mr} />} | ||
variant="compact" | ||
/> | ||
); | ||
|
||
export default ModelRegistriesTable; |
22 changes: 22 additions & 0 deletions
22
clients/ui/frontend/src/app/pages/settings/ModelRegistriesTableRow.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,22 @@ | ||
import React from 'react'; | ||
import { Td, Tr } from '@patternfly/react-table'; | ||
import { ModelRegistry } from '~/app/types'; | ||
|
||
type ModelRegistriesTableRowProps = { | ||
modelRegistry: ModelRegistry; | ||
}; | ||
|
||
const ModelRegistriesTableRow: React.FC<ModelRegistriesTableRowProps> = ({ modelRegistry: mr }) => ( | ||
<> | ||
<Tr> | ||
<Td dataLabel="Model registry name"> | ||
<strong>{mr.displayName || mr.name}</strong> | ||
{mr.description && <p>{mr.description}</p>} | ||
</Td> | ||
</Tr> | ||
</> | ||
); | ||
|
||
// TODO: Get rest of columns once we manage permissions | ||
|
||
export default ModelRegistriesTableRow; |
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
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,23 @@ | ||
import { SortableData } from '~/app/components/table'; | ||
import { ModelRegistry } from '~/app/types'; | ||
|
||
export const modelRegistryColumns: SortableData<ModelRegistry>[] = [ | ||
{ | ||
field: 'model regisry name', | ||
label: 'Model registry name', | ||
sortable: (a, b) => a.name.localeCompare(b.name), | ||
width: 30, | ||
}, | ||
// TODO: Add once we manage permissions | ||
// { | ||
// field: 'status', | ||
// label: 'Status', | ||
// sortable: false, | ||
// }, | ||
// { | ||
// field: 'manage permissions', | ||
// label: '', | ||
// sortable: false, | ||
// }, | ||
// kebabTableColumn(), | ||
]; |