Skip to content

Commit

Permalink
Feat: add organization filter (#352)
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 b6da736 commit ea412a7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/web/i18n
Submodule i18n updated 2 files
+1 −1 en/analyze.json
+1 −0 zh/analyze.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import React, { useState } from 'react';
import { Button, Input } from 'antd';
import { useTranslation } from 'next-i18next';

const ContributorDropdown = ({ selectedKeys, setSelectedKeys, confirm }) => {
const ContributorDropdown = ({
selectedKeys,
setSelectedKeys,
confirm,
placeholder,
}) => {
const { t } = useTranslation();
const [contributor, setContributor] = useState(selectedKeys);

Expand All @@ -17,7 +22,7 @@ const ContributorDropdown = ({ selectedKeys, setSelectedKeys, confirm }) => {
return (
<div style={{ padding: 8 }} onKeyDown={(e) => e.stopPropagation()}>
<Input
placeholder={t('analyze:metric_detail:search_contributor')}
placeholder={placeholder}
value={contributor[0]}
onChange={(e) => setContributor([e.target.value])}
onPressEnter={() => handleSearch()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ const MetricTable: React.FC<{
selectedKeys={selectedKeys}
setSelectedKeys={setSelectedKeys}
confirm={confirm}
placeholder={t('analyze:metric_detail:search_contributor')}
/>
);
},
Expand Down Expand Up @@ -299,6 +300,25 @@ const MetricTable: React.FC<{
</div>
);
},
filterIcon: (filtered: boolean) => (
<AiFillFilter
className="text-sm"
style={{ color: filtered ? '#1677ff' : undefined }}
/>
),
defaultFilteredValue:
defaultFilterOpts.find((i) => i.type === 'organization')?.values ||
null,
filterDropdown: ({ selectedKeys, setSelectedKeys, confirm }) => {
return (
<ContributorDropdown
selectedKeys={selectedKeys}
setSelectedKeys={setSelectedKeys}
confirm={confirm}
placeholder={t('analyze:metric_detail:search_organization')}
/>
);
},
},
{
title: t('analyze:metric_detail:contribution'),
Expand Down

0 comments on commit ea412a7

Please sign in to comment.