From 4852751d624eb0d1faea7303a493c2c39097e37b Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Thu, 5 Oct 2017 13:01:19 +0530 Subject: [PATCH] =?UTF-8?q?Github=20issue#1212,=20Filter=20project=20types?= =?UTF-8?q?=20in=20admin=20view=20=E2=80=94=20Fixed.=20Made=20the=20list?= =?UTF-8?q?=20of=20the=20project=20types=20to=20be=20dynamic.=20It=20was?= =?UTF-8?q?=20hard=20coded=20earlier=20because=20earlier=20we=20were=20sho?= =?UTF-8?q?wing=20different=20label=20in=20filters=20than=20what=20we=20ha?= =?UTF-8?q?ve=20in=20the=20projectWizard/index.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TopBar/Filters.js | 18 +++++++----------- src/config/projectWizard/index.js | 3 +++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/components/TopBar/Filters.js b/src/components/TopBar/Filters.js index df3aa2d69..205fbbc7b 100644 --- a/src/components/TopBar/Filters.js +++ b/src/components/TopBar/Filters.js @@ -2,14 +2,7 @@ import React, {PropTypes} from 'react' import _ from 'lodash' import { Dropdown, DropdownItem, SwitchButton } from 'appirio-tech-react-components' import { PROJECT_STATUS } from '../../config/constants' - -const projectTypes = [ - { val: null, label: 'All Types' }, - { val: 'generic', label: 'Work Project' }, - { val: 'visual_design', label: 'Visual Design' }, - { val: 'visual_prototype', label: 'Visual Prototype' }, - { val: 'app_dev', label: 'App Development' } -] +import { projectTypes } from '../../config/projectWizard' const projectStatuses = [ { val: 'in(draft,in_review,reviewed,active)', label: 'Open' }, @@ -19,12 +12,15 @@ const projectStatuses = [ const Filters = ({ criteria, handleMyProjectsFilter, applyFilters }) => { - const type = _.find(projectTypes, t => t.val === (criteria.type || null)) + const type = _.find(projectTypes, t => t.id === (criteria.type || null)) const status = _.find(projectStatuses, t => t.val === (criteria.status || null)) const _types = _.map(projectTypes, p => { - return { val: { type: p.val }, label: p.label } + return { val: { type: p.id }, label: p.name } }) + // adds null valued object for All Types selection + _types.splice(0, 0, { val: { type: null}, label: 'All Types' }) + const _statuses = _.map(projectStatuses, p => { return { val: { status: p.val }, label: p.label } }) @@ -36,7 +32,7 @@ const Filters = ({ criteria, handleMyProjectsFilter, applyFilters }) => {
- { type.label || 'All Types' } + { _.get(type, 'name') || 'All Types' }
    { _types.map((item, i) => diff --git a/src/config/projectWizard/index.js b/src/config/projectWizard/index.js index 2cbac67bf..345067960 100644 --- a/src/config/projectWizard/index.js +++ b/src/config/projectWizard/index.js @@ -171,6 +171,9 @@ const products = { export default products +// exports all project types as an array +export const projectTypes = _.mapValues(products, (p, key) => ({...p, name: key }) ) + export function findProduct(product) { if (product === 'generic_dev') { return 'Development'