Skip to content

Commit

Permalink
improve context name displaying
Browse files Browse the repository at this point in the history
to make webchannel people happier
-
Ticket: SUITEDEV-30089
  • Loading branch information
hawser86 committed Feb 11, 2022
1 parent 5a8c9e9 commit 769f423
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/renderer/components/app/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ipcRenderer } from 'electron';
import log from 'electron-log';
import { get, isEqual, last, uniqBy } from 'lodash';
import { get, isEqual, uniqBy } from 'lodash';
import { mapMutations } from 'vuex';
import kubernetesClient from '../../lib/kubernetes-client/kubernetes-client';
import notificationDisplayer from '../../lib/notification-displayer';
Expand Down Expand Up @@ -46,7 +46,7 @@ export default {
availableContexts() {
return this.contextList.map(context => ({
type: 'option',
content: last(context.split('_')),
content: context.split('_')[1],
value: context,
selected: context === this.context
}));
Expand Down
14 changes: 9 additions & 5 deletions src/renderer/components/app/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ describe('App', () => {
describe('#availableContexts', () => {
it('should return available contexts in UI Kit select format and with a short name', async () => {
sinon.stub(kubernetesClient, 'listContexts').resolves([
'some-prefix_useless-middle-part_gap-stage',
'some-prefix_useless-middle-part_gap-prod'
'prefix_gap-stage_postfix',
'prefix_gap-prod_postfix',
'prefix_custom-team-stage_postfix',
'prefix_custom-team-prod_postfix'
]);
sinon.stub(kubernetesClient, 'listNamespaces').resolves([]);
const { vm } = await loadApp();
vm.context = 'some-prefix_useless-middle-part_gap-stage';
vm.context = 'prefix_gap-stage_postfix';

expect(vm.availableContexts).to.eql([
{ type: 'option', content: 'gap-stage', value: 'some-prefix_useless-middle-part_gap-stage', selected: true },
{ type: 'option', content: 'gap-prod', value: 'some-prefix_useless-middle-part_gap-prod', selected: false }
{ type: 'option', content: 'gap-stage', value: 'prefix_gap-stage_postfix', selected: true },
{ type: 'option', content: 'gap-prod', value: 'prefix_gap-prod_postfix', selected: false },
{ type: 'option', content: 'custom-team-stage', value: 'prefix_custom-team-stage_postfix', selected: false },
{ type: 'option', content: 'custom-team-prod', value: 'prefix_custom-team-prod_postfix', selected: false }
]);
});
});
Expand Down

0 comments on commit 769f423

Please sign in to comment.