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/ci/runner/local_storage_alert/show_alert_from_local_storage.js')
-rw-r--r--app/assets/javascripts/ci/runner/local_storage_alert/show_alert_from_local_storage.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/assets/javascripts/ci/runner/local_storage_alert/show_alert_from_local_storage.js b/app/assets/javascripts/ci/runner/local_storage_alert/show_alert_from_local_storage.js
new file mode 100644
index 00000000000..d768a06494a
--- /dev/null
+++ b/app/assets/javascripts/ci/runner/local_storage_alert/show_alert_from_local_storage.js
@@ -0,0 +1,18 @@
+import AccessorUtilities from '~/lib/utils/accessor';
+import { LOCAL_STORAGE_ALERT_KEY } from './constants';
+
+export const showAlertFromLocalStorage = async () => {
+ if (AccessorUtilities.canUseLocalStorage()) {
+ const alertOptions = localStorage.getItem(LOCAL_STORAGE_ALERT_KEY);
+
+ if (alertOptions) {
+ try {
+ const { createAlert } = await import('~/flash');
+ createAlert(JSON.parse(alertOptions));
+ } catch {
+ // ignore when the alert data cannot be parsed
+ }
+ }
+ localStorage.removeItem(LOCAL_STORAGE_ALERT_KEY);
+ }
+};