Skip to content

Commit

Permalink
Update Model registry version selector on the details page title to s…
Browse files Browse the repository at this point in the history
…how only active versions (#3358)
  • Loading branch information
ppadti authored Oct 22, 2024
1 parent 610e4f7 commit 9d7dcab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { verifyRelativeURL } from '~/__tests__/cypress/cypress/utils/url';
import { modelVersionDetails } from '~/__tests__/cypress/cypress/pages/modelRegistry/modelVersionDetails';
import { InferenceServiceModelState } from '~/pages/modelServing/screens/types';
import { modelServingGlobal } from '~/__tests__/cypress/cypress/pages/modelServing';
import { ModelRegistryMetadataType } from '~/concepts/modelRegistry/types';
import { ModelRegistryMetadataType, ModelState } from '~/concepts/modelRegistry/types';

const MODEL_REGISTRY_API_VERSION = 'v1alpha3';
const mockModelVersions = mockModelVersion({
Expand Down Expand Up @@ -171,6 +171,13 @@ const initIntercepts = () => {
id: '2',
name: 'Version 2',
}),
mockModelVersion({
author: 'Author 3',
registeredModelId: '1',
id: '3',
name: 'Version 3',
state: ModelState.ARCHIVED,
}),
],
}),
);
Expand Down Expand Up @@ -333,6 +340,7 @@ describe('Model version details', () => {
it('Switching model versions', () => {
modelVersionDetails.findVersionId().contains('1');
modelVersionDetails.findModelVersionDropdownButton().click();
modelVersionDetails.findModelVersionDropdownItem('Version 3').should('not.exist');
modelVersionDetails.findModelVersionDropdownSearch().fill('Version 2');
modelVersionDetails.findModelVersionDropdownItem('Version 2').click();
modelVersionDetails.findVersionId().contains('2');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '@patternfly/react-core';
import useModelVersionsByRegisteredModel from '~/concepts/modelRegistry/apiHooks/useModelVersionsByRegisteredModel';
import { ModelVersion } from '~/concepts/modelRegistry/types';
import { filterLiveVersions } from '~/concepts/modelRegistry/utils';

type ModelVersionSelectorProps = {
rmId?: string;
Expand All @@ -33,16 +34,17 @@ const ModelVersionSelector: React.FC<ModelVersionSelectorProps> = ({
const menuRef = React.useRef(null);

const [modelVersions] = useModelVersionsByRegisteredModel(rmId);
const liveModelVersions = filterLiveVersions(modelVersions.items);

const menuListItems = modelVersions.items
const menuListItems = liveModelVersions
.filter((item) => !input || item.name.toLowerCase().includes(input.toString().toLowerCase()))
.map((mv, index) => (
<MenuItem isSelected={mv.id === selection.id} itemId={mv.id} key={index}>
{mv.name}
</MenuItem>
));

if (input && modelVersions.size === 0) {
if (input && liveModelVersions.length === 0) {
menuListItems.push(
<MenuItem isDisabled key="no result">
No results found
Expand Down Expand Up @@ -75,7 +77,7 @@ const ModelVersionSelector: React.FC<ModelVersionSelectorProps> = ({
</MenuSearchInput>
<HelperText style={{ paddingTop: '0.5rem' }}>
<HelperTextItem variant="indeterminate">
{`Type a name to search your ${modelVersions.size} versions.`}
{`Type a name to search your ${liveModelVersions.length} versions.`}
</HelperTextItem>
</HelperText>
</MenuSearch>
Expand Down

0 comments on commit 9d7dcab

Please sign in to comment.