Commit cfba3a08 authored by anna_vovchenko's avatar anna_vovchenko

Added suggested changes after FE and TW reviews

parent 18711a65
...@@ -16,11 +16,11 @@ import { removeAgentFromStore } from '../graphql/cache_update'; ...@@ -16,11 +16,11 @@ import { removeAgentFromStore } from '../graphql/cache_update';
export default { export default {
i18n: { i18n: {
dropdownText: __('More actions'), dropdownText: __('More options'),
deleteButton: s__('ClusterAgents|Delete agent'), deleteButton: s__('ClusterAgents|Delete agent'),
modalTitle: __('Are you sure?'), modalTitle: __('Are you sure?'),
modalBody: s__( modalBody: s__(
'ClusterAgents|Are you sure you want to delete this agent? This action cannot be undone.', 'ClusterAgents|Are you sure you want to delete this agent? You cannot undo this.',
), ),
modalInputLabel: s__('ClusterAgents|To delete the agent, type %{name} to confirm:'), modalInputLabel: s__('ClusterAgents|To delete the agent, type %{name} to confirm:'),
modalAction: s__('ClusterAgents|Delete'), modalAction: s__('ClusterAgents|Delete'),
...@@ -44,6 +44,7 @@ export default { ...@@ -44,6 +44,7 @@ export default {
agent: { agent: {
required: true, required: true,
type: Object, type: Object,
validator: (value) => ['id', 'name'].every((prop) => value[prop]),
}, },
defaultBranchName: { defaultBranchName: {
default: '.noBranch', default: '.noBranch',
...@@ -113,20 +114,12 @@ export default { ...@@ -113,20 +114,12 @@ export default {
throw new Error(errors[0]); throw new Error(errors[0]);
} }
} catch (error) { } catch (error) {
if (error?.message) { this.error = error?.message || this.$options.i18n.defaultError;
this.error = error.message;
} else {
this.error = this.$options.i18n.defaultError;
}
} finally { } finally {
this.loading = false; this.loading = false;
const successMessage = sprintf(this.$options.i18n.successMessage, { name: this.agentName }); const successMessage = sprintf(this.$options.i18n.successMessage, { name: this.agentName });
if (!this.error) { this.$toast.show(this.error || successMessage);
this.$toast.show(successMessage);
} else {
this.$toast.show(this.error);
}
this.$refs.modal.hide(); this.$refs.modal.hide();
} }
......
...@@ -6,7 +6,7 @@ import timeagoMixin from '~/vue_shared/mixins/timeago'; ...@@ -6,7 +6,7 @@ import timeagoMixin from '~/vue_shared/mixins/timeago';
import { helpPagePath } from '~/helpers/help_page_helper'; import { helpPagePath } from '~/helpers/help_page_helper';
import { AGENT_STATUSES } from '../constants'; import { AGENT_STATUSES } from '../constants';
import { getAgentConfigPath } from '../clusters_util'; import { getAgentConfigPath } from '../clusters_util';
import AgentActions from './agent_actions.vue'; import AgentOptions from './agent_options.vue';
export default { export default {
i18n: { i18n: {
...@@ -14,7 +14,7 @@ export default { ...@@ -14,7 +14,7 @@ export default {
statusLabel: s__('ClusterAgents|Connection status'), statusLabel: s__('ClusterAgents|Connection status'),
lastContactLabel: s__('ClusterAgents|Last contact'), lastContactLabel: s__('ClusterAgents|Last contact'),
configurationLabel: s__('ClusterAgents|Configuration'), configurationLabel: s__('ClusterAgents|Configuration'),
actionsLabel: __('Actions'), optionsLabel: __('Options'),
troubleshootingText: s__('ClusterAgents|Learn how to troubleshoot'), troubleshootingText: s__('ClusterAgents|Learn how to troubleshoot'),
neverConnectedText: s__('ClusterAgents|Never'), neverConnectedText: s__('ClusterAgents|Never'),
}, },
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
GlTooltip, GlTooltip,
GlPopover, GlPopover,
TimeAgoTooltip, TimeAgoTooltip,
AgentActions, AgentOptions,
}, },
mixins: [timeagoMixin], mixins: [timeagoMixin],
AGENT_STATUSES, AGENT_STATUSES,
...@@ -74,8 +74,8 @@ export default { ...@@ -74,8 +74,8 @@ export default {
tdClass, tdClass,
}, },
{ {
key: 'actions', key: 'options',
label: this.$options.i18n.actionsLabel, label: this.$options.i18n.optionsLabel,
tdClass, tdClass,
}, },
]; ];
...@@ -154,8 +154,8 @@ export default { ...@@ -154,8 +154,8 @@ export default {
</span> </span>
</template> </template>
<template #cell(actions)="{ item }"> <template #cell(options)="{ item }">
<agent-actions <agent-options
:agent="item" :agent="item"
:default-branch-name="defaultBranchName" :default-branch-name="defaultBranchName"
:max-agents="maxAgents" :max-agents="maxAgents"
......
...@@ -136,8 +136,17 @@ with the following differences: ...@@ -136,8 +136,17 @@ with the following differences:
## Remove an agent ## Remove an agent
You can remove an agent using the [GitLab UI](#remove-an-agent-through-the-gitlab-ui) or through the [GraphQL API](#remove-an-agent-with-the-gitlab-graphql-api).
### Remove an agent through the GitLab UI
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/323055) in GitLab 14.7.
To remove an agent from the UI:
1. Go to your agent's configuration repository.
1. From your project's sidebar, select **Infrastructure > Kubernetes clusters**. 1. From your project's sidebar, select **Infrastructure > Kubernetes clusters**.
1. Select your agent from the table, and then in the **Actions** column, click the vertical ellipsis 1. Select your agent from the table, and then in the **Options** column, click the vertical ellipsis
(**{ellipsis_v}**) button and select **Delete agent**. (**{ellipsis_v}**) button and select **Delete agent**.
### Remove an agent with the GitLab GraphQL API ### Remove an agent with the GitLab GraphQL API
......
...@@ -7560,7 +7560,7 @@ msgstr "" ...@@ -7560,7 +7560,7 @@ msgstr ""
msgid "ClusterAgents|An unknown error occurred. Please try again." msgid "ClusterAgents|An unknown error occurred. Please try again."
msgstr "" msgstr ""
msgid "ClusterAgents|Are you sure you want to delete this agent? This action cannot be undone." msgid "ClusterAgents|Are you sure you want to delete this agent? You cannot undo this."
msgstr "" msgstr ""
msgid "ClusterAgents|Certificate" msgid "ClusterAgents|Certificate"
...@@ -23041,6 +23041,9 @@ msgstr "" ...@@ -23041,6 +23041,9 @@ msgstr ""
msgid "More information." msgid "More information."
msgstr "" msgstr ""
msgid "More options"
msgstr ""
msgid "More than %{number_commits_distance} commits different with %{default_branch}" msgid "More than %{number_commits_distance} commits different with %{default_branch}"
msgstr "" msgstr ""
......
...@@ -6,7 +6,7 @@ import { ENTER_KEY } from '~/lib/utils/keys'; ...@@ -6,7 +6,7 @@ import { ENTER_KEY } from '~/lib/utils/keys';
import getAgentsQuery from '~/clusters_list/graphql/queries/get_agents.query.graphql'; import getAgentsQuery from '~/clusters_list/graphql/queries/get_agents.query.graphql';
import deleteAgentMutation from '~/clusters_list/graphql/mutations/delete_agent.mutation.graphql'; import deleteAgentMutation from '~/clusters_list/graphql/mutations/delete_agent.mutation.graphql';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import AgentActions from '~/clusters_list/components/agent_actions.vue'; import AgentOptions from '~/clusters_list/components/agent_options.vue';
import { MAX_LIST_COUNT } from '~/clusters_list/constants'; import { MAX_LIST_COUNT } from '~/clusters_list/constants';
import { getAgentResponse, mockDeleteResponse, mockErrorDeleteResponse } from '../mocks/apollo'; import { getAgentResponse, mockDeleteResponse, mockErrorDeleteResponse } from '../mocks/apollo';
...@@ -21,7 +21,7 @@ const agent = { ...@@ -21,7 +21,7 @@ const agent = {
webPath: 'agent-webPath', webPath: 'agent-webPath',
}; };
describe('AgentActions', () => { describe('AgentOptions', () => {
let wrapper; let wrapper;
let toast; let toast;
let apolloProvider; let apolloProvider;
...@@ -66,7 +66,7 @@ describe('AgentActions', () => { ...@@ -66,7 +66,7 @@ describe('AgentActions', () => {
toast = jest.fn(); toast = jest.fn();
wrapper = shallowMountExtended(AgentActions, { wrapper = shallowMountExtended(AgentOptions, {
apolloProvider, apolloProvider,
provide, provide,
propsData, propsData,
...@@ -190,7 +190,7 @@ describe('AgentActions', () => { ...@@ -190,7 +190,7 @@ describe('AgentActions', () => {
submitAgentToDelete(); submitAgentToDelete();
}); });
it('reenables the actions dropdown', async () => { it('reenables the options dropdown', async () => {
expect(findPrimaryActionAttributes('loading')).toBe(true); expect(findPrimaryActionAttributes('loading')).toBe(true);
expect(findDropdown().attributes('disabled')).toBe('true'); expect(findDropdown().attributes('disabled')).toBe('true');
......
import { GlLink, GlIcon } from '@gitlab/ui'; import { GlLink, GlIcon } from '@gitlab/ui';
import AgentTable from '~/clusters_list/components/agent_table.vue'; import AgentTable from '~/clusters_list/components/agent_table.vue';
import AgentActions from '~/clusters_list/components/agent_actions.vue'; import AgentOptions from '~/clusters_list/components/agent_options.vue';
import { ACTIVE_CONNECTION_TIME } from '~/clusters_list/constants'; import { ACTIVE_CONNECTION_TIME } from '~/clusters_list/constants';
import { mountExtended } from 'helpers/vue_test_utils_helper'; import { mountExtended } from 'helpers/vue_test_utils_helper';
import { stubComponent } from 'helpers/stub_component'; import { stubComponent } from 'helpers/stub_component';
...@@ -16,6 +16,7 @@ const propsData = { ...@@ -16,6 +16,7 @@ const propsData = {
agents: [ agents: [
{ {
name: 'agent-1', name: 'agent-1',
id: 'agent-1-id',
configFolder: { configFolder: {
webPath: '/agent/full/path', webPath: '/agent/full/path',
}, },
...@@ -26,6 +27,7 @@ const propsData = { ...@@ -26,6 +27,7 @@ const propsData = {
}, },
{ {
name: 'agent-2', name: 'agent-2',
id: 'agent-2-id',
webPath: '/agent-2', webPath: '/agent-2',
status: 'active', status: 'active',
lastContact: connectedTimeNow.getTime(), lastContact: connectedTimeNow.getTime(),
...@@ -39,6 +41,7 @@ const propsData = { ...@@ -39,6 +41,7 @@ const propsData = {
}, },
{ {
name: 'agent-3', name: 'agent-3',
id: 'agent-3-id',
webPath: '/agent-3', webPath: '/agent-3',
status: 'inactive', status: 'inactive',
lastContact: connectedTimeInactive.getTime(), lastContact: connectedTimeInactive.getTime(),
...@@ -53,7 +56,7 @@ const propsData = { ...@@ -53,7 +56,7 @@ const propsData = {
], ],
}; };
const AgentActionsStub = stubComponent(AgentActions, { const AgentOptionsStub = stubComponent(AgentOptions, {
template: `<div></div>`, template: `<div></div>`,
}); });
...@@ -66,14 +69,14 @@ describe('AgentTable', () => { ...@@ -66,14 +69,14 @@ describe('AgentTable', () => {
const findLastContactText = (at) => wrapper.findAllByTestId('cluster-agent-last-contact').at(at); const findLastContactText = (at) => wrapper.findAllByTestId('cluster-agent-last-contact').at(at);
const findConfiguration = (at) => const findConfiguration = (at) =>
wrapper.findAllByTestId('cluster-agent-configuration-link').at(at); wrapper.findAllByTestId('cluster-agent-configuration-link').at(at);
const findAgentActions = () => wrapper.findAllComponents(AgentActions); const findAgentOptions = () => wrapper.findAllComponents(AgentOptions);
beforeEach(() => { beforeEach(() => {
wrapper = mountExtended(AgentTable, { wrapper = mountExtended(AgentTable, {
propsData, propsData,
provide: provideData, provide: provideData,
stubs: { stubs: {
AgentActions: AgentActionsStub, AgentOptions: AgentOptionsStub,
}, },
}); });
}); });
...@@ -125,7 +128,7 @@ describe('AgentTable', () => { ...@@ -125,7 +128,7 @@ describe('AgentTable', () => {
}); });
it('displays actions menu for each agent', () => { it('displays actions menu for each agent', () => {
expect(findAgentActions()).toHaveLength(3); expect(findAgentOptions()).toHaveLength(3);
}); });
}); });
}); });
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