Commit 883854ad authored by Miguel Rincon's avatar Miguel Rincon

Merge branch 'fix-keep-artifacts-project-setting' into 'master'

Fix: keep latest artifacts checkbox shows always disabled

See merge request gitlab-org/gitlab!54669
parents 928b0c26 034d543b
......@@ -2,7 +2,6 @@
import { GlAlert, GlFormCheckbox, GlLink } from '@gitlab/ui';
import { __ } from '~/locale';
import UpdateKeepLatestArtifactProjectSetting from './graphql/mutations/update_keep_latest_artifact_project_setting.mutation.graphql';
import GetKeepLatestArtifactApplicationSetting from './graphql/queries/get_keep_latest_artifact_application_setting.query.graphql';
import GetKeepLatestArtifactProjectSetting from './graphql/queries/get_keep_latest_artifact_project_setting.query.graphql';
export default {
......@@ -14,7 +13,6 @@ export default {
enabledHelpText: __(
'The latest artifacts created by jobs in the most recent successful pipeline will be stored.',
),
disabledHelpText: __('This feature is disabled at the instance level.'),
helpLinkText: __('More information'),
checkboxText: __('Keep artifacts from most recent successful jobs'),
},
......@@ -46,19 +44,12 @@ export default {
this.reportError(this.$options.errors.fetchError);
},
},
projectSettingDisabled: {
query: GetKeepLatestArtifactApplicationSetting,
update(data) {
return !data.ciApplicationSettings?.keepLatestArtifact;
},
},
},
data() {
return {
keepLatestArtifact: null,
errorMessage: '',
isAlertDismissed: false,
projectSettingDisabled: true,
};
},
computed: {
......@@ -66,9 +57,7 @@ export default {
return this.errorMessage && !this.isAlertDismissed;
},
helpText() {
return this.projectSettingDisabled
? this.$options.i18n.disabledHelpText
: this.$options.i18n.enabledHelpText;
return this.$options.i18n.enabledHelpText;
},
},
methods: {
......@@ -106,10 +95,7 @@ export default {
@dismiss="isAlertDismissed = true"
>{{ errorMessage }}</gl-alert
>
<gl-form-checkbox
v-model="keepLatestArtifact"
:disabled="projectSettingDisabled"
@change="updateSetting"
<gl-form-checkbox v-model="keepLatestArtifact" @change="updateSetting"
><strong class="gl-mr-3">{{ $options.i18n.checkboxText }}</strong>
<gl-link :href="helpPagePath">{{ $options.i18n.helpLinkText }}</gl-link>
<template v-if="!$apollo.loading" #help>{{ helpText }}</template>
......
......@@ -47,16 +47,17 @@
.settings-content
= render 'projects/runners/index'
%section.settings.no-animate#js-artifacts-settings{ class: ('expanded' if expanded) }
.settings-header
%h4
= _("Artifacts")
%button.btn.gl-button.btn-default.js-settings-toggle{ type: 'button' }
= expanded ? _('Collapse') : _('Expand')
%p
= _("A job artifact is an archive of files and directories saved by a job when it finishes.")
.settings-content
#js-artifacts-settings-app{ data: { full_path: @project.full_path, help_page_path: help_page_path('ci/pipelines/job_artifacts', anchor: 'keep-artifacts-from-most-recent-successful-jobs') } }
- if Gitlab::CurrentSettings.current_application_settings.keep_latest_artifact?
%section.settings.no-animate#js-artifacts-settings{ class: ('expanded' if expanded) }
.settings-header
%h4
= _("Artifacts")
%button.btn.gl-button.btn-default.js-settings-toggle{ type: 'button' }
= expanded ? _('Collapse') : _('Expand')
%p
= _("A job artifact is an archive of files and directories saved by a job when it finishes.")
.settings-content
#js-artifacts-settings-app{ data: { full_path: @project.full_path, help_page_path: help_page_path('ci/pipelines/job_artifacts', anchor: 'keep-artifacts-from-most-recent-successful-jobs') } }
%section.qa-variables-settings.settings.no-animate#js-cicd-variables-settings{ class: ('expanded' if expanded), data: { qa_selector: 'variables_settings_content' } }
.settings-header
......
---
title: Fix keep latest artifacts checkbox being always disabled
merge_request: 54669
author:
type: fixed
......@@ -30054,9 +30054,6 @@ msgstr ""
msgid "This epic does not exist or you don't have sufficient permission."
msgstr ""
msgid "This feature is disabled at the instance level."
msgstr ""
msgid "This feature requires local storage to be enabled"
msgstr ""
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Keep latest artifact checkbox when application keep latest artifact setting is disabled checkbox is disabled when application setting is disabled 1`] = `
<div>
<!---->
<b-form-checkbox-stub
checked="true"
class="gl-form-checkbox"
disabled="true"
plain="true"
value="true"
>
<strong
class="gl-mr-3"
>
Keep artifacts from most recent successful jobs
</strong>
<gl-link-stub
href="/help/ci/pipelines/job_artifacts"
>
More information
</gl-link-stub>
<p
class="help-text"
>
This feature is disabled at the instance level.
</p>
</b-form-checkbox-stub>
</div>
`;
exports[`Keep latest artifact checkbox when application keep latest artifact setting is enabled sets correct setting value in checkbox with query result 1`] = `
<div>
<!---->
......
......@@ -120,23 +120,4 @@ describe('Keep latest artifact checkbox', () => {
expect(findCheckbox().attributes('disabled')).toBeUndefined();
});
});
describe('when application keep latest artifact setting is disabled', () => {
it('checkbox is disabled when application setting is disabled', async () => {
createComponent({
keepLatestArtifactApplicationQueryHandler: jest.fn().mockResolvedValue({
data: {
ciApplicationSettings: {
keepLatestArtifact: false,
},
},
}),
});
await wrapper.vm.$nextTick();
expect(wrapper.element).toMatchSnapshot();
expect(findCheckbox().attributes('disabled')).toBe('true');
});
});
});
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