Commit 399cc167 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '207322-remove-eslint-disable' into 'master'

Remove eslint-disable for application row component

Closes #207322

See merge request gitlab-org/gitlab!33940
parents a1115792 5cd549d6
<script> <script>
/* eslint-disable vue/require-default-prop */ import { GlLink, GlModalDirective, GlSprintf } from '@gitlab/ui';
/* eslint-disable @gitlab/vue-require-i18n-strings */
import { GlLink, GlModalDirective } from '@gitlab/ui';
import { s__, __, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import identicon from '../../vue_shared/components/identicon.vue'; import identicon from '../../vue_shared/components/identicon.vue';
...@@ -17,6 +15,7 @@ export default { ...@@ -17,6 +15,7 @@ export default {
loadingButton, loadingButton,
identicon, identicon,
GlLink, GlLink,
GlSprintf,
UninstallApplicationButton, UninstallApplicationButton,
UninstallApplicationConfirmationModal, UninstallApplicationConfirmationModal,
UpdateApplicationConfirmationModal, UpdateApplicationConfirmationModal,
...@@ -36,15 +35,17 @@ export default { ...@@ -36,15 +35,17 @@ export default {
titleLink: { titleLink: {
type: String, type: String,
required: false, required: false,
default: '',
}, },
manageLink: { manageLink: {
type: String, type: String,
required: false, required: false,
default: '',
}, },
logoUrl: { logoUrl: {
type: String, type: String,
required: false, required: false,
default: null, default: '',
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
...@@ -59,14 +60,17 @@ export default { ...@@ -59,14 +60,17 @@ export default {
status: { status: {
type: String, type: String,
required: false, required: false,
default: '',
}, },
statusReason: { statusReason: {
type: String, type: String,
required: false, required: false,
default: '',
}, },
requestReason: { requestReason: {
type: String, type: String,
required: false, required: false,
default: '',
}, },
installed: { installed: {
type: Boolean, type: Boolean,
...@@ -81,14 +85,17 @@ export default { ...@@ -81,14 +85,17 @@ export default {
installedVia: { installedVia: {
type: String, type: String,
required: false, required: false,
default: '',
}, },
version: { version: {
type: String, type: String,
required: false, required: false,
default: '',
}, },
chartRepo: { chartRepo: {
type: String, type: String,
required: false, required: false,
default: '',
}, },
updateAvailable: { updateAvailable: {
type: Boolean, type: Boolean,
...@@ -206,15 +213,6 @@ export default { ...@@ -206,15 +213,6 @@ export default {
return sprintf(errorDescription, { title: this.title }); return sprintf(errorDescription, { title: this.title });
}, },
versionLabel() {
if (this.updateFailed) {
return __('Update failed');
} else if (this.isUpdating) {
return __('Updating');
}
return this.updateSuccessful ? __('Updated to') : __('Updated');
},
updateFailureDescription() { updateFailureDescription() {
return s__('ClusterIntegration|Update failed. Please check the logs and try again.'); return s__('ClusterIntegration|Update failed. Please check the logs and try again.');
}, },
...@@ -365,14 +363,20 @@ export default { ...@@ -365,14 +363,20 @@ export default {
v-if="shouldShowUpdateDetails" v-if="shouldShowUpdateDetails"
class="form-text text-muted label p-0 js-cluster-application-update-details" class="form-text text-muted label p-0 js-cluster-application-update-details"
> >
{{ versionLabel }} <template v-if="updateFailed">{{ __('Update failed') }}</template>
<template v-else-if="isUpdating">{{ __('Updating') }}</template>
<template v-else>
<gl-sprintf :message="__('Updated to %{linkStart}chart v%{linkEnd}')">
<template #link="{ content }">
<gl-link <gl-link
v-if="updateSuccessful"
:href="chartRepo" :href="chartRepo"
target="_blank" target="_blank"
class="js-cluster-application-update-version" class="js-cluster-application-update-version"
>chart v{{ version }}</gl-link >{{ content }}{{ version }}</gl-link
> >
</template>
</gl-sprintf>
</template>
</div> </div>
<div <div
......
...@@ -23999,7 +23999,7 @@ msgstr "" ...@@ -23999,7 +23999,7 @@ msgstr ""
msgid "Updated at" msgid "Updated at"
msgstr "" msgstr ""
msgid "Updated to" msgid "Updated to %{linkStart}chart v%{linkEnd}"
msgstr "" msgstr ""
msgid "Updating" msgid "Updating"
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlSprintf } from '@gitlab/ui';
import eventHub from '~/clusters/event_hub'; import eventHub from '~/clusters/event_hub';
import { APPLICATION_STATUS, ELASTIC_STACK } from '~/clusters/constants'; import { APPLICATION_STATUS, ELASTIC_STACK } from '~/clusters/constants';
import ApplicationRow from '~/clusters/components/application_row.vue'; import ApplicationRow from '~/clusters/components/application_row.vue';
...@@ -16,6 +17,7 @@ describe('Application Row', () => { ...@@ -16,6 +17,7 @@ describe('Application Row', () => {
const mountComponent = data => { const mountComponent = data => {
wrapper = shallowMount(ApplicationRow, { wrapper = shallowMount(ApplicationRow, {
stubs: { GlSprintf },
propsData: { propsData: {
...DEFAULT_APPLICATION_STATE, ...DEFAULT_APPLICATION_STATE,
...data, ...data,
...@@ -356,6 +358,9 @@ describe('Application Row', () => { ...@@ -356,6 +358,9 @@ describe('Application Row', () => {
}); });
describe('Version', () => { describe('Version', () => {
const updateDetails = () => wrapper.find('.js-cluster-application-update-details');
const versionEl = () => wrapper.find('.js-cluster-application-update-version');
it('displays a version number if application has been updated', () => { it('displays a version number if application has been updated', () => {
const version = '0.1.45'; const version = '0.1.45';
mountComponent({ mountComponent({
...@@ -363,12 +368,8 @@ describe('Application Row', () => { ...@@ -363,12 +368,8 @@ describe('Application Row', () => {
updateSuccessful: true, updateSuccessful: true,
version, version,
}); });
const updateDetails = wrapper.find('.js-cluster-application-update-details');
const versionEl = wrapper.find('.js-cluster-application-update-version');
expect(updateDetails.text()).toContain('Updated'); expect(updateDetails().text()).toBe(`Updated to chart v${version}`);
expect(versionEl.exists()).toBe(true);
expect(versionEl.text()).toContain(version);
}); });
it('contains a link to the chart repo if application has been updated', () => { it('contains a link to the chart repo if application has been updated', () => {
...@@ -380,10 +381,9 @@ describe('Application Row', () => { ...@@ -380,10 +381,9 @@ describe('Application Row', () => {
chartRepo, chartRepo,
version, version,
}); });
const versionEl = wrapper.find('.js-cluster-application-update-version');
expect(versionEl.attributes('href')).toEqual(chartRepo); expect(versionEl().attributes('href')).toEqual(chartRepo);
expect(versionEl.props('target')).toEqual('_blank'); expect(versionEl().props('target')).toEqual('_blank');
}); });
it('does not display a version number if application update failed', () => { it('does not display a version number if application update failed', () => {
...@@ -393,11 +393,20 @@ describe('Application Row', () => { ...@@ -393,11 +393,20 @@ describe('Application Row', () => {
updateFailed: true, updateFailed: true,
version, version,
}); });
const updateDetails = wrapper.find('.js-cluster-application-update-details');
const versionEl = wrapper.find('.js-cluster-application-update-version');
expect(updateDetails.text()).toContain('failed'); expect(updateDetails().text()).toBe('Update failed');
expect(versionEl.exists()).toBe(false); expect(versionEl().exists()).toBe(false);
});
it('displays updating when the application update is currently updating', () => {
mountComponent({
status: APPLICATION_STATUS.UPDATING,
updateSuccessful: true,
version: '1.2.3',
});
expect(updateDetails().text()).toBe('Updating');
expect(versionEl().exists()).toBe(false);
}); });
}); });
......
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