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

release_notification_service.js « releases « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 20fbab3241ebee4cdb527d88cff842ff6dc2caa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { s__, __, sprintf } from '~/locale';
import { createAlert, VARIANT_SUCCESS } from '~/alert';

const createReleaseSessionKey = (projectPath) => `createRelease:${projectPath}`;

export const putCreateReleaseNotification = (projectPath, releaseName) => {
  window.sessionStorage.setItem(createReleaseSessionKey(projectPath), releaseName);
};

export const popCreateReleaseNotification = (projectPath) => {
  const key = createReleaseSessionKey(projectPath);
  const createdRelease = window.sessionStorage.getItem(key);

  if (createdRelease) {
    createAlert({
      message: sprintf(s__('Release|Release %{createdRelease} has been successfully created.'), {
        createdRelease,
      }),
      variant: VARIANT_SUCCESS,
    });
    window.sessionStorage.removeItem(key);
  }
};

export const deleteReleaseSessionKey = (projectPath) => `deleteRelease:${projectPath}`;

export const putDeleteReleaseNotification = (projectPath, releaseName) => {
  window.sessionStorage.setItem(deleteReleaseSessionKey(projectPath), releaseName);
};

export const popDeleteReleaseNotification = (projectPath) => {
  const key = deleteReleaseSessionKey(projectPath);
  const deletedRelease = window.sessionStorage.getItem(key);

  if (deletedRelease) {
    createAlert({
      message: sprintf(__('Release %{deletedRelease} has been successfully deleted.'), {
        deletedRelease,
      }),
      variant: VARIANT_SUCCESS,
    });
    window.sessionStorage.removeItem(key);
  }
};