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 = {
}
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';
getOpen,
serializeQuery,
parseFacets,
- mapFacet
+ mapFacet,
+ saveMyIssues
} from '../utils';
import type {
Query,
handleMyIssuesChange = (myIssues: boolean) => {
this.closeFacet('assignees');
+ if (!this.props.component) {
+ saveMyIssues(myIssues);
+ }
this.props.router.push({
pathname: this.props.location.pathname,
query: {
}))
);
};
+
+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);