From 718c4fa60899f73e6c74f119a9336d9dc59bb742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Mon, 23 Nov 2020 21:32:05 +0100 Subject: [PATCH] fix: filter for projects --- .../feature/form/form-add-feature-container.jsx | 12 +++++++++++- frontend/src/component/feature/list-container.jsx | 2 +- frontend/src/component/feature/project-component.jsx | 2 +- frontend/src/store/settings/index.js | 4 +--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/src/component/feature/form/form-add-feature-container.jsx b/frontend/src/component/feature/form/form-add-feature-container.jsx index a8618fb945..9049d25115 100644 --- a/frontend/src/component/feature/form/form-add-feature-container.jsx +++ b/frontend/src/component/feature/form/form-add-feature-container.jsx @@ -8,6 +8,16 @@ import { loadNameFromHash } from './util'; const defaultStrategy = { name: 'default' }; +function resolveCurrentProjectId(settings) { + if (!settings.currentProjectId) { + return 'default'; + } else if (settings.currentProjectId === '*') { + return 'default'; + } else { + return settings.currentProjectId; + } +} + class WrapperComponent extends Component { constructor(props) { super(props); @@ -126,7 +136,7 @@ const mapDispatchToProps = dispatch => ({ const mapStateToProps = state => { const settings = state.settings.toJS().feature || {}; - const currentProjectId = settings.currentProjectId || 'default'; + const currentProjectId = resolveCurrentProjectId(settings); return { currentProjectId }; }; diff --git a/frontend/src/component/feature/list-container.jsx b/frontend/src/component/feature/list-container.jsx index ce07edbf44..f3e4be8f88 100644 --- a/frontend/src/component/feature/list-container.jsx +++ b/frontend/src/component/feature/list-container.jsx @@ -10,7 +10,7 @@ export const mapStateToPropsConfigurable = isFeature => state => { const settings = state.settings.toJS().feature || {}; let features = isFeature ? state.features.toJS() : state.archive.get('list').toArray(); - if (settings.currentProjectId) { + if (settings.currentProjectId && settings.currentProjectId !== '*') { features = features.filter(f => f.project === settings.currentProjectId); } diff --git a/frontend/src/component/feature/project-component.jsx b/frontend/src/component/feature/project-component.jsx index e4023d2a96..44d76d8f05 100644 --- a/frontend/src/component/feature/project-component.jsx +++ b/frontend/src/component/feature/project-component.jsx @@ -3,7 +3,7 @@ import { Menu, MenuItem } from 'react-mdl'; import { DropdownButton } from '../common'; import PropTypes from 'prop-types'; -const ALL_PROJECTS = { id: undefined, name: '> All projects' }; +const ALL_PROJECTS = { id: '*', name: '> All projects' }; function projectItem(selectedId, item) { return ( diff --git a/frontend/src/store/settings/index.js b/frontend/src/store/settings/index.js index 9f0cf9fa62..898152d01e 100644 --- a/frontend/src/store/settings/index.js +++ b/frontend/src/store/settings/index.js @@ -6,9 +6,7 @@ import { USER_LOGOUT, USER_LOGIN } from '../user/actions'; const localStorage = window.localStorage || {}; const SETTINGS = 'settings'; -const DEFAULT = fromJS({ - feature: { currentProjectId: 'default' }, -}); +const DEFAULT = fromJS({}); function getInitState() { try {