Commit 2e20097d authored by Miguel Rincon's avatar Miguel Rincon

Merge branch 'run-new-pipeline-loading-state' into 'master'

Adds loading state to Run pipeline view

See merge request gitlab-org/gitlab!47213
parents f00500d1 82ffc510
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
GlDropdownItem, GlDropdownItem,
GlSearchBoxByType, GlSearchBoxByType,
GlSprintf, GlSprintf,
GlLoadingIcon,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { s__, __, n__ } from '~/locale'; import { s__, __, n__ } from '~/locale';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -45,6 +46,7 @@ export default { ...@@ -45,6 +46,7 @@ export default {
GlDropdownItem, GlDropdownItem,
GlSearchBoxByType, GlSearchBoxByType,
GlSprintf, GlSprintf,
GlLoadingIcon,
}, },
props: { props: {
pipelinesPath: { pipelinesPath: {
...@@ -96,6 +98,7 @@ export default { ...@@ -96,6 +98,7 @@ export default {
warnings: [], warnings: [],
totalWarnings: 0, totalWarnings: 0,
isWarningDismissed: false, isWarningDismissed: false,
isLoading: false,
}; };
}, },
computed: { computed: {
...@@ -209,6 +212,8 @@ export default { ...@@ -209,6 +212,8 @@ export default {
fetchConfigVariables(refValue) { fetchConfigVariables(refValue) {
if (gon?.features?.newPipelineFormPrefilledVars) { if (gon?.features?.newPipelineFormPrefilledVars) {
this.isLoading = true;
return axios return axios
.get(this.configVariablesPath, { .get(this.configVariablesPath, {
params: { params: {
...@@ -226,6 +231,8 @@ export default { ...@@ -226,6 +231,8 @@ export default {
} }
}); });
this.isLoading = false;
return { params, descriptions }; return { params, descriptions };
}); });
} }
...@@ -324,7 +331,9 @@ export default { ...@@ -324,7 +331,9 @@ export default {
> >
</gl-form-group> </gl-form-group>
<gl-form-group :label="s__('Pipeline|Variables')"> <gl-loading-icon v-if="isLoading" class="gl-mb-5" size="lg" />
<gl-form-group v-else :label="s__('Pipeline|Variables')">
<div <div
v-for="(variable, index) in variables" v-for="(variable, index) in variables"
:key="variable.uniqueId" :key="variable.uniqueId"
......
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import { GlDropdown, GlDropdownItem, GlForm, GlSprintf } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlForm, GlSprintf, GlLoadingIcon } from '@gitlab/ui';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
...@@ -35,6 +35,7 @@ describe('Pipeline New Form', () => { ...@@ -35,6 +35,7 @@ describe('Pipeline New Form', () => {
const findWarningAlert = () => wrapper.find('[data-testid="run-pipeline-warning-alert"]'); const findWarningAlert = () => wrapper.find('[data-testid="run-pipeline-warning-alert"]');
const findWarningAlertSummary = () => findWarningAlert().find(GlSprintf); const findWarningAlertSummary = () => findWarningAlert().find(GlSprintf);
const findWarnings = () => wrapper.findAll('[data-testid="run-pipeline-warning"]'); const findWarnings = () => wrapper.findAll('[data-testid="run-pipeline-warning"]');
const findLoadingIcon = () => wrapper.find(GlLoadingIcon);
const getExpectedPostParams = () => JSON.parse(mock.history.post[0].data); const getExpectedPostParams = () => JSON.parse(mock.history.post[0].data);
const createComponent = (term = '', props = {}, method = shallowMount) => { const createComponent = (term = '', props = {}, method = shallowMount) => {
...@@ -207,6 +208,25 @@ describe('Pipeline New Form', () => { ...@@ -207,6 +208,25 @@ describe('Pipeline New Form', () => {
window.gon = origGon; window.gon = origGon;
}); });
describe('loading state', () => {
it('loading icon is shown when content is requested and hidden when received', async () => {
createComponent('', mockParams, mount);
mock.onGet(configVariablesPath).reply(httpStatusCodes.OK, {
[mockYmlKey]: {
value: mockYmlValue,
description: mockYmlDesc,
},
});
expect(findLoadingIcon().exists()).toBe(true);
await waitForPromises();
expect(findLoadingIcon().exists()).toBe(false);
});
});
describe('when yml defines a variable with description', () => { describe('when yml defines a variable with description', () => {
beforeEach(async () => { beforeEach(async () => {
createComponent('', mockParams, mount); createComponent('', mockParams, mount);
......
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