diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-09 12:09:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-09 12:09:19 +0300 |
commit | e7462f7b49a60b2ee7be14682c23190f7f7c5ba7 (patch) | |
tree | 3437f7c7c7931ff2e017de00e69dea10f3d00b57 /app/assets/javascripts/artifacts_settings | |
parent | 43d38aaae05e2ac7e84c035c50844e084c3e54d3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/artifacts_settings')
2 files changed, 42 insertions, 18 deletions
diff --git a/app/assets/javascripts/artifacts_settings/graphql/queries/get_keep_latest_artifact_application_setting.query.graphql b/app/assets/javascripts/artifacts_settings/graphql/queries/get_keep_latest_artifact_application_setting.query.graphql new file mode 100644 index 00000000000..9d833d81a3f --- /dev/null +++ b/app/assets/javascripts/artifacts_settings/graphql/queries/get_keep_latest_artifact_application_setting.query.graphql @@ -0,0 +1,5 @@ +query getKeepLatestArtifactApplicationSetting { + ciApplicationSettings { + keepLatestArtifact + } +} diff --git a/app/assets/javascripts/artifacts_settings/keep_latest_artifact_checkbox.vue b/app/assets/javascripts/artifacts_settings/keep_latest_artifact_checkbox.vue index 5684033f3af..a0cf91bbe7a 100644 --- a/app/assets/javascripts/artifacts_settings/keep_latest_artifact_checkbox.vue +++ b/app/assets/javascripts/artifacts_settings/keep_latest_artifact_checkbox.vue @@ -2,12 +2,22 @@ import { GlAlert, GlFormCheckbox, GlLink } from '@gitlab/ui'; import { __ } from '~/locale'; import GetKeepLatestArtifactProjectSetting from './graphql/queries/get_keep_latest_artifact_project_setting.query.graphql'; +import GetKeepLatestArtifactApplicationSetting from './graphql/queries/get_keep_latest_artifact_application_setting.query.graphql'; import UpdateKeepLatestArtifactProjectSetting from './graphql/mutations/update_keep_latest_artifact_project_setting.mutation.graphql'; -const FETCH_ERROR = __('There was a problem fetching the keep latest artifact setting.'); -const UPDATE_ERROR = __('There was a problem updating the keep latest artifact setting.'); - export default { + errors: { + fetchError: __('There was a problem fetching the keep latest artifacts setting.'), + updateError: __('There was a problem updating the keep latest artifacts setting.'), + }, + i18n: { + 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'), + }, components: { GlAlert, GlFormCheckbox, @@ -33,21 +43,33 @@ export default { return data.project?.ciCdSettings?.keepLatestArtifact; }, error() { - this.reportError(FETCH_ERROR); + this.reportError(this.$options.errors.fetchError); + }, + }, + projectSettingDisabled: { + query: GetKeepLatestArtifactApplicationSetting, + update(data) { + return !data.ciApplicationSettings?.keepLatestArtifact; }, }, }, data() { return { - keepLatestArtifact: true, + keepLatestArtifact: null, errorMessage: '', isAlertDismissed: false, + projectSettingDisabled: true, }; }, computed: { shouldShowAlert() { return this.errorMessage && !this.isAlertDismissed; }, + helpText() { + return this.projectSettingDisabled + ? this.$options.i18n.disabledHelpText + : this.$options.i18n.enabledHelpText; + }, }, methods: { reportError(error) { @@ -65,10 +87,10 @@ export default { }); if (data.ciCdSettingsUpdate.errors.length) { - this.reportError(UPDATE_ERROR); + this.reportError(this.$options.errors.updateError); } } catch (error) { - this.reportError(UPDATE_ERROR); + this.reportError(this.$options.errors.updateError); } }, }, @@ -84,16 +106,13 @@ export default { @dismiss="isAlertDismissed = true" >{{ errorMessage }}</gl-alert > - <gl-form-checkbox v-model="keepLatestArtifact" @change="updateSetting" - ><b class="gl-mr-3">{{ __('Keep artifacts from most recent successful jobs') }}</b> - <gl-link :href="helpPagePath">{{ __('More information') }}</gl-link></gl-form-checkbox - > - <p> - {{ - __( - 'The latest artifacts created by jobs in the most recent successful pipeline will be stored.', - ) - }} - </p> + <gl-form-checkbox + v-model="keepLatestArtifact" + :disabled="projectSettingDisabled" + @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> + </gl-form-checkbox> </div> </template> |