Skip to content

Commit

Permalink
display full context in selector if the middle part cannot be parsed
Browse files Browse the repository at this point in the history
in the rare case of a user customised the name of the contexts and not
uses the default, long names
-
Ticket: SUITEDEV-30448
  • Loading branch information
hawser86 committed Mar 18, 2022
1 parent ea67012 commit 18db487
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/renderer/components/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ export default {
}),
computed: {
availableContexts() {
return this.contextList.map(context => ({
type: 'option',
content: context.split('_')[1],
value: context,
selected: context === this.context
}));
return this.contextList.map(context => {
const displayValue = context.split('_')[1];
return {
type: 'option',
content: displayValue || context,
value: context,
selected: context === this.context
};
});
},
namespaces() {
return this.namespaceList.map(namespace => ({
Expand Down
6 changes: 4 additions & 2 deletions src/renderer/components/app/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ describe('App', () => {
'prefix_gap-stage_postfix',
'prefix_gap-prod_postfix',
'prefix_custom-team-stage_postfix',
'prefix_custom-team-prod_postfix'
'prefix_custom-team-prod_postfix',
'full-custom-context'
]);
sinon.stub(kubernetesClient, 'listNamespaces').resolves([]);
const { vm } = await loadApp();
Expand All @@ -30,7 +31,8 @@ describe('App', () => {
{ 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 }
{ type: 'option', content: 'custom-team-prod', value: 'prefix_custom-team-prod_postfix', selected: false },
{ type: 'option', content: 'full-custom-context', value: 'full-custom-context', selected: false }
]);
});
});
Expand Down

0 comments on commit 18db487

Please sign in to comment.