Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/jira_import/components/jira_import_app.vue')
-rw-r--r--app/assets/javascripts/jira_import/components/jira_import_app.vue106
1 files changed, 4 insertions, 102 deletions
diff --git a/app/assets/javascripts/jira_import/components/jira_import_app.vue b/app/assets/javascripts/jira_import/components/jira_import_app.vue
index 60ddacd49dd..0f690d17da9 100644
--- a/app/assets/javascripts/jira_import/components/jira_import_app.vue
+++ b/app/assets/javascripts/jira_import/components/jira_import_app.vue
@@ -1,11 +1,7 @@
<script>
-import { GlAlert, GlLoadingIcon, GlSprintf } from '@gitlab/ui';
+import { GlAlert, GlLoadingIcon } from '@gitlab/ui';
import { last } from 'lodash';
-import { __ } from '~/locale';
import getJiraImportDetailsQuery from '../queries/get_jira_import_details.query.graphql';
-import getJiraUserMappingMutation from '../queries/get_jira_user_mapping.mutation.graphql';
-import initiateJiraImportMutation from '../queries/initiate_jira_import.mutation.graphql';
-import { addInProgressImportToStore } from '../utils/cache_update';
import { isInProgress, extractJiraProjectsOptions } from '../utils/jira_import_utils';
import JiraImportForm from './jira_import_form.vue';
import JiraImportProgress from './jira_import_progress.vue';
@@ -16,7 +12,6 @@ export default {
components: {
GlAlert,
GlLoadingIcon,
- GlSprintf,
JiraImportForm,
JiraImportProgress,
JiraImportSetup,
@@ -53,10 +48,7 @@ export default {
},
data() {
return {
- isSubmitting: false,
jiraImportDetails: {},
- selectedProject: undefined,
- userMappings: [],
errorMessage: '',
showAlert: false,
};
@@ -80,86 +72,7 @@ export default {
},
},
},
- computed: {
- numberOfPreviousImports() {
- return this.jiraImportDetails.imports?.reduce?.(
- (acc, jiraProject) => (jiraProject.jiraProjectKey === this.selectedProject ? acc + 1 : acc),
- 0,
- );
- },
- hasPreviousImports() {
- return this.numberOfPreviousImports > 0;
- },
- importLabel() {
- return this.selectedProject
- ? `jira-import::${this.selectedProject}-${this.numberOfPreviousImports + 1}`
- : 'jira-import::KEY-1';
- },
- },
- mounted() {
- if (this.isJiraConfigured) {
- this.$apollo
- .mutate({
- mutation: getJiraUserMappingMutation,
- variables: {
- input: {
- projectPath: this.projectPath,
- },
- },
- })
- .then(({ data }) => {
- if (data.jiraImportUsers.errors.length) {
- this.setAlertMessage(data.jiraImportUsers.errors.join('. '));
- } else {
- this.userMappings = data.jiraImportUsers.jiraUsers;
- }
- })
- .catch(() => this.setAlertMessage(__('There was an error retrieving the Jira users.')));
- }
- },
methods: {
- initiateJiraImport(project) {
- this.isSubmitting = true;
-
- this.$apollo
- .mutate({
- mutation: initiateJiraImportMutation,
- variables: {
- input: {
- jiraProjectKey: project,
- projectPath: this.projectPath,
- usersMapping: this.userMappings.map(({ gitlabId, jiraAccountId }) => ({
- gitlabId,
- jiraAccountId,
- })),
- },
- },
- update: (store, { data }) =>
- addInProgressImportToStore(store, data.jiraImportStart, this.projectPath),
- })
- .then(({ data }) => {
- if (data.jiraImportStart.errors.length) {
- this.setAlertMessage(data.jiraImportStart.errors.join('. '));
- } else {
- this.selectedProject = undefined;
- }
- })
- .catch(() => this.setAlertMessage(__('There was an error importing the Jira project.')))
- .finally(() => {
- this.isSubmitting = false;
- });
- },
- updateMapping(jiraAccountId, gitlabId, gitlabUsername) {
- this.userMappings = this.userMappings.map(userMapping =>
- userMapping.jiraAccountId === jiraAccountId
- ? {
- ...userMapping,
- gitlabId,
- gitlabUsername,
- }
- : userMapping,
- );
- },
setAlertMessage(message) {
this.errorMessage = message;
this.showAlert = true;
@@ -168,9 +81,6 @@ export default {
this.showAlert = false;
},
},
- previousImportsMessage: __(
- 'You have imported from this project %{numberOfPreviousImports} times before. Each new import will create duplicate issues.',
- ),
};
</script>
@@ -179,11 +89,6 @@ export default {
<gl-alert v-if="showAlert" variant="danger" @dismiss="dismissAlert">
{{ errorMessage }}
</gl-alert>
- <gl-alert v-if="hasPreviousImports" variant="warning" :dismissible="false">
- <gl-sprintf :message="$options.previousImportsMessage">
- <template #numberOfPreviousImports>{{ numberOfPreviousImports }}</template>
- </gl-sprintf>
- </gl-alert>
<jira-import-setup
v-if="!isJiraConfigured"
@@ -201,15 +106,12 @@ export default {
/>
<jira-import-form
v-else
- v-model="selectedProject"
- :import-label="importLabel"
- :is-submitting="isSubmitting"
:issues-path="issuesPath"
+ :jira-imports="jiraImportDetails.imports"
:jira-projects="jiraImportDetails.projects"
:project-id="projectId"
- :user-mappings="userMappings"
- @initiateJiraImport="initiateJiraImport"
- @updateMapping="updateMapping"
+ :project-path="projectPath"
+ @error="setAlertMessage"
/>
</div>
</template>