Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: fix community filter bug #351

Merged
merged 7 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading