Commit d379eeed authored by Fernando's avatar Fernando

Address maintainer feedback

* Run linters and prettify code
parent 5c356b7a
<script> <script>
import { GlButton, GlModal, GlModalDirective } from '@gitlab/ui'; import { GlButton, GlModal, GlModalDirective, GlSprintf } from '@gitlab/ui';
import CorpusUploadForm from 'ee/security_configuration/corpus_management/components/corpus_upload_form.vue';
import { numberToHumanSize } from '~/lib/utils/number_utils'; import { numberToHumanSize } from '~/lib/utils/number_utils';
import { s__ } from '~/locale'; import { s__, __ } from '~/locale';
import addCorpusMutation from '../graphql/mutations/add_corpus.mutation.graphql'; import addCorpusMutation from '../graphql/mutations/add_corpus.mutation.graphql';
import resetCorpus from '../graphql/mutations/reset_corpus.mutation.graphql'; import resetCorpus from '../graphql/mutations/reset_corpus.mutation.graphql';
import getCorpusesQuery from '../graphql/queries/get_corpuses.query.graphql'; import getCorpusesQuery from '../graphql/queries/get_corpuses.query.graphql';
import CorpusUploadForm from './corpus_upload_form.vue';
export default { export default {
components: { components: {
GlSprintf,
GlButton, GlButton,
GlModal, GlModal,
CorpusUploadForm, CorpusUploadForm,
...@@ -17,7 +18,7 @@ export default { ...@@ -17,7 +18,7 @@ export default {
GlModalDirective, GlModalDirective,
}, },
i18n: { i18n: {
totalSize: s__('CorpusManagement|Total Size:'), totalSize: s__('CorpusManagement|Total Size: %{totalSize}'),
newUpload: s__('CorpusManagement|New upload'), newUpload: s__('CorpusManagement|New upload'),
newCorpus: s__('CorpusMnagement|New corpus'), newCorpus: s__('CorpusMnagement|New corpus'),
}, },
...@@ -31,14 +32,14 @@ export default { ...@@ -31,14 +32,14 @@ export default {
...this.cursor, ...this.cursor,
}; };
}, },
update: (data) => { update(data) {
return data; return data;
}, },
}, },
}, },
modal: { modal: {
actionCancel: { actionCancel: {
text: s__('Cancel'), text: __('Cancel'),
}, },
modalId: 'corpus-upload-modal', modalId: 'corpus-upload-modal',
}, },
...@@ -60,7 +61,7 @@ export default { ...@@ -60,7 +61,7 @@ export default {
}, },
actionPrimaryProps() { actionPrimaryProps() {
return { return {
text: s__('Add'), text: __('Add'),
attributes: { attributes: {
'data-testid': 'modal-confirm', 'data-testid': 'modal-confirm',
disabled: !this.isUploaded, disabled: !this.isUploaded,
...@@ -90,8 +91,11 @@ export default { ...@@ -90,8 +91,11 @@ export default {
class="gl-h-11 gl-bg-gray-10 gl-display-flex gl-justify-content-space-between gl-align-items-center" class="gl-h-11 gl-bg-gray-10 gl-display-flex gl-justify-content-space-between gl-align-items-center"
> >
<div class="gl-ml-5"> <div class="gl-ml-5">
{{ s__('CorpusManagement|Total Size:') }} <gl-sprintf :message="$options.i18n.totalSize">
<template #totalSize>
<span class="gl-font-weight-bold">{{ formattedFileSize }}</span> <span class="gl-font-weight-bold">{{ formattedFileSize }}</span>
</template>
</gl-sprintf>
</div> </div>
<gl-button v-gl-modal-directive="$options.modal.modalId" class="gl-mr-5" variant="confirm"> <gl-button v-gl-modal-directive="$options.modal.modalId" class="gl-mr-5" variant="confirm">
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
GlLoadingIcon, GlLoadingIcon,
GlFormGroup, GlFormGroup,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { s__, __ } from '~/locale'; import { s__, __, sprintf } from '~/locale';
import { VALID_CORPUS_MIMETYPE } from '../constants'; import { VALID_CORPUS_MIMETYPE } from '../constants';
import resetCorpus from '../graphql/mutations/reset_corpus.mutation.graphql'; import resetCorpus from '../graphql/mutations/reset_corpus.mutation.graphql';
import uploadCorpus from '../graphql/mutations/upload_corpus.mutation.graphql'; import uploadCorpus from '../graphql/mutations/upload_corpus.mutation.graphql';
...@@ -38,7 +38,7 @@ export default { ...@@ -38,7 +38,7 @@ export default {
projectPath: this.projectFullPath, projectPath: this.projectFullPath,
}; };
}, },
update: (data) => { update(data) {
return data; return data;
}, },
error() { error() {
...@@ -79,6 +79,9 @@ export default { ...@@ -79,6 +79,9 @@ export default {
progress() { progress() {
return this.states?.uploadState.progress; return this.states?.uploadState.progress;
}, },
progressText() {
return sprintf(__('Attaching File - %{progress}'), { progress: `${this.progress}%` });
},
}, },
beforeDestroy() { beforeDestroy() {
this.resetAttachment(); this.resetAttachment();
...@@ -104,8 +107,7 @@ export default { ...@@ -104,8 +107,7 @@ export default {
this.$refs.fileUpload.click(); this.$refs.fileUpload.click();
}, },
beginFileUpload() { beginFileUpload() {
const uploadCallback = this.beginFileUpload; // const component = this;
const component = this;
// Simulate incrementing file upload progress // Simulate incrementing file upload progress
return this.$apollo return this.$apollo
.mutate({ .mutate({
...@@ -114,8 +116,8 @@ export default { ...@@ -114,8 +116,8 @@ export default {
}) })
.then(({ data }) => { .then(({ data }) => {
if (data.uploadCorpus < 100) { if (data.uploadCorpus < 100) {
component.uploadTimeout = setTimeout(() => { this.uploadTimeout = setTimeout(() => {
uploadCallback(); this.beginFileUpload();
}, 500); }, 500);
} }
}); });
...@@ -198,7 +200,7 @@ export default { ...@@ -198,7 +200,7 @@ export default {
<div v-if="isUploading" data-testid="upload-status" class="gl-mt-2"> <div v-if="isUploading" data-testid="upload-status" class="gl-mt-2">
<gl-loading-icon inline size="sm" /> <gl-loading-icon inline size="sm" />
{{ sprintf(__('Attaching File - %{progress}%'), { progress }) }} {{ progressText }}
<gl-button size="small" @click="cancelUpload"> {{ __('Cancel') }} </gl-button> <gl-button size="small" @click="cancelUpload"> {{ __('Cancel') }} </gl-button>
</div> </div>
</gl-form> </gl-form>
......
...@@ -19,7 +19,6 @@ const mockResolver = { ...@@ -19,7 +19,6 @@ const mockResolver = {
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
mockedPackages(_, { projectPath }) { mockedPackages(_, { projectPath }) {
return { return {
// Mocked data goes here
totalSize: mockTotalSize(), totalSize: mockTotalSize(),
data: mockData(), data: mockData(),
__typename: 'MockedPackages', __typename: 'MockedPackages',
...@@ -44,11 +43,9 @@ describe('Corpus upload modal', () => { ...@@ -44,11 +43,9 @@ describe('Corpus upload modal', () => {
const findUploadCorpus = () => wrapper.find('[data-testid="upload-corpus"]'); const findUploadCorpus = () => wrapper.find('[data-testid="upload-corpus"]');
const findUploadStatus = () => wrapper.find('[data-testid="upload-status"]'); const findUploadStatus = () => wrapper.find('[data-testid="upload-status"]');
function createMockApolloProvider(resolverMock) { const createMockApolloProvider = (resolverMock) => {
localVue.use(VueApollo);
return createMockApollo([], resolverMock); return createMockApollo([], resolverMock);
} };
const createComponent = (resolverMock, options = {}) => { const createComponent = (resolverMock, options = {}) => {
wrapper = mount(CorpusUploadForm, { wrapper = mount(CorpusUploadForm, {
......
...@@ -4352,7 +4352,7 @@ msgstr "" ...@@ -4352,7 +4352,7 @@ msgstr ""
msgid "Attach a file by drag &amp; drop or %{upload_link}" msgid "Attach a file by drag &amp; drop or %{upload_link}"
msgstr "" msgstr ""
msgid "Attaching File - %{progress}%" msgid "Attaching File - %{progress}"
msgstr "" msgstr ""
msgid "Attaching a file" msgid "Attaching a file"
...@@ -8843,7 +8843,7 @@ msgstr "" ...@@ -8843,7 +8843,7 @@ msgstr ""
msgid "CorpusManagement|Target" msgid "CorpusManagement|Target"
msgstr "" msgstr ""
msgid "CorpusManagement|Total Size:" msgid "CorpusManagement|Total Size: %{totalSize}"
msgstr "" msgstr ""
msgid "CorpusMnagement|New corpus" msgid "CorpusMnagement|New corpus"
......
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