Commit e5f90e5b authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '246743-update-instances-of-deprecatedcreateflash-with-new-createflash' into 'master'

Update instances of deprecatedCreateFlash with new createFlash

See merge request gitlab-org/gitlab!46123
parents 38fe0e17 64ff088f
<script> <script>
import { GlIcon, GlLink, GlSprintf } from '@gitlab/ui'; import { GlIcon, GlLink, GlSprintf } from '@gitlab/ui';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import uploadDesignMutation from '../../graphql/mutations/upload_design.mutation.graphql'; import uploadDesignMutation from '../../graphql/mutations/upload_design.mutation.graphql';
import { UPLOAD_DESIGN_INVALID_FILETYPE_ERROR } from '../../utils/error_messages'; import { UPLOAD_DESIGN_INVALID_FILETYPE_ERROR } from '../../utils/error_messages';
import { isValidDesignFile } from '../../utils/design_management_utils'; import { isValidDesignFile } from '../../utils/design_management_utils';
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
const { files } = dataTransfer; const { files } = dataTransfer;
if (!this.isValidUpload(Array.from(files))) { if (!this.isValidUpload(Array.from(files))) {
createFlash(UPLOAD_DESIGN_INVALID_FILETYPE_ERROR); createFlash({ message: UPLOAD_DESIGN_INVALID_FILETYPE_ERROR });
return; return;
} }
......
import { propertyOf } from 'lodash'; import { propertyOf } from 'lodash';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash, { FLASH_TYPES } from '~/flash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import getDesignListQuery from '../graphql/queries/get_design_list.query.graphql'; import getDesignListQuery from '../graphql/queries/get_design_list.query.graphql';
import allVersionsMixin from './all_versions'; import allVersionsMixin from './all_versions';
...@@ -36,20 +36,20 @@ export default { ...@@ -36,20 +36,20 @@ export default {
}, },
result() { result() {
if (this.$route.query.version && !this.hasValidVersion) { if (this.$route.query.version && !this.hasValidVersion) {
createFlash( createFlash({
s__( message: s__(
'DesignManagement|Requested design version does not exist. Showing latest version instead', 'DesignManagement|Requested design version does not exist. Showing latest version instead',
), ),
); });
this.$router.replace({ name: DESIGNS_ROUTE_NAME, query: { version: undefined } }); this.$router.replace({ name: DESIGNS_ROUTE_NAME, query: { version: undefined } });
} }
if (this.designCollection.copyState === 'ERROR') { if (this.designCollection.copyState === 'ERROR') {
createFlash( createFlash({
s__( message: s__(
'DesignManagement|There was an error moving your designs. Please upload your designs below.', 'DesignManagement|There was an error moving your designs. Please upload your designs below.',
), ),
'warning', type: FLASH_TYPES.WARNING,
); });
} }
}, },
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import Mousetrap from 'mousetrap'; import Mousetrap from 'mousetrap';
import { GlLoadingIcon, GlAlert } from '@gitlab/ui'; import { GlLoadingIcon, GlAlert } from '@gitlab/ui';
import { ApolloMutation } from 'vue-apollo'; import { ApolloMutation } from 'vue-apollo';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { fetchPolicies } from '~/lib/graphql'; import { fetchPolicies } from '~/lib/graphql';
import allVersionsMixin from '../../mixins/all_versions'; import allVersionsMixin from '../../mixins/all_versions';
import Toolbar from '../../components/toolbar/index.vue'; import Toolbar from '../../components/toolbar/index.vue';
...@@ -230,7 +230,7 @@ export default { ...@@ -230,7 +230,7 @@ export default {
onQueryError(message) { onQueryError(message) {
// because we redirect user to /designs (the issue page), // because we redirect user to /designs (the issue page),
// we want to create these flashes on the issue page // we want to create these flashes on the issue page
createFlash(message); createFlash({ message });
this.$router.push({ name: this.$options.DESIGNS_ROUTE_NAME }); this.$router.push({ name: this.$options.DESIGNS_ROUTE_NAME });
}, },
onError(message, e) { onError(message, e) {
......
<script> <script>
import { GlLoadingIcon, GlButton, GlAlert } from '@gitlab/ui'; import { GlLoadingIcon, GlButton, GlAlert } from '@gitlab/ui';
import VueDraggable from 'vuedraggable'; import VueDraggable from 'vuedraggable';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash, { FLASH_TYPES } from '~/flash';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import { getFilename } from '~/lib/utils/file_upload'; import { getFilename } from '~/lib/utils/file_upload';
import UploadButton from '../components/upload/button.vue'; import UploadButton from '../components/upload/button.vue';
...@@ -139,8 +139,8 @@ export default { ...@@ -139,8 +139,8 @@ export default {
if (!this.canCreateDesign) return false; if (!this.canCreateDesign) return false;
if (files.length > MAXIMUM_FILE_UPLOAD_LIMIT) { if (files.length > MAXIMUM_FILE_UPLOAD_LIMIT) {
createFlash( createFlash({
sprintf( message: sprintf(
s__( s__(
'DesignManagement|The maximum number of designs allowed to be uploaded is %{upload_limit}. Please try again.', 'DesignManagement|The maximum number of designs allowed to be uploaded is %{upload_limit}. Please try again.',
), ),
...@@ -148,7 +148,7 @@ export default { ...@@ -148,7 +148,7 @@ export default {
upload_limit: MAXIMUM_FILE_UPLOAD_LIMIT, upload_limit: MAXIMUM_FILE_UPLOAD_LIMIT,
}, },
), ),
); });
return false; return false;
} }
...@@ -191,7 +191,7 @@ export default { ...@@ -191,7 +191,7 @@ export default {
const skippedFiles = res?.data?.designManagementUpload?.skippedDesigns || []; const skippedFiles = res?.data?.designManagementUpload?.skippedDesigns || [];
const skippedWarningMessage = designUploadSkippedWarning(this.filesToBeSaved, skippedFiles); const skippedWarningMessage = designUploadSkippedWarning(this.filesToBeSaved, skippedFiles);
if (skippedWarningMessage) { if (skippedWarningMessage) {
createFlash(skippedWarningMessage, 'warning'); createFlash({ message: skippedWarningMessage, types: FLASH_TYPES.WARNING });
} }
// if this upload resulted in a new version being created, redirect user to the latest version // if this upload resulted in a new version being created, redirect user to the latest version
...@@ -214,7 +214,7 @@ export default { ...@@ -214,7 +214,7 @@ export default {
}, },
onUploadDesignError() { onUploadDesignError() {
this.resetFilesToBeSaved(); this.resetFilesToBeSaved();
createFlash(UPLOAD_DESIGN_ERROR); createFlash({ message: UPLOAD_DESIGN_ERROR });
}, },
changeSelectedDesigns(filename) { changeSelectedDesigns(filename) {
if (this.isDesignSelected(filename)) { if (this.isDesignSelected(filename)) {
...@@ -245,18 +245,18 @@ export default { ...@@ -245,18 +245,18 @@ export default {
}, },
onDesignDeleteError() { onDesignDeleteError() {
const errorMessage = designDeletionError({ singular: this.selectedDesigns.length === 1 }); const errorMessage = designDeletionError({ singular: this.selectedDesigns.length === 1 });
createFlash(errorMessage); createFlash({ message: errorMessage });
}, },
onExistingDesignDropzoneChange(files, existingDesignFilename) { onExistingDesignDropzoneChange(files, existingDesignFilename) {
const filesArr = Array.from(files); const filesArr = Array.from(files);
if (filesArr.length > 1) { if (filesArr.length > 1) {
createFlash(EXISTING_DESIGN_DROP_MANY_FILES_MESSAGE); createFlash({ message: EXISTING_DESIGN_DROP_MANY_FILES_MESSAGE });
return; return;
} }
if (!filesArr.some(({ name }) => existingDesignFilename === name)) { if (!filesArr.some(({ name }) => existingDesignFilename === name)) {
createFlash(EXISTING_DESIGN_DROP_INVALID_FILENAME_MESSAGE); createFlash({ message: EXISTING_DESIGN_DROP_INVALID_FILENAME_MESSAGE });
return; return;
} }
...@@ -307,7 +307,7 @@ export default { ...@@ -307,7 +307,7 @@ export default {
optimisticResponse: moveDesignOptimisticResponse(this.reorderedDesigns), optimisticResponse: moveDesignOptimisticResponse(this.reorderedDesigns),
}) })
.catch(() => { .catch(() => {
createFlash(MOVE_DESIGN_ERROR); createFlash({ message: MOVE_DESIGN_ERROR });
}) })
.finally(() => { .finally(() => {
this.isReorderingInProgress = false; this.isReorderingInProgress = false;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { differenceBy } from 'lodash'; import { differenceBy } from 'lodash';
import produce from 'immer'; import produce from 'immer';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { extractCurrentDiscussion, extractDesign, extractDesigns } from './design_management_utils'; import { extractCurrentDiscussion, extractDesign, extractDesigns } from './design_management_utils';
import { import {
ADD_IMAGE_DIFF_NOTE_ERROR, ADD_IMAGE_DIFF_NOTE_ERROR,
...@@ -237,7 +237,7 @@ export const deletePendingTodoFromStore = (store, todoMarkDone, query, queryVari ...@@ -237,7 +237,7 @@ export const deletePendingTodoFromStore = (store, todoMarkDone, query, queryVari
}; };
const onError = (data, message) => { const onError = (data, message) => {
createFlash(message); createFlash({ message });
throw new Error(data.errors); throw new Error(data.errors);
}; };
...@@ -286,7 +286,7 @@ export const updateStoreAfterUploadDesign = (store, data, query) => { ...@@ -286,7 +286,7 @@ export const updateStoreAfterUploadDesign = (store, data, query) => {
export const updateDesignsOnStoreAfterReorder = (store, data, query) => { export const updateDesignsOnStoreAfterReorder = (store, data, query) => {
if (hasErrors(data)) { if (hasErrors(data)) {
createFlash(data.errors[0]); createFlash({ message: data.errors[0] });
} else { } else {
moveDesignInStore(store, data, query); moveDesignInStore(store, data, query);
} }
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlIcon } from '@gitlab/ui'; import { GlIcon } from '@gitlab/ui';
import DesignDropzone from '~/design_management/components/upload/design_dropzone.vue'; import DesignDropzone from '~/design_management/components/upload/design_dropzone.vue';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
jest.mock('~/flash'); jest.mock('~/flash');
......
...@@ -2,7 +2,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; ...@@ -2,7 +2,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils';
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
import { GlAlert } from '@gitlab/ui'; import { GlAlert } from '@gitlab/ui';
import { ApolloMutation } from 'vue-apollo'; import { ApolloMutation } from 'vue-apollo';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import DesignIndex from '~/design_management/pages/design/index.vue'; import DesignIndex from '~/design_management/pages/design/index.vue';
import DesignSidebar from '~/design_management/components/design_sidebar.vue'; import DesignSidebar from '~/design_management/components/design_sidebar.vue';
import DesignPresentation from '~/design_management/components/design_presentation.vue'; import DesignPresentation from '~/design_management/components/design_presentation.vue';
...@@ -295,7 +295,7 @@ describe('Design management design index page', () => { ...@@ -295,7 +295,7 @@ describe('Design management design index page', () => {
wrapper.vm.onDesignQueryResult({ data: mockResponseNoDesigns, loading: false }); wrapper.vm.onDesignQueryResult({ data: mockResponseNoDesigns, loading: false });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith(DESIGN_NOT_FOUND_ERROR); expect(createFlash).toHaveBeenCalledWith({ message: DESIGN_NOT_FOUND_ERROR });
expect(router.push).toHaveBeenCalledTimes(1); expect(router.push).toHaveBeenCalledTimes(1);
expect(router.push).toHaveBeenCalledWith({ name: DESIGNS_ROUTE_NAME }); expect(router.push).toHaveBeenCalledWith({ name: DESIGNS_ROUTE_NAME });
}); });
...@@ -316,7 +316,7 @@ describe('Design management design index page', () => { ...@@ -316,7 +316,7 @@ describe('Design management design index page', () => {
wrapper.vm.onDesignQueryResult({ data: mockResponseWithDesigns, loading: false }); wrapper.vm.onDesignQueryResult({ data: mockResponseWithDesigns, loading: false });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith(DESIGN_VERSION_NOT_EXIST_ERROR); expect(createFlash).toHaveBeenCalledWith({ message: DESIGN_VERSION_NOT_EXIST_ERROR });
expect(router.push).toHaveBeenCalledTimes(1); expect(router.push).toHaveBeenCalledTimes(1);
expect(router.push).toHaveBeenCalledWith({ name: DESIGNS_ROUTE_NAME }); expect(router.push).toHaveBeenCalledWith({ name: DESIGNS_ROUTE_NAME });
}); });
......
...@@ -16,7 +16,7 @@ import { ...@@ -16,7 +16,7 @@ import {
EXISTING_DESIGN_DROP_MANY_FILES_MESSAGE, EXISTING_DESIGN_DROP_MANY_FILES_MESSAGE,
EXISTING_DESIGN_DROP_INVALID_FILENAME_MESSAGE, EXISTING_DESIGN_DROP_INVALID_FILENAME_MESSAGE,
} from '~/design_management/utils/error_messages'; } from '~/design_management/utils/error_messages';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import createRouter from '~/design_management/router'; import createRouter from '~/design_management/router';
import * as utils from '~/design_management/utils/design_management_utils'; import * as utils from '~/design_management/utils/design_management_utils';
import { import {
...@@ -443,10 +443,10 @@ describe('Design management index page', () => { ...@@ -443,10 +443,10 @@ describe('Design management index page', () => {
return uploadDesign.then(() => { return uploadDesign.then(() => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'Upload skipped. test.jpg did not change.', message: 'Upload skipped. test.jpg did not change.',
'warning', types: 'warning',
); });
}); });
}); });
...@@ -482,7 +482,7 @@ describe('Design management index page', () => { ...@@ -482,7 +482,7 @@ describe('Design management index page', () => {
designDropzone.vm.$emit('change', eventPayload); designDropzone.vm.$emit('change', eventPayload);
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith(message); expect(createFlash).toHaveBeenCalledWith({ message });
}); });
}); });
...@@ -747,7 +747,7 @@ describe('Design management index page', () => { ...@@ -747,7 +747,7 @@ describe('Design management index page', () => {
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(createFlash).toHaveBeenCalledWith('Houston, we have a problem'); expect(createFlash).toHaveBeenCalledWith({ message: 'Houston, we have a problem' });
}); });
it('displays flash if mutation had a non-recoverable error', async () => { it('displays flash if mutation had a non-recoverable error', async () => {
...@@ -761,9 +761,9 @@ describe('Design management index page', () => { ...@@ -761,9 +761,9 @@ describe('Design management index page', () => {
await jest.runOnlyPendingTimers(); // kick off the mocked GQL stuff (promises) await jest.runOnlyPendingTimers(); // kick off the mocked GQL stuff (promises)
await wrapper.vm.$nextTick(); // kick off the DOM update for flash await wrapper.vm.$nextTick(); // kick off the DOM update for flash
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'Something went wrong when reordering designs. Please try again', message: 'Something went wrong when reordering designs. Please try again',
); });
}); });
}); });
}); });
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
UPDATE_IMAGE_DIFF_NOTE_ERROR, UPDATE_IMAGE_DIFF_NOTE_ERROR,
} from '~/design_management/utils/error_messages'; } from '~/design_management/utils/error_messages';
import design from '../mock_data/design'; import design from '../mock_data/design';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
jest.mock('~/flash.js'); jest.mock('~/flash.js');
...@@ -35,7 +35,7 @@ describe('Design Management cache update', () => { ...@@ -35,7 +35,7 @@ describe('Design Management cache update', () => {
expect(createFlash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
expect(() => subject(mockStore, { errors: mockErrors }, {}, ...extraArgs)).toThrow(); expect(() => subject(mockStore, { errors: mockErrors }, {}, ...extraArgs)).toThrow();
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith(errorMessage); expect(createFlash).toHaveBeenCalledWith({ message: errorMessage });
}); });
}); });
}); });
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