summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/registry/settings
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/registry/settings')
-rw-r--r--app/assets/javascripts/registry/settings/components/registry_settings_app.vue49
-rw-r--r--app/assets/javascripts/registry/settings/store/actions.js6
-rw-r--r--app/assets/javascripts/registry/settings/store/getters.js4
-rw-r--r--app/assets/javascripts/registry/settings/store/mutation_types.js1
-rw-r--r--app/assets/javascripts/registry/settings/store/mutations.js11
-rw-r--r--app/assets/javascripts/registry/settings/store/state.js16
6 files changed, 58 insertions, 29 deletions
diff --git a/app/assets/javascripts/registry/settings/components/registry_settings_app.vue b/app/assets/javascripts/registry/settings/components/registry_settings_app.vue
index 4d767f1a578..b4a59fd0178 100644
--- a/app/assets/javascripts/registry/settings/components/registry_settings_app.vue
+++ b/app/assets/javascripts/registry/settings/components/registry_settings_app.vue
@@ -1,5 +1,5 @@
<script>
-import { mapActions, mapState } from 'vuex';
+import { mapActions, mapGetters, mapState } from 'vuex';
import { GlAlert, GlSprintf, GlLink } from '@gitlab/ui';
import { s__ } from '~/locale';
@@ -15,8 +15,15 @@ export default {
GlLink,
},
i18n: {
- unavailableFeatureText: s__(
- 'ContainerRegistry|Currently, the Container Registry tag expiration feature is not available for projects created before GitLab version 12.8. For updates and more information, visit Issue %{linkStart}#196124%{linkEnd}',
+ unavailableFeatureTitle: s__(
+ `ContainerRegistry|Container Registry tag expiration and retention policy is disabled`,
+ ),
+ unavailableFeatureIntroText: s__(
+ `ContainerRegistry|The Container Registry tag expiration and retention policies for this project have not been enabled.`,
+ ),
+ unavailableUserFeatureText: s__(`ContainerRegistry|Please contact your administrator.`),
+ unavailableAdminFeatureText: s__(
+ `ContainerRegistry| Please visit the %{linkStart}administration settings%{linkEnd} to enable this feature.`,
),
fetchSettingsErrorText: FETCH_SETTINGS_ERROR_MESSAGE,
},
@@ -26,10 +33,19 @@ export default {
};
},
computed: {
- ...mapState(['isDisabled']),
+ ...mapState(['isAdmin', 'adminSettingsPath']),
+ ...mapGetters({ isDisabled: 'getIsDisabled' }),
showSettingForm() {
return !this.isDisabled && !this.fetchSettingsError;
},
+ showDisabledFormMessage() {
+ return this.isDisabled && !this.fetchSettingsError;
+ },
+ unavailableFeatureMessage() {
+ return this.isAdmin
+ ? this.$options.i18n.unavailableAdminFeatureText
+ : this.$options.i18n.unavailableUserFeatureText;
+ },
},
mounted() {
this.fetchSettings().catch(() => {
@@ -59,16 +75,21 @@ export default {
</ul>
<settings-form v-if="showSettingForm" />
<template v-else>
- <gl-alert v-if="isDisabled" :dismissible="false">
- <p>
- <gl-sprintf :message="$options.i18n.unavailableFeatureText">
- <template #link="{content}">
- <gl-link href="https://gitlab.com/gitlab-org/gitlab/issues/196124" target="_blank">
- {{ content }}
- </gl-link>
- </template>
- </gl-sprintf>
- </p>
+ <gl-alert
+ v-if="showDisabledFormMessage"
+ :dismissible="false"
+ :title="$options.i18n.unavailableFeatureTitle"
+ variant="tip"
+ >
+ {{ $options.i18n.unavailableFeatureIntroText }}
+
+ <gl-sprintf :message="unavailableFeatureMessage">
+ <template #link="{ content }">
+ <gl-link :href="adminSettingsPath" target="_blank">
+ {{ content }}
+ </gl-link>
+ </template>
+ </gl-sprintf>
</gl-alert>
<gl-alert v-else-if="fetchSettingsError" variant="warning" :dismissible="false">
<gl-sprintf :message="$options.i18n.fetchSettingsErrorText" />
diff --git a/app/assets/javascripts/registry/settings/store/actions.js b/app/assets/javascripts/registry/settings/store/actions.js
index d0379d05164..be1f62334fa 100644
--- a/app/assets/javascripts/registry/settings/store/actions.js
+++ b/app/assets/javascripts/registry/settings/store/actions.js
@@ -5,11 +5,7 @@ export const setInitialState = ({ commit }, data) => commit(types.SET_INITIAL_ST
export const updateSettings = ({ commit }, data) => commit(types.UPDATE_SETTINGS, data);
export const toggleLoading = ({ commit }) => commit(types.TOGGLE_LOADING);
export const receiveSettingsSuccess = ({ commit }, data) => {
- if (data) {
- commit(types.SET_SETTINGS, data);
- } else {
- commit(types.SET_IS_DISABLED, true);
- }
+ commit(types.SET_SETTINGS, data);
};
export const resetSettings = ({ commit }) => commit(types.RESET_SETTINGS);
diff --git a/app/assets/javascripts/registry/settings/store/getters.js b/app/assets/javascripts/registry/settings/store/getters.js
index 639becebeec..ef4b4f0ba02 100644
--- a/app/assets/javascripts/registry/settings/store/getters.js
+++ b/app/assets/javascripts/registry/settings/store/getters.js
@@ -19,3 +19,7 @@ export const getSettings = (state, getters) => ({
});
export const getIsEdited = state => !isEqual(state.original, state.settings);
+
+export const getIsDisabled = state => {
+ return !(state.original || state.enableHistoricEntries);
+};
diff --git a/app/assets/javascripts/registry/settings/store/mutation_types.js b/app/assets/javascripts/registry/settings/store/mutation_types.js
index 2d071567c1f..db499ffa761 100644
--- a/app/assets/javascripts/registry/settings/store/mutation_types.js
+++ b/app/assets/javascripts/registry/settings/store/mutation_types.js
@@ -3,4 +3,3 @@ export const UPDATE_SETTINGS = 'UPDATE_SETTINGS';
export const TOGGLE_LOADING = 'TOGGLE_LOADING';
export const SET_SETTINGS = 'SET_SETTINGS';
export const RESET_SETTINGS = 'RESET_SETTINGS';
-export const SET_IS_DISABLED = 'SET_IS_DISABLED';
diff --git a/app/assets/javascripts/registry/settings/store/mutations.js b/app/assets/javascripts/registry/settings/store/mutations.js
index f562137db1a..bb7071b020b 100644
--- a/app/assets/javascripts/registry/settings/store/mutations.js
+++ b/app/assets/javascripts/registry/settings/store/mutations.js
@@ -1,3 +1,4 @@
+import { parseBoolean } from '~/lib/utils/common_utils';
import * as types from './mutation_types';
export default {
@@ -8,19 +9,19 @@ export default {
keepN: JSON.parse(initialState.keepNOptions),
olderThan: JSON.parse(initialState.olderThanOptions),
};
+ state.enableHistoricEntries = parseBoolean(initialState.enableHistoricEntries);
+ state.isAdmin = parseBoolean(initialState.isAdmin);
+ state.adminSettingsPath = initialState.adminSettingsPath;
},
[types.UPDATE_SETTINGS](state, data) {
state.settings = { ...state.settings, ...data.settings };
},
[types.SET_SETTINGS](state, settings) {
- state.settings = settings;
+ state.settings = settings ?? state.settings;
state.original = Object.freeze(settings);
},
- [types.SET_IS_DISABLED](state, isDisabled) {
- state.isDisabled = isDisabled;
- },
[types.RESET_SETTINGS](state) {
- state.settings = { ...state.original };
+ state.settings = Object.assign({}, state.original);
},
[types.TOGGLE_LOADING](state) {
state.isLoading = !state.isLoading;
diff --git a/app/assets/javascripts/registry/settings/store/state.js b/app/assets/javascripts/registry/settings/store/state.js
index 582e18e5465..fccc0991c1c 100644
--- a/app/assets/javascripts/registry/settings/store/state.js
+++ b/app/assets/javascripts/registry/settings/store/state.js
@@ -8,9 +8,17 @@ export default () => ({
*/
isLoading: false,
/*
- * Boolean to determine if the user is allowed to interact with the form
+ * Boolean to determine if the user is an admin
*/
- isDisabled: false,
+ isAdmin: false,
+ /*
+ * String containing the full path to the admin config page for CI/CD
+ */
+ adminSettingsPath: '',
+ /*
+ * Boolean to determine if project created before 12.8 can use this feature
+ */
+ enableHistoricEntries: false,
/*
* This contains the data shown and manipulated in the UI
* Has the following structure:
@@ -24,9 +32,9 @@ export default () => ({
*/
settings: {},
/*
- * Same structure as settings, above but Frozen object and used only in case the user clicks 'cancel'
+ * Same structure as settings, above but Frozen object and used only in case the user clicks 'cancel', initialized to null
*/
- original: {},
+ original: null,
/*
* Contains the options used to populate the form selects
*/