fix when no GCP projects are found
This commit is contained in:
parent
bb0d746e4d
commit
e144946ebe
|
@ -38,6 +38,10 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
results() {
|
results() {
|
||||||
|
if (!this.items) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return this.items.filter(item => item.name.toLowerCase().indexOf(this.searchQuery) > -1);
|
return this.items.filter(item => item.name.toLowerCase().indexOf(this.searchQuery) > -1);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,10 +19,10 @@ export default {
|
||||||
...mapState({ items: 'projects' }),
|
...mapState({ items: 'projects' }),
|
||||||
...mapGetters(['hasProject']),
|
...mapGetters(['hasProject']),
|
||||||
hasOneProject() {
|
hasOneProject() {
|
||||||
return this.items.length === 1;
|
return this.items && this.items.length === 1;
|
||||||
},
|
},
|
||||||
isDisabled() {
|
isDisabled() {
|
||||||
return this.items.length < 2;
|
return this.items && this.items.length < 2;
|
||||||
},
|
},
|
||||||
toggleText() {
|
toggleText() {
|
||||||
if (this.isLoading) {
|
if (this.isLoading) {
|
||||||
|
@ -33,20 +33,27 @@ export default {
|
||||||
return this.selectedProject.name;
|
return this.selectedProject.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !this.items.length
|
if (!this.items) {
|
||||||
? s__('ClusterIntegration|No projects found')
|
return s__('ClusterIntegration|No projects found');
|
||||||
: s__('ClusterIntegration|Select project');
|
}
|
||||||
|
|
||||||
|
return s__('ClusterIntegration|Select project');
|
||||||
},
|
},
|
||||||
helpText() {
|
helpText() {
|
||||||
let message;
|
let message;
|
||||||
if (this.hasErrors) {
|
if (this.hasErrors) {
|
||||||
|
message = this.gapiError;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.items) {
|
||||||
message =
|
message =
|
||||||
'ClusterIntegration|We were unable to fetch any projects. Ensure that you have a project on %{docsLinkStart}Google Cloud Platform%{docsLinkEnd}.';
|
'ClusterIntegration|We were unable to fetch any projects. Ensure that you have a project on %{docsLinkStart}Google Cloud Platform%{docsLinkEnd}.';
|
||||||
}
|
}
|
||||||
|
|
||||||
message = this.items.length
|
message =
|
||||||
? 'ClusterIntegration|To use a new project, first create one on %{docsLinkStart}Google Cloud Platform%{docsLinkEnd}.'
|
this.items && this.items.length
|
||||||
: 'ClusterIntegration|To create a cluster, first create a project on %{docsLinkStart}Google Cloud Platform%{docsLinkEnd}.';
|
? 'ClusterIntegration|To use a new project, first create one on %{docsLinkStart}Google Cloud Platform%{docsLinkEnd}.'
|
||||||
|
: 'ClusterIntegration|To create a cluster, first create a project on %{docsLinkStart}Google Cloud Platform%{docsLinkEnd}.';
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
s__(message),
|
s__(message),
|
||||||
|
|
|
@ -58,7 +58,7 @@ describe('GkeProjectIdDropdown', () => {
|
||||||
|
|
||||||
it('returns empty toggle text', done =>
|
it('returns empty toggle text', done =>
|
||||||
vm.$nextTick().then(() => {
|
vm.$nextTick().then(() => {
|
||||||
vm.$store.commit(SET_PROJECTS, []);
|
vm.$store.commit(SET_PROJECTS, null);
|
||||||
vm.setItem(emptyProjectMock);
|
vm.setItem(emptyProjectMock);
|
||||||
|
|
||||||
expect(vm.toggleText).toBe(LABELS.EMPTY);
|
expect(vm.toggleText).toBe(LABELS.EMPTY);
|
||||||
|
|
Loading…
Reference in New Issue