mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
fix: filter for projects
This commit is contained in:
parent
fc15144a15
commit
718c4fa608
@ -8,6 +8,16 @@ import { loadNameFromHash } from './util';
|
|||||||
|
|
||||||
const defaultStrategy = { name: 'default' };
|
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 {
|
class WrapperComponent extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -126,7 +136,7 @@ const mapDispatchToProps = dispatch => ({
|
|||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
const settings = state.settings.toJS().feature || {};
|
const settings = state.settings.toJS().feature || {};
|
||||||
const currentProjectId = settings.currentProjectId || 'default';
|
const currentProjectId = resolveCurrentProjectId(settings);
|
||||||
|
|
||||||
return { currentProjectId };
|
return { currentProjectId };
|
||||||
};
|
};
|
||||||
|
@ -10,7 +10,7 @@ export const mapStateToPropsConfigurable = isFeature => state => {
|
|||||||
const settings = state.settings.toJS().feature || {};
|
const settings = state.settings.toJS().feature || {};
|
||||||
let features = isFeature ? state.features.toJS() : state.archive.get('list').toArray();
|
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);
|
features = features.filter(f => f.project === settings.currentProjectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { Menu, MenuItem } from 'react-mdl';
|
|||||||
import { DropdownButton } from '../common';
|
import { DropdownButton } from '../common';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
const ALL_PROJECTS = { id: undefined, name: '> All projects' };
|
const ALL_PROJECTS = { id: '*', name: '> All projects' };
|
||||||
|
|
||||||
function projectItem(selectedId, item) {
|
function projectItem(selectedId, item) {
|
||||||
return (
|
return (
|
||||||
|
@ -6,9 +6,7 @@ import { USER_LOGOUT, USER_LOGIN } from '../user/actions';
|
|||||||
const localStorage = window.localStorage || {};
|
const localStorage = window.localStorage || {};
|
||||||
const SETTINGS = 'settings';
|
const SETTINGS = 'settings';
|
||||||
|
|
||||||
const DEFAULT = fromJS({
|
const DEFAULT = fromJS({});
|
||||||
feature: { currentProjectId: 'default' },
|
|
||||||
});
|
|
||||||
|
|
||||||
function getInitState() {
|
function getInitState() {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user