diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /app/assets/javascripts/import_entities/import_groups/graphql/services/source_groups_manager.js | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) | |
download | gitlab-ce-0653e08efd039a5905f3fa4f6e9cef9f5d2f799c.tar.gz |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'app/assets/javascripts/import_entities/import_groups/graphql/services/source_groups_manager.js')
-rw-r--r-- | app/assets/javascripts/import_entities/import_groups/graphql/services/source_groups_manager.js | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/app/assets/javascripts/import_entities/import_groups/graphql/services/source_groups_manager.js b/app/assets/javascripts/import_entities/import_groups/graphql/services/source_groups_manager.js index 97dbdbf518a..7caa37d9ad4 100644 --- a/app/assets/javascripts/import_entities/import_groups/graphql/services/source_groups_manager.js +++ b/app/assets/javascripts/import_entities/import_groups/graphql/services/source_groups_manager.js @@ -35,15 +35,18 @@ export class SourceGroupsManager { } createImportState(importId, jobConfig) { - this.importStates[this.getStorageKey(importId)] = { + this.importStates[importId] = { status: jobConfig.status, - groups: jobConfig.groups.map((g) => ({ importTarget: g.import_target, id: g.id })), + groups: jobConfig.groups.map((g) => ({ + importTarget: { ...g.import_target }, + id: g.id, + })), }; this.saveImportStatesToStorage(); } updateImportProgress(importId, status) { - const currentState = this.importStates[this.getStorageKey(importId)]; + const currentState = this.importStates[importId]; if (!currentState) { return; } @@ -52,12 +55,15 @@ export class SourceGroupsManager { this.saveImportStatesToStorage(); } + getImportedGroupsByJobId(jobId) { + return this.importStates[jobId]?.groups ?? []; + } + getImportStateFromStorageByGroupId(groupId) { - const PREFIX = this.getStorageKey(''); const [jobId, importState] = - Object.entries(this.importStates).find( - ([key, state]) => key.startsWith(PREFIX) && state.groups.some((g) => g.id === groupId), - ) ?? []; + Object.entries(this.importStates) + .reverse() + .find(([, state]) => state.groups.some((g) => g.id === groupId)) ?? []; if (!jobId) { return null; @@ -67,10 +73,6 @@ export class SourceGroupsManager { return { jobId, importState: { ...group, status: importState.status } }; } - getStorageKey(importId) { - return `${this.sourceUrl}|${importId}`; - } - saveImportStatesToStorage = debounce(() => { try { // storage might be changed in other tab so fetch first |