aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2017-05-09 16:40:53 +0200
committerStas Vilchik <stas-vilchik@users.noreply.github.com>2017-05-10 09:40:15 +0200
commite8eb4c2591dd1645509d07036a9dadc474eb58f1 (patch)
tree0f40571f056e29f01f3f126e0bdeab1c6288a77c /server/sonar-web/src/main/js/apps
parent4131f3c791ed790259ff94604f48426023d905a3 (diff)
downloadsonarqube-e8eb4c2591dd1645509d07036a9dadc474eb58f1.tar.gz
sonarqube-e8eb4c2591dd1645509d07036a9dadc474eb58f1.zip
SONAR-9175 Remember the last selection for My Issues / All filter
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/App.js6
-rw-r--r--server/sonar-web/src/main/js/apps/issues/utils.js21
2 files changed, 26 insertions, 1 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.js b/server/sonar-web/src/main/js/apps/issues/components/App.js
index 6361d5cc85f..a91ef8ea68f 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/App.js
+++ b/server/sonar-web/src/main/js/apps/issues/components/App.js
@@ -40,7 +40,8 @@ import {
getOpen,
serializeQuery,
parseFacets,
- mapFacet
+ mapFacet,
+ saveMyIssues
} from '../utils';
import type {
Query,
@@ -524,6 +525,9 @@ export default class App extends React.PureComponent {
handleMyIssuesChange = (myIssues: boolean) => {
this.closeFacet('assignees');
+ if (!this.props.component) {
+ saveMyIssues(myIssues);
+ }
this.props.router.push({
pathname: this.props.location.pathname,
query: {
diff --git a/server/sonar-web/src/main/js/apps/issues/utils.js b/server/sonar-web/src/main/js/apps/issues/utils.js
index 712b00024db..140aea14e25 100644
--- a/server/sonar-web/src/main/js/apps/issues/utils.js
+++ b/server/sonar-web/src/main/js/apps/issues/utils.js
@@ -244,3 +244,24 @@ export const searchAssignees = (query: string, component?: Component) => {
}))
);
};
+
+const LOCALSTORAGE_KEY = 'sonarqube.issues.default';
+const LOCALSTORAGE_MY = 'my';
+const LOCALSTORAGE_ALL = 'all';
+
+export const isMySet = (): boolean => {
+ 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
+ }
+};
+
+export const saveMyIssues = (myIssues: boolean) =>
+ save(myIssues ? LOCALSTORAGE_MY : LOCALSTORAGE_ALL);