Skip to content

Commit

Permalink
Merge branch 'feature-issue-table' into 'master-0.24.0'
Browse files Browse the repository at this point in the history
[IMP]优化类型

See merge request hzero-agile/agile-service!1033
  • Loading branch information
王坤奇 committed Sep 15, 2020
2 parents 794a0c1 + b016d12 commit d79173d
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 34 deletions.
7 changes: 5 additions & 2 deletions react/components/charts/sprint/useSprintReport.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import useBurnDownReport from '../burn-down/useBurnDownReport';
import useBurnDownReport, { BurnDownConfig } from '../burn-down/useBurnDownReport';

function useSprintReport() {
export type SprintConfig = Omit<BurnDownConfig, 'type'>

function useSprintReport(config?: SprintConfig) {
return useBurnDownReport({
type: 'issueCount',
...config,
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import Sprint from '@/components/charts/sprint';
import useSprintReport, { SprintConfig } from '@/components/charts/sprint/useSprintReport';

interface Props {
filter: SprintConfig
}
const SprintComponent: React.FC<Props> = ({ filter }) => {
const [, props] = useSprintReport(filter);
return (
<div>
<Sprint {...props} />
</div>
);
};
export default SprintComponent;
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
import React from 'react';
import { IReportBlock } from '@/routes/project-report/create-report/store';
import { IReportChartBlock } from '@/routes/project-report/create-report/store';
import BurnDownBlock from './components/burndown';
import SprintBlock from './components/sprint';

const ChartMap = new Map([
['burndown', BurnDownBlock],
['sprint', SprintBlock],
]);
interface Props {
data: IReportBlock
data: IReportChartBlock
}
const ChartBlock: React.FC<Props> = ({ data: { data } }) => {
// const ChartBlockComponent = ChartMap.get(dataSet.current?.get('chart'));
const ChartBlockComponent = ChartMap.get(data.chartType);
const ChartBlock: React.FC<Props> = ({ data: { data, chartType } }) => {
const ChartBlockComponent = ChartMap.get(chartType);
return (
<>
{ChartBlockComponent && (
<ChartBlockComponent filter={{
type: 'issueCount',
sprintId: '=xFlL48OlIBm6InJtxh7OA6pF-SWg1-_JQGrtR1P3sj4==',
quickFilter: {
onlyStory: false,
onlyMe: true,
quickFilters: [],
personalFilters: [],
},
restDayShow: false,
}}
/>
<ChartBlockComponent filter={data.filter} />
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import WYSIWYGViewer from '@/components/WYSIWYGViewer';
import { IReportBlock } from '@/routes/project-report/create-report/store';
import { IReportTextBlock } from '@/routes/project-report/create-report/store';

interface Props {
data: IReportBlock
data: IReportTextBlock
}
const TextBlock: React.FC<Props> = ({ data: { data } }) => <WYSIWYGViewer data={data} />;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
import React from 'react';
import React, { useCallback } from 'react';
import { Button } from 'choerodon-ui/pro';
import { ButtonColor } from 'choerodon-ui/pro/lib/button/enum';
import styles from './index.less';
import { IReportBlock } from '../../store';
import { IReportBlock, IReportTextBlock, IReportChartBlock } from '../../store';
import TextBlock from './components/text-block';
import ChartBlock from './components/chart-block';

interface Props {
data: IReportBlock

}
const BlockMap = new Map([
['text', TextBlock],
['chart', ChartBlock],
]);

const ReportBlock: React.FC<Props> = ({ data }) => {
const { title, type } = data;
const BlockComponent = BlockMap.get(type);
const renderBlock = useCallback(() => {
switch (type) {
case 'text': {
return <TextBlock data={data as IReportTextBlock} />;
}
case 'chart': {
return <ChartBlock data={data as IReportChartBlock} />;
}
default: {
return null;
}
}
}, [data, type]);
return (
<div className={styles.report_block}>
<div className={styles.header}>
Expand All @@ -26,7 +34,7 @@ const ReportBlock: React.FC<Props> = ({ data }) => {
<Button icon="delete" color={'blue' as ButtonColor}>删除</Button>
</div>
</div>
{BlockComponent && <BlockComponent data={data} />}
{renderBlock()}
</div>
);
};
Expand Down
53 changes: 49 additions & 4 deletions react/routes/project-report/create-report/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,32 @@ import {
observable, action, computed, runInAction,
} from 'mobx';
import { IReportContentType } from '@/common/types';
import { BurnDownConfig } from '@/components/charts/burn-down/useBurnDownReport';
import { SprintConfig } from '@/components/charts/sprint/useSprintReport';

export interface IReportBlock {
export type IChartType = 'burndown' | 'sprint'

interface IBaseReportBlock {
id: string
title: string
type: IReportContentType
data: any
}

export interface IReportChartBlock extends IBaseReportBlock {
chartType: IChartType
data: {
filter: BurnDownConfig | SprintConfig
}
}
export interface IReportListBlock extends IBaseReportBlock {
data: {
filter: any
}
}
export interface IReportTextBlock extends IBaseReportBlock {
data: string
}
export type IReportBlock = IReportTextBlock | IReportListBlock | IReportChartBlock
class ProjectReportStore {
@observable blockList: IReportBlock[] = [{
id: '1',
Expand All @@ -27,9 +45,36 @@ class ProjectReportStore {
id: '2',
title: '上周未完成的工作项(图表标题)',
type: 'chart',
chartType: 'burndown',
data: {
chartType: 'burndown',
filter: {},
filter: {
type: 'issueCount',
sprintId: '=xFlL48OlIBm6InJtxh7OA6pF-SWg1-_JQGrtR1P3sj4==',
quickFilter: {
onlyStory: false,
onlyMe: true,
quickFilters: [],
personalFilters: [],
},
restDayShow: false,
},
},
}, {
id: '3',
title: '上周未完成的工作项(图表标题)',
type: 'chart',
chartType: 'sprint',
data: {
filter: {
sprintId: '=xFlL48OlIBm6InJtxh7OA6pF-SWg1-_JQGrtR1P3sj4==',
quickFilter: {
onlyStory: false,
onlyMe: true,
quickFilters: [],
personalFilters: [],
},
restDayShow: false,
},
},
}]
}
Expand Down

0 comments on commit d79173d

Please sign in to comment.