Commit 7d45e44f authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'remove-instructions-to-install-agent' into 'master'

Remove instructions to install Agent if KAS is not set up

See merge request gitlab-org/gitlab!78168
parents 5595a0bb 51d7f1e0
...@@ -142,6 +142,9 @@ export default { ...@@ -142,6 +142,9 @@ export default {
isAgentRegistrationModal() { isAgentRegistrationModal() {
return this.modalType === MODAL_TYPE_REGISTER; return this.modalType === MODAL_TYPE_REGISTER;
}, },
isKasEnabledInEmptyStateModal() {
return this.isEmptyStateModal && !this.kasDisabled;
},
}, },
methods: { methods: {
setAgentName(name) { setAgentName(name) {
...@@ -350,18 +353,18 @@ export default { ...@@ -350,18 +353,18 @@ export default {
<img :alt="i18n.altText" :src="emptyStateImage" height="100" /> <img :alt="i18n.altText" :src="emptyStateImage" height="100" />
</div> </div>
<p> <p v-if="kasDisabled">
<gl-sprintf :message="i18n.modalBody"> <gl-sprintf :message="i18n.enableKasText">
<template #link="{ content }"> <template #link="{ content }">
<gl-link :href="$options.installAgentPath"> {{ content }}</gl-link> <gl-link :href="$options.enableKasPath">{{ content }}</gl-link>
</template> </template>
</gl-sprintf> </gl-sprintf>
</p> </p>
<p v-if="kasDisabled"> <p v-else>
<gl-sprintf :message="i18n.enableKasText"> <gl-sprintf :message="i18n.modalBody">
<template #link="{ content }"> <template #link="{ content }">
<gl-link :href="$options.enableKasPath"> {{ content }}</gl-link> <gl-link :href="$options.installAgentPath">{{ content }}</gl-link>
</template> </template>
</gl-sprintf> </gl-sprintf>
</p> </p>
...@@ -401,7 +404,7 @@ export default { ...@@ -401,7 +404,7 @@ export default {
</gl-button> </gl-button>
<gl-button <gl-button
v-if="isEmptyStateModal" v-if="isKasEnabledInEmptyStateModal"
:href="repositoryPath" :href="repositoryPath"
variant="confirm" variant="confirm"
category="secondary" category="secondary"
......
import { GlAlert, GlButton, GlFormInputGroup } from '@gitlab/ui'; import { GlAlert, GlButton, GlFormInputGroup, GlSprintf } from '@gitlab/ui';
import { createLocalVue } from '@vue/test-utils'; import { createLocalVue } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { sprintf } from '~/locale';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { mockTracking } from 'helpers/tracking_helper'; import { mockTracking } from 'helpers/tracking_helper';
import AvailableAgentsDropdown from '~/clusters_list/components/available_agents_dropdown.vue'; import AvailableAgentsDropdown from '~/clusters_list/components/available_agents_dropdown.vue';
...@@ -27,6 +28,7 @@ import { ...@@ -27,6 +28,7 @@ import {
createAgentTokenResponse, createAgentTokenResponse,
createAgentTokenErrorResponse, createAgentTokenErrorResponse,
getAgentResponse, getAgentResponse,
kasDisabledErrorResponse,
} from '../mocks/apollo'; } from '../mocks/apollo';
import ModalStub from '../stubs'; import ModalStub from '../stubs';
...@@ -35,7 +37,6 @@ localVue.use(VueApollo); ...@@ -35,7 +37,6 @@ localVue.use(VueApollo);
const projectPath = 'path/to/project'; const projectPath = 'path/to/project';
const kasAddress = 'kas.example.com'; const kasAddress = 'kas.example.com';
const kasEnabled = true;
const emptyStateImage = 'path/to/image'; const emptyStateImage = 'path/to/image';
const defaultBranchName = 'default'; const defaultBranchName = 'default';
const maxAgents = MAX_LIST_COUNT; const maxAgents = MAX_LIST_COUNT;
...@@ -80,7 +81,6 @@ describe('InstallAgentModal', () => { ...@@ -80,7 +81,6 @@ describe('InstallAgentModal', () => {
const provide = { const provide = {
projectPath, projectPath,
kasAddress, kasAddress,
kasEnabled,
emptyStateImage, emptyStateImage,
}; };
...@@ -92,6 +92,7 @@ describe('InstallAgentModal', () => { ...@@ -92,6 +92,7 @@ describe('InstallAgentModal', () => {
wrapper = shallowMountExtended(InstallAgentModal, { wrapper = shallowMountExtended(InstallAgentModal, {
attachTo: document.body, attachTo: document.body,
stubs: { stubs: {
GlSprintf,
GlModal: ModalStub, GlModal: ModalStub,
}, },
localVue, localVue,
...@@ -307,4 +308,34 @@ describe('InstallAgentModal', () => { ...@@ -307,4 +308,34 @@ describe('InstallAgentModal', () => {
}); });
}); });
}); });
describe('when KAS is disabled', () => {
const i18n = I18N_AGENT_MODAL.empty_state;
beforeEach(() => {
apolloProvider = createMockApollo([
[getAgentConfigurations, jest.fn().mockResolvedValue(kasDisabledErrorResponse)],
]);
return mockSelectedAgentResponse();
});
it('renders empty state image', () => {
expect(findImage().attributes('src')).toBe(emptyStateImage);
});
it('renders an instruction to enable the KAS', () => {
expect(findModal().text()).toContain(
sprintf(i18n.enableKasText, { linkStart: '', linkEnd: '' }),
);
});
it('renders a cancel button', () => {
expect(findActionButton().isVisible()).toBe(true);
expect(findActionButton().text()).toBe(i18n.done);
});
it("doesn't render a secondary button", () => {
expect(findSecondaryButton().exists()).toBe(false);
});
});
}); });
...@@ -76,6 +76,11 @@ export const getAgentResponse = { ...@@ -76,6 +76,11 @@ export const getAgentResponse = {
}, },
}; };
export const kasDisabledErrorResponse = {
data: {},
errors: [{ message: 'Gitlab::Kas::Client::ConfigurationError' }],
};
export const mockDeleteResponse = { export const mockDeleteResponse = {
data: { clusterAgentDelete: { errors: [] } }, data: { clusterAgentDelete: { errors: [] } },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment