Commit 1ec2e8bb authored by Illya Klymov's avatar Illya Klymov Committed by Jacques Erasmus

Update import_target cell for re-import

* always render dropdown ui
* complete state behavior should be equal to not started behavior -
replace all isAlreadyImported checks with isAvailableForImport and
negate them
parent c5515778
...@@ -3,14 +3,16 @@ import { ...@@ -3,14 +3,16 @@ import {
GlDropdownDivider, GlDropdownDivider,
GlDropdownItem, GlDropdownItem,
GlDropdownSectionHeader, GlDropdownSectionHeader,
GlLink,
GlFormInput, GlFormInput,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { joinPaths } from '~/lib/utils/url_utility';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import ImportGroupDropdown from '../../components/group_dropdown.vue'; import ImportGroupDropdown from '../../components/group_dropdown.vue';
import { STATUSES } from '../../constants'; import {
import { isInvalid, getInvalidNameValidationMessage, isNameValid } from '../utils'; isInvalid,
getInvalidNameValidationMessage,
isNameValid,
isAvailableForImport,
} from '../utils';
export default { export default {
components: { components: {
...@@ -18,7 +20,6 @@ export default { ...@@ -18,7 +20,6 @@ export default {
GlDropdownDivider, GlDropdownDivider,
GlDropdownItem, GlDropdownItem,
GlDropdownSectionHeader, GlDropdownSectionHeader,
GlLink,
GlFormInput, GlFormInput,
}, },
props: { props: {
...@@ -61,20 +62,8 @@ export default { ...@@ -61,20 +62,8 @@ export default {
return isNameValid(this.group, this.groupPathRegex); return isNameValid(this.group, this.groupPathRegex);
}, },
isAlreadyImported() { isAvailableForImport() {
return this.group.progress.status !== STATUSES.NONE; return isAvailableForImport(this.group);
},
isFinished() {
return this.group.progress.status === STATUSES.FINISHED;
},
fullPath() {
return `${this.importTarget.target_namespace}/${this.importTarget.new_name}`;
},
absolutePath() {
return joinPaths(gon.relative_url_root || '/', this.fullPath);
}, },
}, },
...@@ -85,25 +74,11 @@ export default { ...@@ -85,25 +74,11 @@ export default {
</script> </script>
<template> <template>
<gl-link <div class="gl-display-flex gl-align-items-stretch">
v-if="isFinished"
class="gl-display-inline-flex gl-align-items-center gl-h-7"
:href="absolutePath"
>
{{ fullPath }}
</gl-link>
<div
v-else
class="gl-display-flex gl-align-items-stretch"
:class="{
disabled: isAlreadyImported,
}"
>
<import-group-dropdown <import-group-dropdown
#default="{ namespaces }" #default="{ namespaces }"
:text="importTarget.target_namespace" :text="importTarget.target_namespace"
:disabled="isAlreadyImported" :disabled="!isAvailableForImport"
:namespaces="availableNamespaceNames" :namespaces="availableNamespaceNames"
toggle-class="gl-rounded-top-right-none! gl-rounded-bottom-right-none!" toggle-class="gl-rounded-top-right-none! gl-rounded-bottom-right-none!"
class="gl-h-7 gl-flex-grow-1" class="gl-h-7 gl-flex-grow-1"
...@@ -131,8 +106,8 @@ export default { ...@@ -131,8 +106,8 @@ export default {
<div <div
class="gl-h-7 gl-px-3 gl-display-flex gl-align-items-center gl-border-solid gl-border-0 gl-border-t-1 gl-border-b-1 gl-bg-gray-10" class="gl-h-7 gl-px-3 gl-display-flex gl-align-items-center gl-border-solid gl-border-0 gl-border-t-1 gl-border-b-1 gl-bg-gray-10"
:class="{ :class="{
'gl-text-gray-400 gl-border-gray-100': isAlreadyImported, 'gl-text-gray-400 gl-border-gray-100': !isAvailableForImport,
'gl-border-gray-200': !isAlreadyImported, 'gl-border-gray-200': isAvailableForImport,
}" }"
> >
/ /
...@@ -141,11 +116,11 @@ export default { ...@@ -141,11 +116,11 @@ export default {
<gl-form-input <gl-form-input
class="gl-rounded-top-left-none gl-rounded-bottom-left-none" class="gl-rounded-top-left-none gl-rounded-bottom-left-none"
:class="{ :class="{
'gl-inset-border-1-gray-200!': !isAlreadyImported, 'gl-inset-border-1-gray-200!': isAvailableForImport,
'gl-inset-border-1-gray-100!': isAlreadyImported, 'gl-inset-border-1-gray-100!': !isAvailableForImport,
'is-invalid': isInvalid && !isAlreadyImported, 'is-invalid': isInvalid && isAvailableForImport,
}" }"
:disabled="isAlreadyImported" :disabled="!isAvailableForImport"
:value="importTarget.new_name" :value="importTarget.new_name"
@input="$emit('update-new-name', $event)" @input="$emit('update-new-name', $event)"
/> />
......
import { GlButton, GlDropdownItem, GlLink, GlFormInput } from '@gitlab/ui'; import { GlDropdownItem, GlFormInput } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo';
import ImportGroupDropdown from '~/import_entities/components/group_dropdown.vue'; import ImportGroupDropdown from '~/import_entities/components/group_dropdown.vue';
import { STATUSES } from '~/import_entities/constants'; import { STATUSES } from '~/import_entities/constants';
import ImportTargetCell from '~/import_entities/import_groups/components/import_target_cell.vue'; import ImportTargetCell from '~/import_entities/import_groups/components/import_target_cell.vue';
import { availableNamespacesFixture } from '../graphql/fixtures'; import { availableNamespacesFixture } from '../graphql/fixtures';
Vue.use(VueApollo);
const getFakeGroup = (status) => ({ const getFakeGroup = (status) => ({
web_url: 'https://fake.host/', web_url: 'https://fake.host/',
full_path: 'fake_group_1', full_path: 'fake_group_1',
...@@ -26,9 +22,6 @@ describe('import target cell', () => { ...@@ -26,9 +22,6 @@ describe('import target cell', () => {
let wrapper; let wrapper;
let group; let group;
const findByText = (cmp, text) => {
return wrapper.findAll(cmp).wrappers.find((node) => node.text().indexOf(text) === 0);
};
const findNameInput = () => wrapper.find(GlFormInput); const findNameInput = () => wrapper.find(GlFormInput);
const findNamespaceDropdown = () => wrapper.find(ImportGroupDropdown); const findNamespaceDropdown = () => wrapper.find(ImportGroupDropdown);
...@@ -117,10 +110,6 @@ describe('import target cell', () => { ...@@ -117,10 +110,6 @@ describe('import target cell', () => {
createComponent({ group }); createComponent({ group });
}); });
it('does not render Import button', () => {
expect(findByText(GlButton, 'Import')).toBe(undefined);
});
it('renders namespace dropdown as disabled', () => { it('renders namespace dropdown as disabled', () => {
expect(findNamespaceDropdown().attributes('disabled')).toBe('true'); expect(findNamespaceDropdown().attributes('disabled')).toBe('true');
}); });
...@@ -132,17 +121,8 @@ describe('import target cell', () => { ...@@ -132,17 +121,8 @@ describe('import target cell', () => {
createComponent({ group }); createComponent({ group });
}); });
it('does not render Import button', () => { it('renders namespace dropdown as enabled', () => {
expect(findByText(GlButton, 'Import')).toBe(undefined); expect(findNamespaceDropdown().attributes('disabled')).toBe(undefined);
});
it('does not render namespace dropdown', () => {
expect(findNamespaceDropdown().exists()).toBe(false);
});
it('renders target as link', () => {
const TARGET_LINK = `${group.import_target.target_namespace}/${group.import_target.new_name}`;
expect(findByText(GlLink, TARGET_LINK).exists()).toBe(true);
}); });
}); });
...@@ -179,9 +159,6 @@ describe('import target cell', () => { ...@@ -179,9 +159,6 @@ describe('import target cell', () => {
}, },
}); });
jest.runOnlyPendingTimers();
await nextTick();
expect(wrapper.text()).toContain(FAKE_ERROR_MESSAGE); expect(wrapper.text()).toContain(FAKE_ERROR_MESSAGE);
}); });
}); });
......
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