diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
commit | ee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch) | |
tree | f8479f94a28f66654c6a4f6fb99bad6b4e86a40e /app/assets/javascripts/import_entities | |
parent | 62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff) |
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'app/assets/javascripts/import_entities')
7 files changed, 125 insertions, 24 deletions
diff --git a/app/assets/javascripts/import_entities/import_groups/components/import_table.vue b/app/assets/javascripts/import_entities/import_groups/components/import_table.vue index 98ee858ca91..0cdd64b1b98 100644 --- a/app/assets/javascripts/import_entities/import_groups/components/import_table.vue +++ b/app/assets/javascripts/import_entities/import_groups/components/import_table.vue @@ -12,7 +12,7 @@ import { GlFormCheckbox, } from '@gitlab/ui'; import { debounce } from 'lodash'; -import createFlash from '~/flash'; +import { createAlert } from '~/flash'; import { s__, __, n__, sprintf } from '~/locale'; import PaginationBar from '~/vue_shared/components/pagination_bar/pagination_bar.vue'; import HelpPopover from '~/vue_shared/components/help_popover.vue'; @@ -150,6 +150,10 @@ export default { }, groupsTableData() { + if (!this.availableNamespaces) { + return []; + } + return this.groups.map((group) => { const importTarget = this.getImportTarget(group); const status = this.getStatus(group); @@ -232,6 +236,10 @@ export default { version: this.bulkImportSourceGroups.versionValidation.features.sourceInstanceVersion, }); }, + + pageInfo() { + return this.bulkImportSourceGroups?.pageInfo ?? {}; + }, }, watch: { @@ -342,7 +350,7 @@ export default { variables: { importRequests }, }); } catch (error) { - createFlash({ + createAlert({ message: i18n.ERROR_IMPORT, captureError: true, error, @@ -503,6 +511,7 @@ export default { permissionsHelpPath: helpPagePath('user/permissions', { anchor: 'group-members-permissions' }), popoverOptions: { title: __('What is listed here?') }, i18n, + LOCAL_STORAGE_KEY: 'gl-bulk-imports-status-page-size-v1', }; </script> @@ -696,14 +705,15 @@ export default { /> </template> </gl-table> - <pagination-bar - v-if="hasGroups" - :page-info="bulkImportSourceGroups.pageInfo" - class="gl-mt-3" - @set-page="setPage" - @set-page-size="setPageSize" - /> </template> </template> + <pagination-bar + v-show="!$apollo.loading && hasGroups" + :page-info="pageInfo" + class="gl-mt-3" + :storage-key="$options.LOCAL_STORAGE_KEY" + @set-page="setPage" + @set-page-size="setPageSize" + /> </div> </template> diff --git a/app/assets/javascripts/import_entities/import_groups/services/status_poller.js b/app/assets/javascripts/import_entities/import_groups/services/status_poller.js index ba0f2bb947a..6ad5e448a40 100644 --- a/app/assets/javascripts/import_entities/import_groups/services/status_poller.js +++ b/app/assets/javascripts/import_entities/import_groups/services/status_poller.js @@ -1,5 +1,5 @@ import Visibility from 'visibilityjs'; -import createFlash from '~/flash'; +import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; import Poll from '~/lib/utils/poll'; import { s__ } from '~/locale'; @@ -15,7 +15,7 @@ export class StatusPoller { statuses.forEach((status) => updateImportStatus(status)); }, errorCallback: () => - createFlash({ + createAlert({ message: s__('BulkImport|Update of import statuses with realtime changes failed'), }), }); diff --git a/app/assets/javascripts/import_entities/import_projects/components/advanced_settings.vue b/app/assets/javascripts/import_entities/import_projects/components/advanced_settings.vue new file mode 100644 index 00000000000..a8fdf9b9ec5 --- /dev/null +++ b/app/assets/javascripts/import_entities/import_projects/components/advanced_settings.vue @@ -0,0 +1,51 @@ +<script> +import { GlAccordion, GlAccordionItem, GlAlert, GlForm, GlFormCheckbox } from '@gitlab/ui'; + +export default { + components: { + GlAccordion, + GlAccordionItem, + GlAlert, + GlForm, + GlFormCheckbox, + }, + props: { + stages: { + required: true, + type: Array, + }, + value: { + required: true, + type: Object, + }, + isInitiallyExpanded: { + type: Boolean, + required: false, + default: false, + }, + }, +}; +</script> +<template> + <gl-accordion :header-level="3"> + <gl-accordion-item + :title="s__('ImportProjects|Advanced import settings')" + :visible="isInitiallyExpanded" + > + <gl-alert variant="warning" class="gl-mb-5" :dismissible="false">{{ + s__('ImportProjects|The more information you select, the longer it will take to import') + }}</gl-alert> + <gl-form> + <gl-form-checkbox + v-for="{ name, label, details } in stages" + :key="name" + :checked="value[name]" + @change="$emit('input', { ...value, [name]: $event })" + > + {{ label }} + <template v-if="details" #help>{{ details }} </template> + </gl-form-checkbox> + </gl-form> + </gl-accordion-item> + </gl-accordion> +</template> diff --git a/app/assets/javascripts/import_entities/import_projects/components/import_projects_table.vue b/app/assets/javascripts/import_entities/import_projects/components/import_projects_table.vue index 848c7361601..97a7ed4bf55 100644 --- a/app/assets/javascripts/import_entities/import_projects/components/import_projects_table.vue +++ b/app/assets/javascripts/import_entities/import_projects/components/import_projects_table.vue @@ -9,10 +9,12 @@ import { import { mapActions, mapState, mapGetters } from 'vuex'; import { n__, __, sprintf } from '~/locale'; import ProviderRepoTableRow from './provider_repo_table_row.vue'; +import AdvancedSettings from './advanced_settings.vue'; export default { name: 'ImportProjectsTable', components: { + AdvancedSettings, ProviderRepoTableRow, GlLoadingIcon, GlButton, @@ -35,6 +37,24 @@ export default { required: false, default: false, }, + optionalStages: { + type: Array, + required: false, + default: () => [], + }, + isAdvancedSettingsPanelInitiallyExpanded: { + type: Boolean, + required: false, + default: true, + }, + }, + + data() { + return { + optionalStagesSelection: Object.fromEntries( + this.optionalStages.map(({ name }) => [name, false]), + ), + }; }, computed: { @@ -127,7 +147,7 @@ export default { modal-id="import-all-modal" :title="s__('ImportProjects|Import repositories')" :ok-title="__('Import')" - @ok="importAll" + @ok="importAll({ optionalStages: optionalStagesSelection })" > {{ n__( @@ -150,6 +170,13 @@ export default { /> </form> </div> + <advanced-settings + v-if="optionalStages && optionalStages.length" + v-model="optionalStagesSelection" + :stages="optionalStages" + :is-initially-expanded="isAdvancedSettingsPanelInitiallyExpanded" + class="gl-mb-5" + /> <div v-if="repositories.length" class="gl-w-full"> <table> <thead class="gl-border-0 gl-border-solid gl-border-t-1 gl-border-gray-100"> @@ -171,6 +198,7 @@ export default { :repo="repo" :available-namespaces="namespaces" :user-namespace="defaultTargetNamespace" + :optional-stages="optionalStagesSelection" /> </template> </tbody> diff --git a/app/assets/javascripts/import_entities/import_projects/components/provider_repo_table_row.vue b/app/assets/javascripts/import_entities/import_projects/components/provider_repo_table_row.vue index e4090a378e1..458e0fb1cb1 100644 --- a/app/assets/javascripts/import_entities/import_projects/components/provider_repo_table_row.vue +++ b/app/assets/javascripts/import_entities/import_projects/components/provider_repo_table_row.vue @@ -43,6 +43,10 @@ export default { type: Array, required: true, }, + optionalStages: { + type: Object, + required: true, + }, }, computed: { @@ -177,7 +181,7 @@ export default { v-if="isImportNotStarted" type="button" data-qa-selector="import_button" - @click="fetchImport(repo.importSource.id)" + @click="fetchImport({ repoId: repo.importSource.id, optionalStages })" > {{ importButtonText }} </gl-button> diff --git a/app/assets/javascripts/import_entities/import_projects/index.js b/app/assets/javascripts/import_entities/import_projects/index.js index 5146a0eb461..4daa9e8a1b8 100644 --- a/app/assets/javascripts/import_entities/import_projects/index.js +++ b/app/assets/javascripts/import_entities/import_projects/index.js @@ -42,6 +42,7 @@ export function initPropsFromElement(element) { providerTitle: element.dataset.provider, filterable: parseBoolean(element.dataset.filterable), paginatable: parseBoolean(element.dataset.paginatable), + optionalStages: JSON.parse(element.dataset.optionalStages), }; } diff --git a/app/assets/javascripts/import_entities/import_projects/store/actions.js b/app/assets/javascripts/import_entities/import_projects/store/actions.js index 92be028b8a9..a30c14f9d28 100644 --- a/app/assets/javascripts/import_entities/import_projects/store/actions.js +++ b/app/assets/javascripts/import_entities/import_projects/store/actions.js @@ -1,5 +1,5 @@ import Visibility from 'visibilityjs'; -import createFlash from '~/flash'; +import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import httpStatusCodes from '~/lib/utils/http_status'; @@ -43,11 +43,14 @@ const restartJobsPolling = () => { const setImportTarget = ({ commit }, { repoId, importTarget }) => commit(types.SET_IMPORT_TARGET, { repoId, importTarget }); -const importAll = ({ state, dispatch }) => { +const importAll = ({ state, dispatch }, config = {}) => { return Promise.all( - state.repositories - .filter(isProjectImportable) - .map((r) => dispatch('fetchImport', r.importSource.id)), + state.repositories.filter(isProjectImportable).map((r) => + dispatch('fetchImport', { + repoId: r.importSource.id, + optionalStages: config?.optionalStages, + }), + ), ); }; @@ -73,7 +76,7 @@ const fetchReposFactory = ({ reposPath = isRequired() }) => ({ state, commit }) if (hasRedirectInError(e)) { redirectToUrlInError(e); } else if (tooManyRequests(e)) { - createFlash({ + createAlert({ message: sprintf(s__('ImportProjects|%{provider} rate limit exceeded. Try again later'), { provider: capitalizeFirstCharacter(provider), }), @@ -81,7 +84,7 @@ const fetchReposFactory = ({ reposPath = isRequired() }) => ({ state, commit }) commit(types.RECEIVE_REPOS_ERROR); } else { - createFlash({ + createAlert({ message: sprintf(s__('ImportProjects|Requesting your %{provider} repositories failed'), { provider, }), @@ -92,7 +95,10 @@ const fetchReposFactory = ({ reposPath = isRequired() }) => ({ state, commit }) }); }; -const fetchImportFactory = (importPath = isRequired()) => ({ state, commit, getters }, repoId) => { +const fetchImportFactory = (importPath = isRequired()) => ( + { state, commit, getters }, + { repoId, optionalStages }, +) => { const { ciCdOnly } = state; const importTarget = getters.getImportTarget(repoId); @@ -105,6 +111,7 @@ const fetchImportFactory = (importPath = isRequired()) => ({ state, commit, gett ci_cd_only: ciCdOnly, new_name: newName, target_namespace: targetNamespace, + ...(Object.keys(optionalStages).length ? { optional_stages: optionalStages } : {}), }) .then(({ data }) => { commit(types.RECEIVE_IMPORT_SUCCESS, { @@ -124,7 +131,7 @@ const fetchImportFactory = (importPath = isRequired()) => ({ state, commit, gett ) : s__('ImportProjects|Importing the project failed'); - createFlash({ + createAlert({ message: flashMessage, }); @@ -149,7 +156,7 @@ export const fetchJobsFactory = (jobsPath = isRequired()) => ({ state, commit, d if (hasRedirectInError(e)) { redirectToUrlInError(e); } else { - createFlash({ + createAlert({ message: s__('ImportProjects|Update of imported projects with realtime changes failed'), }); } @@ -177,7 +184,7 @@ const fetchNamespacesFactory = (namespacesPath = isRequired()) => ({ commit }) = commit(types.RECEIVE_NAMESPACES_SUCCESS, convertObjectPropsToCamelCase(data, { deep: true })), ) .catch(() => { - createFlash({ + createAlert({ message: s__('ImportProjects|Requesting namespaces failed'), }); |