diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueTable.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueTable.tsx index 49fedd0b..4ea9540c 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueTable.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueTable.tsx @@ -28,7 +28,8 @@ const MetricTable: React.FC<{ level: string; beginDate: Date; endDate: Date; -}> = ({ label, level, beginDate, endDate }) => { + commonFilterOpts: any[]; +}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => { const { t } = useTranslation(); const stateOption = useStateType(); const [tableData, setData] = useState(); @@ -52,7 +53,7 @@ const MetricTable: React.FC<{ const query = { page: tableParams.pagination.current, per: tableParams.pagination.pageSize, - filterOpts: tableParams.filterOpts, + filterOpts: [...tableParams.filterOpts, ...commonFilterOpts], sortOpts: tableParams.sortOpts, label, level, diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/index.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/index.tsx index 76e31259..bb3a5e9b 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/index.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/index.tsx @@ -19,12 +19,17 @@ const MetricIssue = () => { const { label, level } = verifiedItems[0]; const { t } = useTranslation(); const queryCard = router.query?.card as string; - const [isBot, setIsBot] = useState(true); + const [repoList, setRepoList] = useState([]); + const [tab, setTab] = useState(queryCard || '1'); + const commonFilterOpts = useMemo(() => { let opts = []; + if (repoList.length > 0) { + opts.push({ type: 'repo_urls', values: repoList }); + } return opts; - }, [isBot]); + }, [repoList]); let source; switch (tab) { case '1': { @@ -34,6 +39,7 @@ const MetricIssue = () => { level={level} beginDate={timeStart} endDate={timeEnd} + commonFilterOpts={commonFilterOpts} /> ); break; @@ -67,6 +73,7 @@ const MetricIssue = () => { level={level} beginDate={timeStart} endDate={timeEnd} + commonFilterOpts={commonFilterOpts} /> ); break; @@ -77,7 +84,12 @@ const MetricIssue = () => { // title={t('analyze:metric_detail:contributor')} className="relative flex h-full min-w-0 flex-1 flex-col overflow-hidden rounded-lg border-2 border-transparent bg-white p-4 drop-shadow-sm md:rounded-none" > - + setRepoList(v)} + level={level} + label={label} + type={'issue'} + /> = ({ label, level, beginDate, endDate }) => { + commonFilterOpts: any[]; +}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => { const { t } = useTranslation(); const stateOption = useStateType(); const [tableData, setData] = useState(); @@ -51,7 +52,7 @@ const MetricTable: React.FC<{ const query = { page: tableParams.pagination.current, per: tableParams.pagination.pageSize, - filterOpts: tableParams.filterOpts, + filterOpts: [...tableParams.filterOpts, ...commonFilterOpts], sortOpts: tableParams.sortOpts, label, level, diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/index.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/index.tsx index 1e2e8920..126bdbb9 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/index.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/index.tsx @@ -37,6 +37,7 @@ const MetricPr = () => { level={level} beginDate={timeStart} endDate={timeEnd} + commonFilterOpts={commonFilterOpts} /> ); break; @@ -70,6 +71,7 @@ const MetricPr = () => { level={level} beginDate={timeStart} endDate={timeEnd} + commonFilterOpts={commonFilterOpts} /> ); break; @@ -80,7 +82,12 @@ const MetricPr = () => { // title={t('analyze:metric_detail:contributor')} className="relative flex h-full min-w-0 flex-1 flex-col overflow-hidden rounded-lg border-2 border-transparent bg-white p-4 drop-shadow-sm md:rounded-none" > - + setRepoList(v)} + type={'pr'} + /> void; onRepoChange?: (v) => void; -}> = ({ type, label, isBot, onBotChange, onRepoChange }) => { +}> = ({ type, level, label, isBot, onBotChange, onRepoChange }) => { const { t } = useTranslation(); const isBotOptions = [ @@ -26,34 +26,55 @@ const DetailHeaderFilter: React.FC<{ if (type == 'issue') { return ( <> -
- {t('analyze:metric_detail:issues')} -
+ {level === 'community' ? ( + onRepoChange(v)} + /> + ) : ( +
+ {t('analyze:metric_detail:issues')} +
+ )} ); } else if (type == 'pr') { return ( <> -
- {t('analyze:metric_detail:pull_requests')} -
+ {level === 'community' ? ( + onRepoChange(v)} + /> + ) : ( +
+ {t('analyze:metric_detail:pull_requests')} +
+ )} ); + } else { + return ( +
+ {level === 'community' ? ( + onRepoChange(v)} + /> + ) : ( + { - onBotChange(v); - // handleQueryParams({ tab: v }); - }} - value={isBot} - options={isBotOptions} - /> -
- ); }; export default DetailHeaderFilter;