summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jira_import
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-13 18:09:16 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-13 18:09:16 +0000
commitd9aac35d79489591396456aceefa609de4b8b05c (patch)
tree3ef25ee74f8ba1a72771a519c912d5e239ff2bb8 /app/assets/javascripts/jira_import
parentff430539d5299de3a066cb8397b302626761a745 (diff)
downloadgitlab-ce-d9aac35d79489591396456aceefa609de4b8b05c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/jira_import')
-rw-r--r--app/assets/javascripts/jira_import/utils/jira_import_utils.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/assets/javascripts/jira_import/utils/jira_import_utils.js b/app/assets/javascripts/jira_import/utils/jira_import_utils.js
index e82a3f44a29..a1186b087e1 100644
--- a/app/assets/javascripts/jira_import/utils/jira_import_utils.js
+++ b/app/assets/javascripts/jira_import/utils/jira_import_utils.js
@@ -1,4 +1,5 @@
import { last } from 'lodash';
+import { JIRA_IMPORT_SUCCESS_ALERT_HIDE_MAP_KEY } from '~/issuables_list/constants';
export const IMPORT_STATE = {
FAILED: 'failed',
@@ -68,3 +69,36 @@ export const calculateJiraImportLabel = (jiraImports, labels) => {
title,
};
};
+
+/**
+ * Calculates whether the Jira import success alert should be shown.
+ *
+ * @param {string} labelTitle - Jira import label, for checking localStorage
+ * @param {string} importStatus - Jira import status
+ * @returns {boolean} - A boolean indicating whether to show the success alert
+ */
+export const shouldShowFinishedAlert = (labelTitle, importStatus) => {
+ const finishedAlertHideMap =
+ JSON.parse(localStorage.getItem(JIRA_IMPORT_SUCCESS_ALERT_HIDE_MAP_KEY)) || {};
+
+ const shouldHide = finishedAlertHideMap[labelTitle];
+
+ return !shouldHide && isFinished(importStatus);
+};
+
+/**
+ * Updates the localStorage map to permanently hide the Jira import success alert
+ *
+ * @param {string} labelTitle - Jira import label, for checking localStorage
+ */
+export const setFinishedAlertHideMap = labelTitle => {
+ const finishedAlertHideMap =
+ JSON.parse(localStorage.getItem(JIRA_IMPORT_SUCCESS_ALERT_HIDE_MAP_KEY)) || {};
+
+ finishedAlertHideMap[labelTitle] = true;
+
+ localStorage.setItem(
+ JIRA_IMPORT_SUCCESS_ALERT_HIDE_MAP_KEY,
+ JSON.stringify(finishedAlertHideMap),
+ );
+};