Skip to content
代码片段 群组 项目
未验证 提交 95c4f6d7 编辑于 作者: Jacques Erasmus's avatar Jacques Erasmus 提交者: GitLab
浏览文件

Merge branch '444857-setup-required-data-for-allow-block-action-in-agent-auth-ui' into 'master'

Expose required parameters in Agent Authorization UI

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/154341



Merged-by: default avatarJacques Erasmus <jerasmus@gitlab.com>
Approved-by: default avatarThomas Hutterer <thutterer@gitlab.com>
Approved-by: default avatarJacques Erasmus <jerasmus@gitlab.com>
Reviewed-by: default avatarThomas Hutterer <thutterer@gitlab.com>
Co-authored-by: default avatarEnrique Alcantara <ealcantara@gitlab.com>
No related branches found
No related tags found
1 合并请求!2498Add job wait time to group runners dashboard
...@@ -31,6 +31,7 @@ export default { ...@@ -31,6 +31,7 @@ export default {
return { return {
agents: [], agents: [],
errorMessage: '', errorMessage: '',
namespaceId: '',
}; };
}, },
computed: { computed: {
...@@ -48,7 +49,8 @@ export default { ...@@ -48,7 +49,8 @@ export default {
}, },
}, },
methods: { methods: {
onQueryResult({ agents }) { onQueryResult({ agents, namespaceId }) {
this.namespaceId = namespaceId;
this.agents = agents; this.agents = agents;
}, },
onErrorResult() { onErrorResult() {
...@@ -80,6 +82,7 @@ export default { ...@@ -80,6 +82,7 @@ export default {
v-if="!errorMessage" v-if="!errorMessage"
data-testid="allowed-agents-table" data-testid="allowed-agents-table"
:agents="allowedAgents" :agents="allowedAgents"
:namespace-id="namespaceId"
:is-loading="loading" :is-loading="loading"
:empty-state-message="allowedAgentsTableEmptyMessage" :empty-state-message="allowedAgentsTableEmptyMessage"
/> />
...@@ -93,9 +96,10 @@ export default { ...@@ -93,9 +96,10 @@ export default {
<agents-table <agents-table
v-if="!errorMessage" v-if="!errorMessage"
data-testid="all-agents-table" data-testid="all-agents-table"
display-mapping-status
:agents="agents" :agents="agents"
:namespace-id="namespaceId"
:is-loading="loading" :is-loading="loading"
display-mapping-status
:empty-state-message="$options.NO_AGENTS_MESSAGE" :empty-state-message="$options.NO_AGENTS_MESSAGE"
/> />
</gl-tab> </gl-tab>
......
...@@ -35,6 +35,11 @@ export default { ...@@ -35,6 +35,11 @@ export default {
type: Array, type: Array,
required: true, required: true,
}, },
namespaceId: {
type: String,
required: false,
default: '',
},
emptyStateMessage: { emptyStateMessage: {
type: String, type: String,
required: true, required: true,
......
...@@ -34,7 +34,11 @@ export default { ...@@ -34,7 +34,11 @@ export default {
return; return;
} }
const { remoteDevelopmentClusterAgents, clusterAgents } = result.data.group; const {
remoteDevelopmentClusterAgents,
clusterAgents,
id: namespaceId,
} = result.data.group;
const agents = const agents =
clusterAgents?.nodes.map(({ id, name }) => { clusterAgents?.nodes.map(({ id, name }) => {
...@@ -51,7 +55,7 @@ export default { ...@@ -51,7 +55,7 @@ export default {
}; };
}) || []; }) || [];
this.$emit('result', { agents }); this.$emit('result', { namespaceId, agents });
}, },
}, },
}, },
......
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql'; import createDefaultClient from '~/lib/graphql';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase, parseBoolean } from '~/lib/utils/common_utils';
import App from './pages/app.vue'; import App from './pages/app.vue';
Vue.use(VueApollo); Vue.use(VueApollo);
...@@ -19,7 +19,7 @@ const initWorkspacesSettingsApp = () => { ...@@ -19,7 +19,7 @@ const initWorkspacesSettingsApp = () => {
return null; return null;
} }
const { namespace } = convertObjectPropsToCamelCase(el.dataset); const { namespace, canAdminClusterAgentMapping } = convertObjectPropsToCamelCase(el.dataset);
return new Vue({ return new Vue({
el, el,
...@@ -27,6 +27,7 @@ const initWorkspacesSettingsApp = () => { ...@@ -27,6 +27,7 @@ const initWorkspacesSettingsApp = () => {
apolloProvider: createApolloProvider(), apolloProvider: createApolloProvider(),
provide: { provide: {
namespace, namespace,
canAdminClusterAgentMapping: parseBoolean(canAdminClusterAgentMapping),
}, },
render: (createElement) => createElement(App), render: (createElement) => createElement(App),
}); });
......
- page_title s_('Workspaces|Workspaces Settings') - page_title s_('Workspaces|Workspaces Settings')
- breadcrumb_title s_("Workspaces|Workspaces Settings") - breadcrumb_title s_("Workspaces|Workspaces Settings")
#js-workspaces-settings{ data: { namespace: @group.full_path } } #js-workspaces-settings{ data: {
namespace: @group.full_path,
can_admin_cluster_agent_mapping: can?(current_user, :admin_remote_development_cluster_agent_mapping, @group).to_s } }
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import { GlAlert, GlTabs, GlTab, GlBadge } from '@gitlab/ui'; import { GlAlert, GlTabs, GlTab, GlBadge } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import {
AGENT_MAPPING_STATUS_MAPPED,
AGENT_MAPPING_STATUS_UNMAPPED,
} from 'ee/workspaces/agent_mapping/constants';
import AgentMapping from 'ee_component/workspaces/agent_mapping/components/agent_mapping.vue'; import AgentMapping from 'ee_component/workspaces/agent_mapping/components/agent_mapping.vue';
import GetAgentsWithMappingStatusQuery from 'ee_component/workspaces/agent_mapping/components/get_agents_with_mapping_status_query.vue'; import GetAgentsWithMappingStatusQuery from 'ee_component/workspaces/agent_mapping/components/get_agents_with_mapping_status_query.vue';
import { AGENT_MAPPING_STATUS_MAPPED } from 'ee/workspaces/agent_mapping/constants';
import { stubComponent } from 'helpers/stub_component'; import { stubComponent } from 'helpers/stub_component';
import { NAMESPACE_ID, MAPPED_CLUSTER_AGENT, UNMAPPED_CLUSTER_AGENT } from '../../mock_data';
describe('workspaces/agent_mapping/components/agent_mapping.vue', () => { describe('workspaces/agent_mapping/components/agent_mapping', () => {
let wrapper; let wrapper;
const NAMESPACE = 'foo/bar'; const NAMESPACE = 'foo/bar';
...@@ -38,6 +35,12 @@ describe('workspaces/agent_mapping/components/agent_mapping.vue', () => { ...@@ -38,6 +35,12 @@ describe('workspaces/agent_mapping/components/agent_mapping.vue', () => {
const findErrorAlert = () => wrapper.findComponent(GlAlert); const findErrorAlert = () => wrapper.findComponent(GlAlert);
const findAllowedAgentsTab = () => wrapper.findByTestId('allowed-agents-tab'); const findAllowedAgentsTab = () => wrapper.findByTestId('allowed-agents-tab');
const findAllAgentsTab = () => wrapper.findByTestId('all-agents-tab'); const findAllAgentsTab = () => wrapper.findByTestId('all-agents-tab');
const triggerQueryResultEvent = (result) => {
findGetAgentsWithMappingStatusQuery().vm.$emit('result', {
namespaceId: NAMESPACE_ID,
...result,
});
};
describe('default', () => { describe('default', () => {
beforeEach(() => { beforeEach(() => {
...@@ -64,26 +67,18 @@ describe('workspaces/agent_mapping/components/agent_mapping.vue', () => { ...@@ -64,26 +67,18 @@ describe('workspaces/agent_mapping/components/agent_mapping.vue', () => {
buildWrapper(); buildWrapper();
agents = [ agents = [
MAPPED_CLUSTER_AGENT,
UNMAPPED_CLUSTER_AGENT,
{ {
id: 'agent-1', ...UNMAPPED_CLUSTER_AGENT,
name: 'agent one',
mappingStatus: AGENT_MAPPING_STATUS_MAPPED,
},
{
id: 'agent-2',
name: 'agent two',
mappingStatus: AGENT_MAPPING_STATUS_UNMAPPED,
},
{
id: 'agent-3', id: 'agent-3',
name: 'agent three', name: 'agent three',
mappingStatus: AGENT_MAPPING_STATUS_UNMAPPED,
}, },
]; ];
allowedAgents = agents.filter( allowedAgents = agents.filter(
(agent) => agent.mappingStatus === AGENT_MAPPING_STATUS_MAPPED, (agent) => agent.mappingStatus === AGENT_MAPPING_STATUS_MAPPED,
); );
findGetAgentsWithMappingStatusQuery().vm.$emit('result', { agents }); triggerQueryResultEvent({ agents });
await nextTick(); await nextTick();
}); });
...@@ -99,6 +94,11 @@ describe('workspaces/agent_mapping/components/agent_mapping.vue', () => { ...@@ -99,6 +94,11 @@ describe('workspaces/agent_mapping/components/agent_mapping.vue', () => {
); );
}); });
it('passes namespaceId to all tables', () => {
expect(findAllowedAgentsTable().props('namespaceId')).toEqual(NAMESPACE_ID);
expect(findAllAgentsTable().props('namespaceId')).toEqual(NAMESPACE_ID);
});
it('passes allowed agents to the allowed agents table', () => { it('passes allowed agents to the allowed agents table', () => {
expect(findAllowedAgentsTable().props('agents')).toEqual(allowedAgents); expect(findAllowedAgentsTable().props('agents')).toEqual(allowedAgents);
}); });
...@@ -116,18 +116,14 @@ describe('workspaces/agent_mapping/components/agent_mapping.vue', () => { ...@@ -116,18 +116,14 @@ describe('workspaces/agent_mapping/components/agent_mapping.vue', () => {
buildWrapper(); buildWrapper();
agents = [ agents = [
UNMAPPED_CLUSTER_AGENT,
{ {
id: 'agent-2', ...UNMAPPED_CLUSTER_AGENT,
name: 'agent two',
mappingStatus: AGENT_MAPPING_STATUS_UNMAPPED,
},
{
id: 'agent-3', id: 'agent-3',
name: 'agent three', name: 'agent three',
mappingStatus: AGENT_MAPPING_STATUS_UNMAPPED,
}, },
]; ];
findGetAgentsWithMappingStatusQuery().vm.$emit('result', { agents }); triggerQueryResultEvent({ agents });
await nextTick(); await nextTick();
}); });
...@@ -143,7 +139,7 @@ describe('workspaces/agent_mapping/components/agent_mapping.vue', () => { ...@@ -143,7 +139,7 @@ describe('workspaces/agent_mapping/components/agent_mapping.vue', () => {
buildWrapper(); buildWrapper();
agents = []; agents = [];
findGetAgentsWithMappingStatusQuery().vm.$emit('result', { agents }); triggerQueryResultEvent({ agents });
await nextTick(); await nextTick();
}); });
......
...@@ -85,6 +85,7 @@ describe('workspaces/agent_mapping/components/get_agents_with_mapping_status_que ...@@ -85,6 +85,7 @@ describe('workspaces/agent_mapping/components/get_agents_with_mapping_status_que
expect(wrapper.emitted('result')).toEqual([ expect(wrapper.emitted('result')).toEqual([
[ [
{ {
namespaceId: GET_AGENTS_WITH_MAPPING_STATUS_QUERY_RESULT.data.group.id,
agents: [ agents: [
{ {
id: 'gid://gitlab/Clusters::Agent/1', id: 'gid://gitlab/Clusters::Agent/1',
......
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { WORKSPACE_DESIRED_STATES, WORKSPACE_STATES } from 'ee/workspaces/common/constants'; import { WORKSPACE_DESIRED_STATES, WORKSPACE_STATES } from 'ee/workspaces/common/constants';
import {
AGENT_MAPPING_STATUS_MAPPED,
AGENT_MAPPING_STATUS_UNMAPPED,
} from 'ee/workspaces/agent_mapping/constants';
export const WORKSPACE = { export const WORKSPACE = {
__typename: 'Workspace', __typename: 'Workspace',
...@@ -402,3 +406,33 @@ export const WORKSPACE_UPDATE_MUTATION_RESULT = { ...@@ -402,3 +406,33 @@ export const WORKSPACE_UPDATE_MUTATION_RESULT = {
}, },
}, },
}; };
export const CREATE_CLUSTER_AGENT_MAPPING_MUTATION_RESULT = {
data: {
namespaceCreateRemoteDevelopmentClusterAgentMapping: {
clientMutationId: null,
},
},
};
export const DELETE_CLUSTER_AGENT_MAPPING_MUTATION_RESULT = {
data: {
namespaceDeleteRemoteDevelopmentClusterAgentMapping: {
clientMutationId: null,
},
},
};
export const MAPPED_CLUSTER_AGENT = {
id: 'gid://gitlab/Clusters::Agent/1',
name: 'rootgroup-agent',
mappingStatus: AGENT_MAPPING_STATUS_MAPPED,
};
export const UNMAPPED_CLUSTER_AGENT = {
id: 'gid://gitlab/Clusters::Agent/2',
name: 'rootgroup-agent-2',
mappingStatus: AGENT_MAPPING_STATUS_UNMAPPED,
};
export const NAMESPACE_ID = 'gid://gitlab/Group/81';
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册