Skip to content

Commit

Permalink
Feat: fix community filter bug (#351)
Browse files Browse the repository at this point in the history
Signed-off-by: laixingyou <[email protected]>
  • Loading branch information
coder-sett authored May 9, 2024
1 parent ff69469 commit b6da736
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const EcoContributorContribution: React.FC<{
level: level,
beginDate: beginDate,
endDate: endDate,
filterOpts: commonFilterOpts,
// filterOpts: commonFilterOpts,
});
const getEcologicalText = useGetEcologicalText();
const getSeries = useMemo(() => {
Expand Down Expand Up @@ -310,7 +310,7 @@ const OrgContributorContribution: React.FC<{
level: level,
beginDate: beginDate,
endDate: endDate,
filterOpts: commonFilterOpts,
// filterOpts: commonFilterOpts,
});
const getEcologicalText = useGetEcologicalText();
const getSeries = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ContributorContribution: React.FC<{
level: level,
beginDate: beginDate,
endDate: endDate,
filterOpts: commonFilterOpts,
// filterOpts: commonFilterOpts,
});
const getSeries = useMemo(() => {
const legend = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const ContributorContributors: React.FC<{
level: level,
beginDate: beginDate,
endDate: endDate,
filterOpts: commonFilterOpts,
// filterOpts: commonFilterOpts,
});

const getSeries = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const MetricContributor = () => {
? JSON.parse(queryMileage)
: ['core', 'regular'];
const [mileage, setMileage] = useState<string[]>(defaultMileage);
const [isBot, setIsBot] = useState(true);
const [isBot, setIsBot] = useState(false);
const [repoList, setRepoList] = useState([]);

const onMileageChange = (checkedValues: string[]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IssueDetail[]>();
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -34,6 +39,7 @@ const MetricIssue = () => {
level={level}
beginDate={timeStart}
endDate={timeEnd}
commonFilterOpts={commonFilterOpts}
/>
);
break;
Expand Down Expand Up @@ -67,6 +73,7 @@ const MetricIssue = () => {
level={level}
beginDate={timeStart}
endDate={timeEnd}
commonFilterOpts={commonFilterOpts}
/>
);
break;
Expand All @@ -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"
>
<DetailHeaderFilter level={level} label={label} type={'issue'} />
<DetailHeaderFilter
onRepoChange={(v) => setRepoList(v)}
level={level}
label={label}
type={'issue'}
/>
<Tabs
classes={{ flexContainer: 'border-b', indicator: '!bg-black' }}
value={tab}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PullDetail[]>();
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const MetricPr = () => {
level={level}
beginDate={timeStart}
endDate={timeEnd}
commonFilterOpts={commonFilterOpts}
/>
);
break;
Expand Down Expand Up @@ -70,6 +71,7 @@ const MetricPr = () => {
level={level}
beginDate={timeStart}
endDate={timeEnd}
commonFilterOpts={commonFilterOpts}
/>
);
break;
Expand All @@ -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"
>
<DetailHeaderFilter level={level} label={label} type={'pr'} />
<DetailHeaderFilter
level={level}
label={label}
onRepoChange={(v) => setRepoList(v)}
type={'pr'}
/>
<Tabs
classes={{ flexContainer: 'border-b', indicator: '!bg-black' }}
value={tab}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const CommunityFilter = ({ label, onRepoChange }) => {
<Select
mode="multiple"
value={value}
maxTagCount={'responsive'}
maxTagCount={selectState ? 0 : 'responsive'}
maxTagPlaceholder={() =>
selectState ? (
<span>{t('analyze:metric_detail:all_repos')}</span>
Expand All @@ -60,7 +60,7 @@ const CommunityFilter = ({ label, onRepoChange }) => {
onRepoChange(newValue);
}
}}
style={{ width: 130 }}
style={{ width: 200 }}
// allowClear
dropdownRender={(menu) => (
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const DetailHeaderFilter: React.FC<{
isBot?: boolean;
onBotChange?: (v) => void;
onRepoChange?: (v) => void;
}> = ({ type, label, isBot, onBotChange, onRepoChange }) => {
}> = ({ type, level, label, isBot, onBotChange, onRepoChange }) => {
const { t } = useTranslation();

const isBotOptions = [
Expand All @@ -26,34 +26,66 @@ const DetailHeaderFilter: React.FC<{
if (type == 'issue') {
return (
<>
<div className="mb-1 text-lg font-semibold text-[#000000]">
{t('analyze:metric_detail:issues')}
</div>
{level === 'community1' ? (
<CommunityFilter
label={label}
onRepoChange={(v) => onRepoChange(v)}
/>
) : (
<div className="mb-1 text-lg font-semibold text-[#000000]">
{t('analyze:metric_detail:issues')}
</div>
)}
</>
);
} else if (type == 'pr') {
return (
<>
<div className="mb-1 text-lg font-semibold text-[#000000]">
{t('analyze:metric_detail:pull_requests')}
</div>
{level === 'community1' ? (
<CommunityFilter
label={label}
onRepoChange={(v) => onRepoChange(v)}
/>
) : (
<div className="mb-1 text-lg font-semibold text-[#000000]">
{t('analyze:metric_detail:pull_requests')}
</div>
)}
</>
);
} else {
return (
<div className="flex gap-2">
{level === 'community' ? (
<>
<CommunityFilter
label={label}
onRepoChange={(v) => onRepoChange(v)}
/>
<Select
style={{ width: 130 }}
onChange={(v) => {
onBotChange(v);
// handleQueryParams({ tab: v });
}}
value={isBot}
options={isBotOptions}
/>
</>
) : (
<Select
style={{ width: 130 }}
onChange={(v) => {
onBotChange(v);
// handleQueryParams({ tab: v });
}}
value={isBot}
options={isBotOptions}
/>
)}
</div>
);
}
return (
<div className="flex gap-2">
<CommunityFilter label={label} onRepoChange={(v) => onRepoChange(v)} />
<Select
style={{ width: 130 }}
onChange={(v) => {
onBotChange(v);
// handleQueryParams({ tab: v });
}}
value={isBot}
options={isBotOptions}
/>
</div>
);
};

export default DetailHeaderFilter;

0 comments on commit b6da736

Please sign in to comment.