aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/issues/utils.ts
diff options
context:
space:
mode:
authorPascal Mugnier <pascal.mugnier@sonarsource.com>2018-04-16 08:29:08 +0200
committerSonarTech <sonartech@sonarsource.com>2018-04-16 20:20:47 +0200
commitee0cd4ea0df3e71d1fceced8255ce5a01c98cc4e (patch)
treeaee6a02f0404c4f0d5b29f35d54df06b21e87182 /server/sonar-web/src/main/js/apps/issues/utils.ts
parent3ee8ec8dec07179ea5eb72cf7e3a5cc584f5734c (diff)
downloadsonarqube-ee0cd4ea0df3e71d1fceced8255ce5a01c98cc4e.tar.gz
sonarqube-ee0cd4ea0df3e71d1fceced8255ce5a01c98cc4e.zip
SONAR-10580 Local storage references should not use window.localStorage (#145)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues/utils.ts')
-rw-r--r--server/sonar-web/src/main/js/apps/issues/utils.ts17
1 files changed, 4 insertions, 13 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts
index 0423bc1ee64..82df6728898 100644
--- a/server/sonar-web/src/main/js/apps/issues/utils.ts
+++ b/server/sonar-web/src/main/js/apps/issues/utils.ts
@@ -21,6 +21,7 @@ import { searchMembers } from '../../api/organizations';
import { searchUsers } from '../../api/users';
import { Issue } from '../../app/types';
import { formatMeasure } from '../../helpers/measures';
+import { get, save } from '../../helpers/storage';
import {
queriesEqual,
cleanQuery,
@@ -63,6 +64,7 @@ export interface Query {
// allow sorting by CREATION_DATE only
const parseAsSort = (sort: string) => (sort === 'CREATION_DATE' ? 'CREATION_DATE' : '');
+const ISSUES_DEFAULT = 'sonarqube.issues.default';
export function parseQuery(query: RawQuery): Query {
return {
@@ -208,26 +210,15 @@ export const searchAssignees = (query: string, organization?: string) => {
);
};
-const LOCALSTORAGE_KEY = 'sonarqube.issues.default';
const LOCALSTORAGE_MY = 'my';
const LOCALSTORAGE_ALL = 'all';
export const isMySet = () => {
- const setting = window.localStorage.getItem(LOCALSTORAGE_KEY);
- return setting === LOCALSTORAGE_MY;
-};
-
-const save = (value: string) => {
- try {
- window.localStorage.setItem(LOCALSTORAGE_KEY, value);
- } catch (e) {
- // usually that means the storage is full
- // just do nothing in this case
- }
+ return get(ISSUES_DEFAULT) === LOCALSTORAGE_MY;
};
export const saveMyIssues = (myIssues: boolean) =>
- save(myIssues ? LOCALSTORAGE_MY : LOCALSTORAGE_ALL);
+ save(ISSUES_DEFAULT, myIssues ? LOCALSTORAGE_MY : LOCALSTORAGE_ALL);
export function getLocations(
{ flows, secondaryLocations }: Pick<Issue, 'flows' | 'secondaryLocations'>,