Commit 39ced756 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch '339653-improve-success-error-messages-runners' into 'master'

Update flash alerts of Admin Runner UI

See merge request gitlab-org/gitlab!77669
parents 7d3e3a44 c7d1fc60
<script> <script>
import { GlButton, GlButtonGroup, GlModalDirective, GlTooltipDirective } from '@gitlab/ui'; import { GlButton, GlButtonGroup, GlModalDirective, GlTooltipDirective } from '@gitlab/ui';
import createFlash from '~/flash'; import { createAlert } from '~/flash';
import { __, s__, sprintf } from '~/locale'; import { __, s__, sprintf } from '~/locale';
import runnerDeleteMutation from '~/runner/graphql/runner_delete.mutation.graphql'; import runnerDeleteMutation from '~/runner/graphql/runner_delete.mutation.graphql';
import runnerActionsUpdateMutation from '~/runner/graphql/runner_actions_update.mutation.graphql'; import runnerActionsUpdateMutation from '~/runner/graphql/runner_actions_update.mutation.graphql';
...@@ -139,7 +139,7 @@ export default { ...@@ -139,7 +139,7 @@ export default {
onError(error) { onError(error) {
const { message } = error; const { message } = error;
createFlash({ message }); createAlert({ message });
this.reportToSentry(error); this.reportToSentry(error);
}, },
......
<script> <script>
import { GlDropdownItem, GlLoadingIcon } from '@gitlab/ui'; import { GlDropdownItem, GlLoadingIcon } from '@gitlab/ui';
import createFlash from '~/flash'; import { createAlert } from '~/flash';
import { TYPE_GROUP, TYPE_PROJECT } from '~/graphql_shared/constants'; import { TYPE_GROUP, TYPE_PROJECT } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
...@@ -91,7 +91,7 @@ export default { ...@@ -91,7 +91,7 @@ export default {
}, },
onError(error) { onError(error) {
const { message } = error; const { message } = error;
createFlash({ message }); createAlert({ message });
this.reportToSentry(error); this.reportToSentry(error);
}, },
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
modelToUpdateMutationVariables, modelToUpdateMutationVariables,
runnerToModel, runnerToModel,
} from 'ee_else_ce/runner/runner_details/runner_update_form_utils'; } from 'ee_else_ce/runner/runner_details/runner_update_form_utils';
import createFlash, { FLASH_TYPES } from '~/flash'; import { createAlert, VARIANT_SUCCESS } from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { captureException } from '~/runner/sentry_utils'; import { captureException } from '~/runner/sentry_utils';
import { ACCESS_LEVEL_NOT_PROTECTED, ACCESS_LEVEL_REF_PROTECTED, PROJECT_TYPE } from '../constants'; import { ACCESS_LEVEL_NOT_PROTECTED, ACCESS_LEVEL_REF_PROTECTED, PROJECT_TYPE } from '../constants';
...@@ -75,14 +75,14 @@ export default { ...@@ -75,14 +75,14 @@ export default {
if (errors?.length) { if (errors?.length) {
// Validation errors need not be thrown // Validation errors need not be thrown
createFlash({ message: errors[0] }); createAlert({ message: errors[0] });
return; return;
} }
this.onSuccess(); this.onSuccess();
} catch (error) { } catch (error) {
const { message } = error; const { message } = error;
createFlash({ message }); createAlert({ message });
this.reportToSentry(error); this.reportToSentry(error);
} finally { } finally {
...@@ -90,7 +90,7 @@ export default { ...@@ -90,7 +90,7 @@ export default {
} }
}, },
onSuccess() { onSuccess() {
createFlash({ message: __('Changes saved.'), type: FLASH_TYPES.SUCCESS }); createAlert({ message: __('Changes saved.'), variant: VARIANT_SUCCESS });
this.model = runnerToModel(this.runner); this.model = runnerToModel(this.runner);
}, },
reportToSentry(error) { reportToSentry(error) {
......
<script> <script>
import { GlFilteredSearchSuggestion, GlToken } from '@gitlab/ui'; import { GlFilteredSearchSuggestion, GlToken } from '@gitlab/ui';
import createFlash from '~/flash'; import { createAlert } from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
...@@ -50,7 +50,7 @@ export default { ...@@ -50,7 +50,7 @@ export default {
try { try {
this.tags = await this.getTagsOptions(searchTerm); this.tags = await this.getTagsOptions(searchTerm);
} catch { } catch {
createFlash({ createAlert({
message: s__('Runners|Something went wrong while fetching the tags suggestions'), message: s__('Runners|Something went wrong while fetching the tags suggestions'),
}); });
} finally { } finally {
......
<script> <script>
import { GlLink } from '@gitlab/ui'; import { GlLink } from '@gitlab/ui';
import createFlash from '~/flash'; import { createAlert } from '~/flash';
import { fetchPolicies } from '~/lib/graphql'; import { fetchPolicies } from '~/lib/graphql';
import { updateHistory } from '~/lib/utils/url_utility'; import { updateHistory } from '~/lib/utils/url_utility';
import { formatNumber, sprintf, s__ } from '~/locale'; import { formatNumber, sprintf, s__ } from '~/locale';
...@@ -84,7 +84,7 @@ export default { ...@@ -84,7 +84,7 @@ export default {
}; };
}, },
error(error) { error(error) {
createFlash({ message: I18N_FETCH_ERROR }); createAlert({ message: I18N_FETCH_ERROR });
this.reportToSentry(error); this.reportToSentry(error);
}, },
......
<script> <script>
import createFlash from '~/flash'; import { createAlert } from '~/flash';
import { TYPE_CI_RUNNER } from '~/graphql_shared/constants'; import { TYPE_CI_RUNNER } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import RunnerHeader from '../components/runner_header.vue'; import RunnerHeader from '../components/runner_header.vue';
...@@ -34,7 +34,7 @@ export default { ...@@ -34,7 +34,7 @@ export default {
}; };
}, },
error(error) { error(error) {
createFlash({ message: I18N_FETCH_ERROR }); createAlert({ message: I18N_FETCH_ERROR });
this.reportToSentry(error); this.reportToSentry(error);
}, },
......
...@@ -5,7 +5,7 @@ import createMockApollo from 'helpers/mock_apollo_helper'; ...@@ -5,7 +5,7 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { runnerData } from 'jest/runner/mock_data'; import { runnerData } from 'jest/runner/mock_data';
import createFlash, { FLASH_TYPES } from '~/flash'; import { createAlert, VARIANT_SUCCESS } from '~/flash';
import RunnerUpdateForm from '~/runner/components/runner_update_form.vue'; import RunnerUpdateForm from '~/runner/components/runner_update_form.vue';
import runnerUpdateMutation from '~/runner/graphql/runner_update.mutation.graphql'; import runnerUpdateMutation from '~/runner/graphql/runner_update.mutation.graphql';
...@@ -53,9 +53,9 @@ describe('RunnerUpdateForm', () => { ...@@ -53,9 +53,9 @@ describe('RunnerUpdateForm', () => {
input: expect.objectContaining(submittedRunner), input: expect.objectContaining(submittedRunner),
}); });
expect(createFlash).toHaveBeenLastCalledWith({ expect(createAlert).toHaveBeenLastCalledWith({
message: expect.stringContaining('saved'), message: expect.stringContaining('saved'),
type: FLASH_TYPES.SUCCESS, variant: VARIANT_SUCCESS,
}); });
expect(findSubmitDisabledAttr()).toBeUndefined(); expect(findSubmitDisabledAttr()).toBeUndefined();
......
...@@ -4,7 +4,7 @@ import createMockApollo from 'helpers/mock_apollo_helper'; ...@@ -4,7 +4,7 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import createFlash from '~/flash'; import { createAlert } from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { captureException } from '~/runner/sentry_utils'; import { captureException } from '~/runner/sentry_utils';
...@@ -200,7 +200,7 @@ describe('RunnerTypeCell', () => { ...@@ -200,7 +200,7 @@ describe('RunnerTypeCell', () => {
}); });
it('error is shown to the user', () => { it('error is shown to the user', () => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createAlert).toHaveBeenCalledTimes(1);
}); });
}); });
...@@ -229,7 +229,7 @@ describe('RunnerTypeCell', () => { ...@@ -229,7 +229,7 @@ describe('RunnerTypeCell', () => {
}); });
it('error is shown to the user', () => { it('error is shown to the user', () => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createAlert).toHaveBeenCalledTimes(1);
}); });
}); });
}); });
...@@ -350,7 +350,7 @@ describe('RunnerTypeCell', () => { ...@@ -350,7 +350,7 @@ describe('RunnerTypeCell', () => {
}); });
it('error is shown to the user', () => { it('error is shown to the user', () => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createAlert).toHaveBeenCalledTimes(1);
}); });
it('toast notification is not shown', () => { it('toast notification is not shown', () => {
...@@ -382,7 +382,7 @@ describe('RunnerTypeCell', () => { ...@@ -382,7 +382,7 @@ describe('RunnerTypeCell', () => {
}); });
it('error is shown to the user', () => { it('error is shown to the user', () => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createAlert).toHaveBeenCalledTimes(1);
}); });
}); });
}); });
......
...@@ -4,7 +4,7 @@ import { nextTick } from 'vue'; ...@@ -4,7 +4,7 @@ import { nextTick } from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import createFlash from '~/flash'; import { createAlert } from '~/flash';
import RegistrationTokenResetDropdownItem from '~/runner/components/registration/registration_token_reset_dropdown_item.vue'; import RegistrationTokenResetDropdownItem from '~/runner/components/registration/registration_token_reset_dropdown_item.vue';
import { INSTANCE_TYPE, GROUP_TYPE, PROJECT_TYPE } from '~/runner/constants'; import { INSTANCE_TYPE, GROUP_TYPE, PROJECT_TYPE } from '~/runner/constants';
import runnersRegistrationTokenResetMutation from '~/runner/graphql/runners_registration_token_reset.mutation.graphql'; import runnersRegistrationTokenResetMutation from '~/runner/graphql/runners_registration_token_reset.mutation.graphql';
...@@ -146,7 +146,7 @@ describe('RegistrationTokenResetDropdownItem', () => { ...@@ -146,7 +146,7 @@ describe('RegistrationTokenResetDropdownItem', () => {
findDropdownItem().trigger('click'); findDropdownItem().trigger('click');
await waitForPromises(); await waitForPromises();
expect(createFlash).toHaveBeenLastCalledWith({ expect(createAlert).toHaveBeenLastCalledWith({
message: `Network error: ${mockErrorMsg}`, message: `Network error: ${mockErrorMsg}`,
}); });
expect(captureException).toHaveBeenCalledWith({ expect(captureException).toHaveBeenCalledWith({
...@@ -172,7 +172,7 @@ describe('RegistrationTokenResetDropdownItem', () => { ...@@ -172,7 +172,7 @@ describe('RegistrationTokenResetDropdownItem', () => {
findDropdownItem().trigger('click'); findDropdownItem().trigger('click');
await waitForPromises(); await waitForPromises();
expect(createFlash).toHaveBeenLastCalledWith({ expect(createAlert).toHaveBeenLastCalledWith({
message: `${mockErrorMsg} ${mockErrorMsg2}`, message: `${mockErrorMsg} ${mockErrorMsg2}`,
}); });
expect(captureException).toHaveBeenCalledWith({ expect(captureException).toHaveBeenCalledWith({
......
...@@ -5,7 +5,7 @@ import VueApollo from 'vue-apollo'; ...@@ -5,7 +5,7 @@ import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import createFlash, { FLASH_TYPES } from '~/flash'; import { createAlert, VARIANT_SUCCESS } from '~/flash';
import RunnerUpdateForm from '~/runner/components/runner_update_form.vue'; import RunnerUpdateForm from '~/runner/components/runner_update_form.vue';
import { import {
INSTANCE_TYPE, INSTANCE_TYPE,
...@@ -79,9 +79,9 @@ describe('RunnerUpdateForm', () => { ...@@ -79,9 +79,9 @@ describe('RunnerUpdateForm', () => {
input: expect.objectContaining(submittedRunner), input: expect.objectContaining(submittedRunner),
}); });
expect(createFlash).toHaveBeenLastCalledWith({ expect(createAlert).toHaveBeenLastCalledWith({
message: expect.stringContaining('saved'), message: expect.stringContaining('saved'),
type: FLASH_TYPES.SUCCESS, variant: VARIANT_SUCCESS,
}); });
expect(findSubmitDisabledAttr()).toBeUndefined(); expect(findSubmitDisabledAttr()).toBeUndefined();
...@@ -238,7 +238,7 @@ describe('RunnerUpdateForm', () => { ...@@ -238,7 +238,7 @@ describe('RunnerUpdateForm', () => {
await submitFormAndWait(); await submitFormAndWait();
expect(createFlash).toHaveBeenLastCalledWith({ expect(createAlert).toHaveBeenLastCalledWith({
message: `Network error: ${mockErrorMsg}`, message: `Network error: ${mockErrorMsg}`,
}); });
expect(captureException).toHaveBeenCalledWith({ expect(captureException).toHaveBeenCalledWith({
...@@ -262,7 +262,7 @@ describe('RunnerUpdateForm', () => { ...@@ -262,7 +262,7 @@ describe('RunnerUpdateForm', () => {
await submitFormAndWait(); await submitFormAndWait();
expect(createFlash).toHaveBeenLastCalledWith({ expect(createAlert).toHaveBeenLastCalledWith({
message: mockErrorMsg, message: mockErrorMsg,
}); });
expect(captureException).not.toHaveBeenCalled(); expect(captureException).not.toHaveBeenCalled();
......
...@@ -3,7 +3,7 @@ import { mount } from '@vue/test-utils'; ...@@ -3,7 +3,7 @@ import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import createFlash from '~/flash'; import { createAlert } from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import TagToken, { TAG_SUGGESTIONS_PATH } from '~/runner/components/search_tokens/tag_token.vue'; import TagToken, { TAG_SUGGESTIONS_PATH } from '~/runner/components/search_tokens/tag_token.vue';
...@@ -168,8 +168,8 @@ describe('TagToken', () => { ...@@ -168,8 +168,8 @@ describe('TagToken', () => {
}); });
it('error is shown', async () => { it('error is shown', async () => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createAlert).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith({ message: expect.any(String) }); expect(createAlert).toHaveBeenCalledWith({ message: expect.any(String) });
}); });
}); });
......
...@@ -6,7 +6,7 @@ import createMockApollo from 'helpers/mock_apollo_helper'; ...@@ -6,7 +6,7 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import setWindowLocation from 'helpers/set_window_location_helper'; import setWindowLocation from 'helpers/set_window_location_helper';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import createFlash from '~/flash'; import { createAlert } from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { updateHistory } from '~/lib/utils/url_utility'; import { updateHistory } from '~/lib/utils/url_utility';
...@@ -236,7 +236,7 @@ describe('GroupRunnersApp', () => { ...@@ -236,7 +236,7 @@ describe('GroupRunnersApp', () => {
}); });
it('error is shown to the user', async () => { it('error is shown to the user', async () => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createAlert).toHaveBeenCalledTimes(1);
}); });
it('error is reported to sentry', async () => { it('error is reported to sentry', async () => {
......
...@@ -2,7 +2,7 @@ import { createLocalVue, mount, shallowMount } from '@vue/test-utils'; ...@@ -2,7 +2,7 @@ import { createLocalVue, mount, shallowMount } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import createFlash from '~/flash'; import { createAlert } from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import RunnerHeader from '~/runner/components/runner_header.vue'; import RunnerHeader from '~/runner/components/runner_header.vue';
...@@ -82,7 +82,7 @@ describe('RunnerDetailsApp', () => { ...@@ -82,7 +82,7 @@ describe('RunnerDetailsApp', () => {
}); });
it('error is shown to the user', () => { it('error is shown to the user', () => {
expect(createFlash).toHaveBeenCalled(); expect(createAlert).toHaveBeenCalled();
}); });
}); });
}); });
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