Commit 8a31782a authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 5918b018 dfad880d
24415e4973647f1b9be3b2cff0ebde4439917484 79003389aa5098a6ef37e73298cafbad4d9e6b79
- add_page_specific_style 'page_bundles/ci_status' - add_page_specific_style 'page_bundles/ci_status'
= content_for :title do
%h3.project-title
Runner ##{@runner.id}
.float-right
- if @runner.instance_type?
%span.runner-state.runner-state-shared
Shared
- else
%span.runner-state.runner-state-specific
Specific
- page_title @runner.short_sha - page_title @runner.short_sha
- add_to_breadcrumbs _("Runners"), admin_runners_path - add_to_breadcrumbs _('Runners'), admin_runners_path
- breadcrumb_title "##{@runner.id}" - breadcrumb_title page_title
%h2.page-title
= sprintf(s_('Runners|Runner #%{runner_id}'), {runner_id: @runner.id})
- if @runner.instance_type? - if @runner.instance_type?
.bs-callout.bs-callout-success .bs-callout.bs-callout-success
......
---
title: Add Runner ID as title in Runner details page
merge_request: 57247
author:
type: changed
---
name: cluster_agent_list
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42115
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/249596
milestone: '13.5'
type: development
group: group::configure
default_enabled: true
mutation updateActiveStep($id: String) {
updateActiveStep(id: $id) @client
}
import produce from 'immer';
import activeStepQuery from './queries/active_step.query.graphql';
import stepListQuery from './queries/step_list.query.graphql';
function updateActiveStep(_, { id }, { cache }) {
const sourceData = cache.readQuery({ query: activeStepQuery });
const { stepList } = cache.readQuery({ query: stepListQuery });
const activeStep = stepList.find((step) => step.id === id);
const data = produce(sourceData, (draftData) => {
draftData.activeStep = {
// eslint-disable-next-line @gitlab/require-i18n-strings
__typename: 'Step',
id: activeStep.id,
};
});
return cache.writeQuery({ query: activeStepQuery, data });
}
function activateNextStep(parent, _, { cache }) {
const sourceData = cache.readQuery({ query: activeStepQuery });
const { stepList } = cache.readQuery({ query: stepListQuery });
const index = stepList.findIndex((step) => step.id === sourceData.activeStep.id);
const activeStep = stepList[index + 1];
const data = produce(sourceData, (draftData) => {
draftData.activeStep = {
// eslint-disable-next-line @gitlab/require-i18n-strings
__typename: 'Step',
id: activeStep.id,
};
});
return cache.writeQuery({ query: activeStepQuery, data });
}
export default {
Mutation: {
updateActiveStep,
activateNextStep,
},
};
type Step {
id: ID
}
extend type Query {
activeStep: Step
}
extend type Query {
stepList: [Step]
}
extend type Mutation {
updateActiveStep(id: ID!): Boolean
}
...@@ -6,9 +6,13 @@ module EE ...@@ -6,9 +6,13 @@ module EE
override :display_cluster_agents? override :display_cluster_agents?
def display_cluster_agents?(clusterable) def display_cluster_agents?(clusterable)
return unless ::Feature.enabled?(:cluster_agent_list, default_enabled: true) clusterable.is_a?(Project) && clusterable.feature_available?(:cluster_agents) && included_in_gitlab_com_rollout?(clusterable)
end
private
clusterable.is_a?(Project) && clusterable.feature_available?(:cluster_agents) def included_in_gitlab_com_rollout?(project)
::Gitlab::Kas.included_in_gitlab_com_rollout?(project)
end end
end end
end end
---
title: Hide cluster agent UI if not enabled on GitLab.com
merge_request: 57668
author:
type: changed
import { createMockClient } from 'mock-apollo-client';
import activateNextStepMutation from 'ee/vue_shared/purchase_flow/graphql/mutations/activate_next_step.mutation.graphql';
import updateStepMutation from 'ee/vue_shared/purchase_flow/graphql/mutations/update_active_step.mutation.graphql';
import activeStepQuery from 'ee/vue_shared/purchase_flow/graphql/queries/active_step.query.graphql';
import stepListQuery from 'ee/vue_shared/purchase_flow/graphql/queries/step_list.query.graphql';
import resolvers from 'ee/vue_shared/purchase_flow/graphql/resolvers';
import typeDefs from 'ee/vue_shared/purchase_flow/graphql/typedefs.graphql';
import { STEPS } from '../mock_data';
describe('ee/vue_shared/purchase_flow/graphql/resolvers', () => {
let mockClient;
beforeEach(async () => {
mockClient = createMockClient({ resolvers, typeDefs });
mockClient.cache.writeQuery({
query: stepListQuery,
data: {
stepList: STEPS,
},
});
mockClient.cache.writeQuery({
query: activeStepQuery,
data: {
activeStep: STEPS[0],
},
});
});
describe('Query', () => {
describe('stepListQuery', () => {
it('stores the stepList', async () => {
const queryResult = await mockClient.query({ query: stepListQuery });
expect(queryResult.data.stepList).toMatchObject(
STEPS.map(({ id }) => {
return { id };
}),
);
});
it('throws an error when cache is not initiated properly', async () => {
mockClient.clearStore();
await mockClient.query({ query: stepListQuery }).catch((e) => {
expect(e instanceof Error).toBe(true);
});
});
});
describe('activeStepQuery', () => {
it('stores the activeStep', async () => {
const queryResult = await mockClient.query({ query: activeStepQuery });
expect(queryResult.data.activeStep).toMatchObject({ id: STEPS[0].id });
});
it('throws an error when cache is not initiated properly', async () => {
mockClient.clearStore();
await mockClient.query({ query: activeStepQuery }).catch((e) => {
expect(e instanceof Error).toBe(true);
});
});
});
});
describe('Mutation', () => {
describe('updateActiveStep', () => {
it('updates the active step', async () => {
await mockClient.mutate({
mutation: updateStepMutation,
variables: { id: STEPS[1].id },
});
const queryResult = await mockClient.query({ query: activeStepQuery });
expect(queryResult.data.activeStep).toMatchObject({ id: STEPS[1].id });
});
it('throws an error when STEP is not present', async () => {
const id = 'does not exist';
await mockClient
.mutate({
mutation: updateStepMutation,
variables: { id },
})
.catch((e) => {
expect(e instanceof Error).toBe(true);
});
});
it('throws an error when cache is not initiated properly', async () => {
mockClient.clearStore();
await mockClient
.mutate({
mutation: updateStepMutation,
variables: { id: STEPS[1].id },
})
.catch((e) => {
expect(e instanceof Error).toBe(true);
});
});
});
describe('activateNextStep', () => {
it('updates the active step to the next', async () => {
await mockClient.mutate({
mutation: activateNextStepMutation,
});
const queryResult = await mockClient.query({ query: activeStepQuery });
expect(queryResult.data.activeStep).toMatchObject({ id: STEPS[1].id });
});
it('throws an error when out of bounds', async () => {
await mockClient.mutate({
mutation: activateNextStepMutation,
});
await mockClient
.mutate({
mutation: activateNextStepMutation,
})
.catch((e) => {
expect(e instanceof Error).toBe(true);
});
});
it('throws an error when cache is not initiated properly', async () => {
mockClient.clearStore();
await mockClient
.mutate({
mutation: activateNextStepMutation,
})
.catch((e) => {
expect(e instanceof Error).toBe(true);
});
});
});
});
});
export const STEPS = [
{ __typename: 'Step', id: 'firstStep' },
{ __typename: 'Step', id: 'secondStep' },
];
...@@ -16,6 +16,8 @@ RSpec.describe ClustersHelper do ...@@ -16,6 +16,8 @@ RSpec.describe ClustersHelper do
context 'with premium license' do context 'with premium license' do
before do before do
allow(Gitlab).to receive(:com?).and_return(false)
stub_licensed_features(cluster_agents: true) stub_licensed_features(cluster_agents: true)
end end
...@@ -33,13 +35,29 @@ RSpec.describe ClustersHelper do ...@@ -33,13 +35,29 @@ RSpec.describe ClustersHelper do
end end
end end
context 'when cluster_agent_list feature flag is disabled' do context 'GitLab.com' do
before do before do
stub_feature_flags(cluster_agent_list: false) allow(Gitlab).to receive(:com?).and_return(true)
end end
it 'does not allows agents to display' do context 'when kubernetes_agent_on_gitlab_com feature flag is disabled' do
expect(subject).to be_falsey before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: false)
end
it 'does not allows agents to display' do
expect(subject).to be_falsey
end
end
context 'kubernetes_agent_on_gitlab_com feature flag enabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: clusterable)
end
it 'allows agents to display' do
expect(subject).to be_truthy
end
end end
end end
end end
......
...@@ -27,7 +27,7 @@ module Gitlab ...@@ -27,7 +27,7 @@ module Gitlab
def included_in_gitlab_com_rollout?(project) def included_in_gitlab_com_rollout?(project)
return true unless ::Gitlab.com? return true unless ::Gitlab.com?
Feature.enabled?(:kubernetes_agent_on_gitlab_com, project) Feature.enabled?(:kubernetes_agent_on_gitlab_com, project, default_enabled: :yaml)
end end
end end
end end
......
...@@ -26554,6 +26554,9 @@ msgstr "" ...@@ -26554,6 +26554,9 @@ msgstr ""
msgid "Runners|Revision" msgid "Runners|Revision"
msgstr "" msgstr ""
msgid "Runners|Runner #%{runner_id}"
msgstr ""
msgid "Runners|Shared" msgid "Runners|Shared"
msgstr "" msgstr ""
......
...@@ -285,8 +285,16 @@ RSpec.describe "Admin Runners" do ...@@ -285,8 +285,16 @@ RSpec.describe "Admin Runners" do
end end
describe 'runner page breadcrumbs' do describe 'runner page breadcrumbs' do
it 'contains the current runner’s short sha' do it 'contains the current runner token' do
expect(page.find('h2')).to have_content(runner.short_sha) page.within '[data-testid="breadcrumb-links"]' do
expect(page.find('h2')).to have_content(runner.short_sha)
end
end
end
describe 'runner page title' do
it 'contains the runner id' do
expect(find('.page-title')).to have_content("Runner ##{runner.id}")
end end
end end
......
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