Commit 6b8e175b authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '199998-container-expiration-policy-settings-hide-form-on-api-error-2' into 'master'

Container expiration policy settings hide form on API error

See merge request gitlab-org/gitlab!26303
parents 92ebf963 b3fd4581
...@@ -18,14 +18,23 @@ export default { ...@@ -18,14 +18,23 @@ export default {
unavailableFeatureText: s__( 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}', '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}',
), ),
fetchSettingsErrorText: FETCH_SETTINGS_ERROR_MESSAGE,
},
data() {
return {
fetchSettingsError: false,
};
}, },
computed: { computed: {
...mapState(['isDisabled']), ...mapState(['isDisabled']),
showSettingForm() {
return !this.isDisabled && !this.fetchSettingsError;
},
}, },
mounted() { mounted() {
this.fetchSettings().catch(() => this.fetchSettings().catch(() => {
this.$toast.show(FETCH_SETTINGS_ERROR_MESSAGE, { type: 'error' }), this.fetchSettingsError = true;
); });
}, },
methods: { methods: {
...mapActions(['fetchSettings']), ...mapActions(['fetchSettings']),
...@@ -48,17 +57,22 @@ export default { ...@@ -48,17 +57,22 @@ export default {
}} }}
</li> </li>
</ul> </ul>
<settings-form v-if="!isDisabled" /> <settings-form v-if="showSettingForm" />
<gl-alert v-else :dismissible="false"> <template v-else>
<p> <gl-alert v-if="isDisabled" :dismissible="false">
<gl-sprintf :message="$options.i18n.unavailableFeatureText"> <p>
<template #link="{content}"> <gl-sprintf :message="$options.i18n.unavailableFeatureText">
<gl-link href="https://gitlab.com/gitlab-org/gitlab/issues/196124" target="_blank"> <template #link="{content}">
{{ content }} <gl-link href="https://gitlab.com/gitlab-org/gitlab/issues/196124" target="_blank">
</gl-link> {{ content }}
</template> </gl-link>
</gl-sprintf> </template>
</p> </gl-sprintf>
</gl-alert> </p>
</gl-alert>
<gl-alert v-else-if="fetchSettingsError" variant="warning" :dismissible="false">
<gl-sprintf :message="$options.i18n.fetchSettingsErrorText" />
</gl-alert>
</template>
</div> </div>
</template> </template>
---
title: Container expiration policy settings hide form on API error
merge_request: 26303
author:
type: fixed
...@@ -44,15 +44,6 @@ describe('Registry Settings App', () => { ...@@ -44,15 +44,6 @@ describe('Registry Settings App', () => {
expect(store.dispatch).toHaveBeenCalledWith('fetchSettings'); expect(store.dispatch).toHaveBeenCalledWith('fetchSettings');
}); });
it('show a toast if fetchSettings fails', () => {
mountComponent({ dispatchMock: 'mockRejectedValue' });
return wrapper.vm.$nextTick().then(() =>
expect(wrapper.vm.$toast.show).toHaveBeenCalledWith(FETCH_SETTINGS_ERROR_MESSAGE, {
type: 'error',
}),
);
});
it('renders the setting form', () => { it('renders the setting form', () => {
mountComponent(); mountComponent();
expect(findSettingsComponent().exists()).toBe(true); expect(findSettingsComponent().exists()).toBe(true);
...@@ -68,7 +59,23 @@ describe('Registry Settings App', () => { ...@@ -68,7 +59,23 @@ describe('Registry Settings App', () => {
}); });
it('shows an alert', () => { it('shows an alert', () => {
expect(findAlert().exists()).toBe(true); expect(findAlert().html()).toContain(
'Currently, the Container Registry tag expiration feature is not available',
);
});
});
describe('fetchSettingsError', () => {
beforeEach(() => {
mountComponent({ dispatchMock: 'mockRejectedValue' });
});
it('the form is hidden', () => {
expect(findSettingsComponent().exists()).toBe(false);
});
it('shows an alert', () => {
expect(findAlert().html()).toContain(FETCH_SETTINGS_ERROR_MESSAGE);
}); });
}); });
}); });
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