Commit 7d25a6e6 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '235977-migrate-import_projects-application-to-gitlab-ui' into 'master'

Migrate import_projects application to gitlab-ui

See merge request gitlab-org/gitlab!53976
parents ea39dd87 d4914d44
<script> <script>
import { GlButton, GlLoadingIcon, GlIntersectionObserver, GlModal } from '@gitlab/ui'; import { GlButton, GlLoadingIcon, GlIntersectionObserver, GlModal, GlFormInput } from '@gitlab/ui';
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import { n__, __, sprintf } from '~/locale'; import { n__, __, sprintf } from '~/locale';
import ProviderRepoTableRow from './provider_repo_table_row.vue'; import ProviderRepoTableRow from './provider_repo_table_row.vue';
...@@ -12,6 +12,7 @@ export default { ...@@ -12,6 +12,7 @@ export default {
GlButton, GlButton,
GlModal, GlModal,
GlIntersectionObserver, GlIntersectionObserver,
GlFormInput,
}, },
props: { props: {
providerTitle: { providerTitle: {
...@@ -115,13 +116,13 @@ export default { ...@@ -115,13 +116,13 @@ export default {
<template> <template>
<div> <div>
<p class="light text-nowrap mt-2"> <p class="gl-text-gray-900 gl-white-space-nowrap gl-mt-3">
{{ s__('ImportProjects|Select the repositories you want to import') }} {{ s__('ImportProjects|Select the repositories you want to import') }}
</p> </p>
<template v-if="hasIncompatibleRepos"> <template v-if="hasIncompatibleRepos">
<slot name="incompatible-repos-warning"></slot> <slot name="incompatible-repos-warning"></slot>
</template> </template>
<div class="d-flex justify-content-between align-items-end flex-wrap mb-3"> <div class="gl-display-flex gl-justify-content-space-between gl-flex-wrap gl-mb-5">
<gl-button <gl-button
variant="success" variant="success"
:loading="isImportingAnyRepo" :loading="isImportingAnyRepo"
...@@ -148,24 +149,29 @@ export default { ...@@ -148,24 +149,29 @@ export default {
<slot name="actions"></slot> <slot name="actions"></slot>
<form v-if="filterable" class="gl-ml-auto" novalidate @submit.prevent> <form v-if="filterable" class="gl-ml-auto" novalidate @submit.prevent>
<input <gl-form-input
data-qa-selector="githubish_import_filter_field" data-qa-selector="githubish_import_filter_field"
class="form-control"
name="filter" name="filter"
:placeholder="__('Filter your repositories by name')" :placeholder="__('Filter your repositories by name')"
autofocus autofocus
size="40" size="lg"
@keyup.enter="setFilter($event.target.value)" @keyup.enter="setFilter($event.target.value)"
/> />
</form> </form>
</div> </div>
<div v-if="repositories.length" class="table-responsive"> <div v-if="repositories.length" class="gl-w-full">
<table class="table import-table"> <table>
<thead> <thead class="gl-border-0 gl-border-solid gl-border-t-1 gl-border-gray-100">
<th class="import-jobs-from-col">{{ fromHeaderText }}</th> <th class="import-jobs-from-col gl-p-4 gl-vertical-align-top gl-border-b-1">
<th class="import-jobs-to-col">{{ __('To GitLab') }}</th> {{ fromHeaderText }}
<th class="import-jobs-status-col">{{ __('Status') }}</th> </th>
<th class="import-jobs-cta-col"></th> <th class="import-jobs-to-col gl-p-4 gl-vertical-align-top gl-border-b-1">
{{ __('To GitLab') }}
</th>
<th class="import-jobs-status-col gl-p-4 gl-vertical-align-top gl-border-b-1">
{{ __('Status') }}
</th>
<th class="import-jobs-cta-col gl-p-4 gl-vertical-align-top gl-border-b-1"></th>
</thead> </thead>
<tbody> <tbody>
<template v-for="repo in repositories"> <template v-for="repo in repositories">
...@@ -183,9 +189,9 @@ export default { ...@@ -183,9 +189,9 @@ export default {
:key="pagePaginationStateKey" :key="pagePaginationStateKey"
@appear="fetchRepos" @appear="fetchRepos"
/> />
<gl-loading-icon v-if="isLoading" class="import-projects-loading-icon" size="md" /> <gl-loading-icon v-if="isLoading" class="gl-mt-7" size="md" />
<div v-if="!isLoading && repositories.length === 0" class="text-center"> <div v-if="!isLoading && repositories.length === 0" class="gl-text-center">
<strong>{{ emptyStateText }}</strong> <strong>{{ emptyStateText }}</strong>
</div> </div>
</div> </div>
......
<script> <script>
import { GlIcon, GlBadge } from '@gitlab/ui'; import { GlIcon, GlBadge, GlFormInput, GlButton, GlLink } from '@gitlab/ui';
import { mapState, mapGetters, mapActions } from 'vuex'; import { mapState, mapGetters, mapActions } from 'vuex';
import { __ } from '~/locale'; import { __ } from '~/locale';
import Select2Select from '~/vue_shared/components/select2_select.vue'; import Select2Select from '~/vue_shared/components/select2_select.vue';
...@@ -12,8 +12,11 @@ export default { ...@@ -12,8 +12,11 @@ export default {
components: { components: {
Select2Select, Select2Select,
ImportStatus, ImportStatus,
GlFormInput,
GlButton,
GlIcon, GlIcon,
GlBadge, GlBadge,
GlLink,
}, },
props: { props: {
repo: { repo: {
...@@ -61,7 +64,7 @@ export default { ...@@ -61,7 +64,7 @@ export default {
select2Options() { select2Options() {
return { return {
data: this.availableNamespaces, data: this.availableNamespaces,
containerCssClass: 'import-namespace-select qa-project-namespace-select w-auto', containerCssClass: 'import-namespace-select qa-project-namespace-select gl-w-auto',
}; };
}, },
...@@ -97,52 +100,56 @@ export default { ...@@ -97,52 +100,56 @@ export default {
</script> </script>
<template> <template>
<tr class="qa-project-import-row import-row"> <tr
<td> class="qa-project-import-row gl-h-11 gl-border-0 gl-border-solid gl-border-t-1 gl-border-gray-100 gl-h-11"
<a >
:href="repo.importSource.providerLink" <td class="gl-p-4">
rel="noreferrer noopener" <gl-link :href="repo.importSource.providerLink" target="_blank" data-testid="providerLink"
target="_blank"
data-testid="providerLink"
>{{ repo.importSource.fullName }} >{{ repo.importSource.fullName }}
<gl-icon v-if="repo.importSource.providerLink" name="external-link" /> <gl-icon v-if="repo.importSource.providerLink" name="external-link" />
</a> </gl-link>
</td> </td>
<td class="d-flex flex-wrap flex-lg-nowrap" data-testid="fullPath"> <td
class="gl-display-flex gl-flex-sm-wrap gl-p-4 gl-pt-5 gl-vertical-align-top"
data-testid="fullPath"
>
<template v-if="repo.importSource.target">{{ repo.importSource.target }}</template> <template v-if="repo.importSource.target">{{ repo.importSource.target }}</template>
<template v-else-if="isImportNotStarted"> <template v-else-if="isImportNotStarted">
<div class="import-entities-target-select gl-display-flex gl-align-items-stretch gl-w-full">
<select2-select v-model="targetNamespaceSelect" :options="select2Options" /> <select2-select v-model="targetNamespaceSelect" :options="select2Options" />
<span class="px-2 import-slash-divider d-flex justify-content-center align-items-center" <div
>/</span class="import-entities-target-select-separator gl-px-3 gl-display-flex gl-align-items-center gl-border-solid gl-border-0 gl-border-t-1 gl-border-b-1"
> >
<input /
</div>
<gl-form-input
v-model="newNameInput" v-model="newNameInput"
type="text" class="gl-rounded-top-left-none gl-rounded-bottom-left-none qa-project-path-field"
class="form-control import-project-name-input qa-project-path-field"
/> />
</div>
</template> </template>
<template v-else-if="repo.importedProject">{{ displayFullPath }}</template> <template v-else-if="repo.importedProject">{{ displayFullPath }}</template>
</td> </td>
<td> <td class="gl-p-4">
<import-status :status="importStatus" /> <import-status :status="importStatus" />
</td> </td>
<td data-testid="actions"> <td data-testid="actions">
<a <gl-button
v-if="isFinished" v-if="isFinished"
class="btn btn-default" class="btn btn-default"
:href="repo.importedProject.fullPath" :href="repo.importedProject.fullPath"
rel="noreferrer noopener" rel="noreferrer noopener"
target="_blank" target="_blank"
>{{ __('Go to project') }} >{{ __('Go to project') }}
</a> </gl-button>
<button <gl-button
v-if="isImportNotStarted" v-if="isImportNotStarted"
type="button" type="button"
class="qa-import-button btn btn-default" class="qa-import-button"
@click="fetchImport(repo.importSource.id)" @click="fetchImport(repo.importSource.id)"
> >
{{ importButtonText }} {{ importButtonText }}
</button> </gl-button>
<gl-badge v-else-if="isIncompatible" variant="danger">{{ <gl-badge v-else-if="isIncompatible" variant="danger">{{
__('Incompatible project') __('Incompatible project')
}}</gl-badge> }}</gl-badge>
......
...@@ -12,35 +12,6 @@ ...@@ -12,35 +12,6 @@
width: 1%; width: 1%;
} }
.import-project-name-input {
border-radius: 0 $border-radius-default $border-radius-default 0;
position: relative;
left: -1px;
max-width: 300px;
}
.import-slash-divider {
background-color: $gray-lightest;
border: 1px solid $border-color;
}
.import-row {
height: 55px;
}
.import-table {
.import-jobs-from-col,
.import-jobs-to-col,
.import-jobs-status-col,
.import-jobs-cta-col {
border-bottom-width: 1px;
padding-left: $gl-padding;
}
}
.import-projects-loading-icon {
margin-top: $gl-padding-32;
}
.import-entities-target-select { .import-entities-target-select {
&.disabled { &.disabled {
......
...@@ -52,6 +52,6 @@ RSpec.describe 'Import multiple repositories by uploading a manifest file', :js ...@@ -52,6 +52,6 @@ RSpec.describe 'Import multiple repositories by uploading a manifest file', :js
end end
def second_row def second_row
page.all('table.import-table tbody tr')[1] page.all('table tbody tr')[1]
end end
end end
import { GlLoadingIcon, GlButton, GlIntersectionObserver } from '@gitlab/ui'; import { GlLoadingIcon, GlButton, GlIntersectionObserver, GlFormInput } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
...@@ -12,7 +12,9 @@ describe('ImportProjectsTable', () => { ...@@ -12,7 +12,9 @@ describe('ImportProjectsTable', () => {
let wrapper; let wrapper;
const findFilterField = () => const findFilterField = () =>
wrapper.find('input[data-qa-selector="githubish_import_filter_field"]'); wrapper
.findAllComponents(GlFormInput)
.wrappers.find((w) => w.attributes('placeholder') === 'Filter your repositories by name');
const providerTitle = 'THE PROVIDER'; const providerTitle = 'THE PROVIDER';
const providerRepo = { const providerRepo = {
...@@ -205,7 +207,7 @@ describe('ImportProjectsTable', () => { ...@@ -205,7 +207,7 @@ describe('ImportProjectsTable', () => {
it('does not render filtering input field when filterable is false', () => { it('does not render filtering input field when filterable is false', () => {
createComponent({ filterable: false }); createComponent({ filterable: false });
expect(findFilterField().exists()).toBe(false); expect(findFilterField()).toBeUndefined();
}); });
describe('when paginatable is set to true', () => { describe('when paginatable is set to true', () => {
......
import { GlBadge } from '@gitlab/ui'; import { GlBadge, GlButton } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
...@@ -34,7 +34,7 @@ describe('ProviderRepoTableRow', () => { ...@@ -34,7 +34,7 @@ describe('ProviderRepoTableRow', () => {
} }
const findImportButton = () => { const findImportButton = () => {
const buttons = wrapper.findAll('button').filter((node) => node.text() === 'Import'); const buttons = wrapper.findAllComponents(GlButton).filter((node) => node.text() === 'Import');
return buttons.length ? buttons.at(0) : buttons; return buttons.length ? buttons.at(0) : buttons;
}; };
...@@ -91,7 +91,7 @@ describe('ProviderRepoTableRow', () => { ...@@ -91,7 +91,7 @@ describe('ProviderRepoTableRow', () => {
}); });
it('imports repo when clicking import button', async () => { it('imports repo when clicking import button', async () => {
findImportButton().trigger('click'); findImportButton().vm.$emit('click');
await nextTick(); await nextTick();
......
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