diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2017-05-09 16:40:53 +0200 |
---|---|---|
committer | Stas Vilchik <stas-vilchik@users.noreply.github.com> | 2017-05-10 09:40:15 +0200 |
commit | e8eb4c2591dd1645509d07036a9dadc474eb58f1 (patch) | |
tree | 0f40571f056e29f01f3f126e0bdeab1c6288a77c /server/sonar-web | |
parent | 4131f3c791ed790259ff94604f48426023d905a3 (diff) | |
download | sonarqube-e8eb4c2591dd1645509d07036a9dadc474eb58f1.tar.gz sonarqube-e8eb4c2591dd1645509d07036a9dadc474eb58f1.zip |
SONAR-9175 Remember the last selection for My Issues / All filter
Diffstat (limited to 'server/sonar-web')
3 files changed, 28 insertions, 2 deletions
diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.js b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.js index d33107fca5f..1cedcf94211 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.js +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.js @@ -21,6 +21,7 @@ import React from 'react'; import { Link } from 'react-router'; import { translate } from '../../../../helpers/l10n'; import { isUserAdmin } from '../../../../helpers/users'; +import { isMySet } from '../../../../apps/issues/utils'; export default class GlobalNavMenu extends React.PureComponent { static propTypes = { @@ -61,7 +62,7 @@ export default class GlobalNavMenu extends React.PureComponent { } renderIssuesLink() { - const query = this.props.currentUser.isLoggedIn + const query = this.props.currentUser.isLoggedIn && isMySet() ? { resolved: 'false', myIssues: 'true' } : { resolved: 'false' }; const active = this.props.location.pathname === 'issues'; 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); |