-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1772 from ppadti/issue-1615
Update Custom Serving Runtime tooltip with Openshift resource information
- Loading branch information
Showing
6 changed files
with
65 additions
and
3 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
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
36 changes: 36 additions & 0 deletions
36
frontend/src/utilities/__tests__/addTypesToK8sListedResources.spec.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,36 @@ | ||
import { K8sResourceCommon } from '@openshift/dynamic-plugin-sdk-utils'; | ||
import { addTypesToK8sListedResources } from '~/utilities/addTypesToK8sListedResources'; | ||
|
||
const servingRuntimeTemplate = { | ||
apiVersion: 'template.openshift.io/v1', | ||
kind: 'TemplateList', | ||
items: [ | ||
{ | ||
metadata: { | ||
name: 'test-model', | ||
annotations: { | ||
'openshift.io/display-name': 'New OVMS Server', | ||
}, | ||
labels: { | ||
'opendatahub.io/dashboard': 'true', | ||
}, | ||
}, | ||
}, | ||
], | ||
metadata: { | ||
resourceVersion: '24348645', | ||
continue: '', | ||
}, | ||
}; | ||
|
||
describe('addTypesToK8sListedResources', () => { | ||
it('should have apiVersion and kind as Template', () => { | ||
const list = addTypesToK8sListedResources(servingRuntimeTemplate, 'Template'); | ||
expect(list).not.toBe(servingRuntimeTemplate); | ||
expect(list.items).toHaveLength(servingRuntimeTemplate.items.length); | ||
list.items.forEach((i: Partial<K8sResourceCommon>) => { | ||
expect(i.apiVersion).toBe('template.openshift.io/v1'); | ||
expect(i.kind).toBe('Template'); | ||
}); | ||
}); | ||
}); |
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,14 @@ | ||
import { K8sResourceCommon } from '@openshift/dynamic-plugin-sdk-utils'; | ||
import { K8sResourceListResult } from '~/k8sTypes'; | ||
|
||
export const addTypesToK8sListedResources = <TResource extends Partial<K8sResourceCommon>>( | ||
response: K8sResourceListResult<TResource>, | ||
kind: string, | ||
): K8sResourceListResult<TResource> => ({ | ||
...response, | ||
items: response.items.map((i) => ({ | ||
...i, | ||
apiVersion: response.apiVersion, | ||
kind, | ||
})), | ||
}); |