Skip to content

Commit

Permalink
add CSI suffix to all non-builtin storageClass provisioners (rancher#…
Browse files Browse the repository at this point in the history
…10348)

* add CSI suffix to all non-builtin storageClass provisioners

* improve unit test

* fix issue with storybook build a spec.ts files

* update main.js to exclude

* revert changes to storybook config + rewrite unit test

---------

Co-authored-by: Alexandre Alves <[email protected]>
  • Loading branch information
aalves08 and Alexandre Alves authored Jan 31, 2024
1 parent 765a991 commit b4d463b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions shell/models/__tests__/storage.k8s.io.storageclass.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import StorageClass, { PROVISIONER_OPTIONS } from '@shell/models/storage.k8s.io.storageclass';

describe('class StorageClass', () => {
describe('checking if provisionerDisplay', () => {
it.each([
['kubernetes.io/azure-disk', true],
['kubernetes.io/portworx-volume', true],
['rancher.io/local-path', false],
['some-random-string-as-provisioner', false],
])('should NOT show a suffix IF they are built-in (on the PROVISIONER_OPTIONS list)', (provisioner, expectation) => {
const storageClass = new StorageClass({
metadata: {},
spec: {},
provisioner
});

jest.spyOn(storageClass, '$rootGetters', 'get').mockReturnValue({ 'i18n/t': jest.fn() });

expect(!!PROVISIONER_OPTIONS.find((opt) => opt.value === provisioner)).toBe(expectation);
});
});
});
2 changes: 1 addition & 1 deletion shell/models/storage.k8s.io.storageclass.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const PROVISIONER_OPTIONS = [
export default class extends SteveModel {
get provisionerDisplay() {
const option = PROVISIONER_OPTIONS.find((o) => o.value === this.provisioner);
const fallback = `${ this.provisioner } ${ this.t('persistentVolume.csi.drivers.suffix') }`;
const fallback = `${ this.provisioner } ${ this.t('persistentVolume.csi.suffix') }`;

return option ? this.t(option.labelKey) : this.$rootGetters['i18n/withFallback'](`persistentVolume.csi.drivers.${ this.provisioner.replaceAll('.', '-') }`, null, fallback);
}
Expand Down

0 comments on commit b4d463b

Please sign in to comment.