diff --git a/apps/web/i18n b/apps/web/i18n index 4d32a5f0..8d87ffbe 160000 --- a/apps/web/i18n +++ b/apps/web/i18n @@ -1 +1 @@ -Subproject commit 4d32a5f0bbc3158b5e6f43c95595ec4e5078b8b6 +Subproject commit 8d87ffbe7c83febdba321c939788c85f172d8a97 diff --git a/apps/web/src/common/components/Table/Download.tsx b/apps/web/src/common/components/Table/Download.tsx index f8b9e4d7..aa9db11b 100644 --- a/apps/web/src/common/components/Table/Download.tsx +++ b/apps/web/src/common/components/Table/Download.tsx @@ -7,6 +7,7 @@ import { apiDownloadFiles, Status, } from '@modules/analyze/DataView/MetricDetail/tableDownload'; +import { useTranslation } from 'react-i18next'; // 对象驼峰转下划线 const objectHumpToLine = (obj) => { @@ -27,6 +28,7 @@ const Download = ({ query: any; fileName: string; }) => { + const { t } = useTranslation(); const newQuery = objectHumpToLine(query); newQuery['sort_opts'] && (newQuery['sort_opts'] = [newQuery['sort_opts']]); @@ -66,9 +68,12 @@ const Download = ({ }; return ( <> -
+
{loadingDownLoad ? ( - + <> + + {t('analyze:metric_detail.download_data')} + ) : (
- + + {t('analyze:metric_detail.download_data')}
)} diff --git a/apps/web/src/modules/academe/DataUsageProcess/DataTerms.tsx b/apps/web/src/modules/academe/DataUsageProcess/DataTerms.tsx index 7ecc9348..c3690e71 100644 --- a/apps/web/src/modules/academe/DataUsageProcess/DataTerms.tsx +++ b/apps/web/src/modules/academe/DataUsageProcess/DataTerms.tsx @@ -68,9 +68,9 @@ const DataTerms = () => { 4. 如果该学术研究成果可进行工程化部署,在不侵犯知识产权的情况下,请同意 OSS Compass 享有此成果的使用权。
- 5. 具体细节请查看底部协议附件。 + {/* 5. 具体细节请查看底部协议附件。 */}

-

+ {/*

附: { > OSS Compass 项目合作框架协议书.pdf -

+ */}
); const enTerms = ( @@ -178,9 +178,9 @@ const DataTerms = () => { engineering without infringing intellectual property rights, please agree to OSS Compass having the right to use these results.
- 5. For specific details, please see the agreement below. + {/* 5. For specific details, please see the agreement below. */}

-

+ {/*

{ > OSS Compass Project Cooperation Framework Agreement.pdf -

+ */}
); if (i18n.language === 'en') { diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContribution.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount/ContributorContribution.tsx similarity index 95% rename from apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContribution.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount/ContributorContribution.tsx index 74a9c16e..c570cc59 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContribution.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount/ContributorContribution.tsx @@ -6,9 +6,9 @@ import { import client from '@common/gqlClient'; import { useTranslation } from 'next-i18next'; import MetricChart from '@modules/analyze/DataView/MetricDetail/MetricChart'; -import { useGetEcologicalText } from './contribution'; +import { useGetEcologicalText } from '../contribution'; import { gradientRamp } from '@common/options'; -import PieDropDownMenu from '../PieDropDownMenu'; +import PieDropDownMenu from '../../PieDropDownMenu'; import type { EChartsOption } from 'echarts'; const ContributorContribution: React.FC<{ @@ -16,8 +16,8 @@ const ContributorContribution: React.FC<{ level: string; beginDate: Date; endDate: Date; - mileage: string[]; -}> = ({ label, level, beginDate, endDate, mileage }) => { + commonFilterOpts: any[]; +}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => { const [orgModel, setOrgModel] = useState(true); const [onlyIdentity, setOnlyIdentity] = useState(false); const [onlyOrg, setOnlyOrg] = useState(false); @@ -59,7 +59,7 @@ const ContributorContribution: React.FC<{ level={level} beginDate={beginDate} endDate={endDate} - mileage={mileage} + commonFilterOpts={commonFilterOpts} /> ) : ( { @@ -301,8 +301,8 @@ const OrgContributorContribution: React.FC<{ level: string; beginDate: Date; endDate: Date; - mileage: string[]; -}> = ({ label, level, beginDate, endDate, mileage }) => { + commonFilterOpts: any[]; +}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => { const { t } = useTranslation(); const chartRef = useRef(null); const { data, isLoading } = useOrgContributionDistributionQuery(client, { @@ -310,7 +310,7 @@ const OrgContributorContribution: React.FC<{ level: level, beginDate: beginDate, endDate: endDate, - filterOpts: [{ type: 'mileage_type', values: mileage }], + filterOpts: commonFilterOpts, }); const getEcologicalText = useGetEcologicalText(); const getSeries = useMemo(() => { diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorOrganizations.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount/ContributorOrganizations.tsx similarity index 96% rename from apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorOrganizations.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount/ContributorOrganizations.tsx index 25bd0634..74fe031c 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorOrganizations.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount/ContributorOrganizations.tsx @@ -11,8 +11,8 @@ const ContributorContribution: React.FC<{ level: string; beginDate: Date; endDate: Date; - mileage: string[]; -}> = ({ label, level, beginDate, endDate, mileage }) => { + commonFilterOpts: any[]; +}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => { const { t } = useTranslation(); const chartRef = useRef(null); const { data, isLoading } = useOrgContributorsOverviewQuery(client, { @@ -20,7 +20,7 @@ const ContributorContribution: React.FC<{ level: level, beginDate: beginDate, endDate: endDate, - filterOpts: [{ type: 'mileage_type', values: mileage }], + filterOpts: commonFilterOpts, }); const getSeries = useMemo(() => { const legend = []; diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount/index.tsx similarity index 78% rename from apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount/index.tsx index d110a11f..8368b97b 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributionCount/index.tsx @@ -7,8 +7,8 @@ const ContributionCount: React.FC<{ level: string; beginDate: Date; endDate: Date; - mileage: string[]; -}> = ({ label, level, beginDate, endDate, mileage }) => { + commonFilterOpts: any[]; +}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => { return (
); diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable/index.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable/index.tsx index be31845d..ebaffc77 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable/index.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable/index.tsx @@ -49,8 +49,8 @@ const MetricTable: React.FC<{ level: string; beginDate: Date; endDate: Date; - mileage: string[]; -}> = ({ label, level, beginDate, endDate, mileage }) => { + commonFilterOpts: any[]; +}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => { const { t } = useTranslation(); const [openConfirm, setOpenConfirm] = useState(false); const [currentName, setCurrentName] = useState(''); @@ -68,14 +68,6 @@ const MetricTable: React.FC<{ const router = useRouter(); const { handleQueryParams } = useHandleQueryParams(); - const mileageFilter = useMemo(() => { - if (mileage.length > 0) { - return { type: 'mileage_type', values: mileage }; - } else { - return null; - } - }, [mileage]); - const queryFilterOpts = router.query?.filterOpts as string; const defaultFilterOpts = queryFilterOpts ? JSON.parse(queryFilterOpts) : []; const defaultSortOpts = router.query?.sortOpts @@ -101,7 +93,7 @@ const MetricTable: React.FC<{ const query = { page: tableParams.pagination.current, per: tableParams.pagination.pageSize, - filterOpts: [...filterOpts, mileageFilter], + filterOpts: [...filterOpts, ...commonFilterOpts], sortOpts: tableParams.sortOpts, label, level, @@ -330,7 +322,7 @@ const MetricTable: React.FC<{ ]; return ( <> -
+
= ({ label, level, beginDate, endDate, mileage }) => { + commonFilterOpts: any[]; +}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => { const { t } = useTranslation(); const getEcologicalText = useGetEcologicalText(); const chartRef = useRef(null); @@ -137,7 +137,7 @@ const ContributorContributors: React.FC<{ level: level, beginDate: beginDate, endDate: endDate, - filterOpts: [{ type: 'mileage_type', values: mileage }], + filterOpts: commonFilterOpts, }); const getSeries = useMemo(() => { diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/index.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/index.tsx index 958a5388..4942e2bc 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/index.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useMemo } from 'react'; import Tabs from '@mui/material/Tabs'; import Tab from '@mui/material/Tab'; import useVerifyDateRange from '../useVerifyDateRange'; @@ -11,9 +11,9 @@ import ContributorContributors from './Contributors'; import { AiOutlineQuestionCircle } from 'react-icons/ai'; import Tooltip from '@common/components/Tooltip'; import useLabelStatus from '@modules/analyze/hooks/useLabelStatus'; -import BaseCard from '@common/components/BaseCard'; import { useRouter } from 'next/router'; import { useHandleQueryParams } from '@modules/analyze/hooks/useHandleQueryParams'; +import DetailHeaderFilter from '@modules/analyze/components/MetricDetail/DetailHeaderFilter'; const MetricContributor = () => { const { t } = useTranslation(); @@ -30,10 +30,26 @@ const MetricContributor = () => { ? JSON.parse(queryMileage) : ['core', 'regular']; const [mileage, setMileage] = useState(defaultMileage); - const onChange = (checkedValues: string[]) => { + const [isBot, setIsBot] = useState(true); + const [repoList, setRepoList] = useState([]); + + const onMileageChange = (checkedValues: string[]) => { setMileage(checkedValues); handleQueryParams({ mileage: JSON.stringify(checkedValues) }); }; + const commonFilterOpts = useMemo(() => { + let opts = []; + if (mileage.length > 0) { + opts.push({ type: 'mileage_type', values: mileage }); + } + if (!isBot) { + opts.push({ type: 'is_bot', values: [String(isBot)] }); + } + if (repoList.length > 0) { + opts.push({ type: 'repo_urls', values: repoList }); + } + return opts; + }, [mileage, isBot, repoList]); let source; switch (tab) { case '1': { @@ -43,7 +59,7 @@ const MetricContributor = () => { level={level} beginDate={timeStart} endDate={timeEnd} - mileage={mileage} + commonFilterOpts={commonFilterOpts} /> ); break; @@ -55,7 +71,7 @@ const MetricContributor = () => { level={level} beginDate={timeStart} endDate={timeEnd} - mileage={mileage} + commonFilterOpts={commonFilterOpts} /> ); break; @@ -67,7 +83,7 @@ const MetricContributor = () => { level={level} beginDate={timeStart} endDate={timeEnd} - mileage={mileage} + commonFilterOpts={commonFilterOpts} /> ); break; @@ -79,58 +95,27 @@ const MetricContributor = () => { level={level} beginDate={timeStart} endDate={timeEnd} - mileage={mileage} + commonFilterOpts={commonFilterOpts} /> ); break; } } return ( - -
-
- { - setTab(v); - handleQueryParams({ card: v }); - }} - aria-label="Tabs where selection follows focus" - selectionFollowsFocus - > - - - - -
- -
+
+ setIsBot(v)} + onRepoChange={(v) => setRepoList(v)} + /> +
{t('analyze:metric_detail:milestone_persona_filter')} {
+
+
+
+ { + setTab(v); + handleQueryParams({ card: v }); + }} + aria-label="Tabs where selection follows focus" + selectionFollowsFocus + > + + + + +
{source}
- +
); }; 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 d3b9b699..49fedd0b 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueTable.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueTable.tsx @@ -48,6 +48,7 @@ const MetricTable: React.FC<{ direction: 'desc', }, }); + const query = { page: tableParams.pagination.current, per: tableParams.pagination.pageSize, @@ -187,7 +188,7 @@ const MetricTable: React.FC<{ ]; return ( <> -
+
{ const router = useRouter(); @@ -19,7 +19,12 @@ const MetricIssue = () => { const { label, level } = verifiedItems[0]; const { t } = useTranslation(); const queryCard = router.query?.card as string; + const [isBot, setIsBot] = useState(true); const [tab, setTab] = useState(queryCard || '1'); + const commonFilterOpts = useMemo(() => { + let opts = []; + return opts; + }, [isBot]); let source; switch (tab) { case '1': { @@ -68,11 +73,11 @@ const MetricIssue = () => { } } return ( - + {
{source}
-
+
); }; diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrTable.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrTable.tsx index 824b437d..9bac7089 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrTable.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrTable.tsx @@ -194,7 +194,7 @@ const MetricTable: React.FC<{ ]; return ( <> -
+
{ const { t } = useTranslation(); @@ -20,6 +20,14 @@ const MetricPr = () => { const queryCard = router.query?.card as string; const [tab, setTab] = useState(queryCard || '1'); const { timeStart, timeEnd } = useVerifyDateRange(); + const [repoList, setRepoList] = useState([]); + const commonFilterOpts = useMemo(() => { + let opts = []; + if (repoList.length > 0) { + opts.push({ type: 'repo_urls', values: repoList }); + } + return opts; + }, [repoList]); let source; switch (tab) { case '1': { @@ -68,11 +76,11 @@ const MetricPr = () => { } } return ( - + { />
{source}
-
+
); }; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/CommunityFilter.tsx b/apps/web/src/modules/analyze/components/MetricDetail/CommunityFilter.tsx new file mode 100644 index 00000000..20ef6085 --- /dev/null +++ b/apps/web/src/modules/analyze/components/MetricDetail/CommunityFilter.tsx @@ -0,0 +1,93 @@ +import React, { useMemo, useRef, useState } from 'react'; +import { Select, Checkbox, Divider } from 'antd'; +import { useCommunityReposSearchQuery } from '@oss-compass/graphql'; +import client from '@common/gqlClient'; +import { getLastPathSegment } from '@common/utils'; +import { useTranslation } from 'next-i18next'; + +interface UserValue { + label: string; + value: string; +} + +const CommunityFilter = ({ label, onRepoChange }) => { + const [value, setValue] = useState([]); + const [options, setOptions] = useState([]); + const [selectState, setSelectState] = useState(true); + const { t } = useTranslation(); + const { isLoading } = useCommunityReposSearchQuery( + client, + { label: label, page: 1, per: 9999 }, + { + onSuccess: (data) => { + if (data) { + let items = data.communityRepos.items; + let opts = items.map((z) => ({ + label: getLastPathSegment(z.label), + value: z.label, + })); + setOptions(opts); + setValue(opts.map((item) => item.value)); + } + console.log(data); + }, + } + ); + + return ( + { + onBotChange(v); + // handleQueryParams({ tab: v }); + }} + value={isBot} + options={isBotOptions} + /> +
+ ); +}; + +export default DetailHeaderFilter; diff --git a/apps/web/src/styles/antd.scss b/apps/web/src/styles/antd.scss index 238f6b3c..05a6beba 100644 --- a/apps/web/src/styles/antd.scss +++ b/apps/web/src/styles/antd.scss @@ -53,8 +53,15 @@ .ant-form-item-explain-error { font-size: 12px !important; } -.ant-picker-clear { - // inset-inline-end: 16px !important; +.ant-select-selector { + border-radius: 0 !important; + // border-color: #cccccc !important; +} +.ant-select-dropdown { + border-radius: 0 !important; + .ant-select-item { + border-radius: 0 !important; + } } // .ant-spin-nested-loading { // height: 100%; diff --git a/packages/graphql/src/generated.ts b/packages/graphql/src/generated.ts index feb0bec7..82649fa3 100644 --- a/packages/graphql/src/generated.ts +++ b/packages/graphql/src/generated.ts @@ -1526,6 +1526,8 @@ export type Query = { collectionList: CollectionPage; /** Get overview data of a community */ communityOverview: CommunityOverview; + /** Get repos list of a community */ + communityRepos: RepoPage; /** Get contributors detail list of a repo or community */ contributorsDetailList: ContributorDetailPage; /** Get overview data of a contributor detail */ @@ -1672,6 +1674,13 @@ export type QueryCommunityOverviewArgs = { type?: InputMaybe; }; +export type QueryCommunityReposArgs = { + label: Scalars['String']; + page?: InputMaybe; + per?: InputMaybe; + type?: InputMaybe; +}; + export type QueryContributorsDetailListArgs = { beginDate?: InputMaybe; endDate?: InputMaybe; @@ -1975,6 +1984,14 @@ export type Repo = { watchersCount?: Maybe; }; +export type RepoPage = { + __typename?: 'RepoPage'; + count?: Maybe; + items?: Maybe>; + page?: Maybe; + totalPage?: Maybe; +}; + export type Report = { __typename?: 'Report'; /** metric model object identification */ @@ -2085,6 +2102,11 @@ export type SortOptionInput = { type: Scalars['String']; }; +export type SubRepo = { + __typename?: 'SubRepo'; + label?: Maybe; +}; + export type SubjectSubscriptionCount = { __typename?: 'SubjectSubscriptionCount'; count: Scalars['Int']; @@ -3961,6 +3983,24 @@ export type CommunityReposQuery = { }; }; +export type CommunityReposSearchQueryVariables = Exact<{ + label: Scalars['String']; + page?: InputMaybe; + per?: InputMaybe; + type?: InputMaybe; +}>; + +export type CommunityReposSearchQuery = { + __typename?: 'Query'; + communityRepos: { + __typename?: 'RepoPage'; + count?: number | null; + page?: number | null; + totalPage?: number | null; + items?: Array<{ __typename?: 'SubRepo'; label?: string | null }> | null; + }; +}; + export type MetricQueryVariables = Exact<{ label: Scalars['String']; level?: InputMaybe; @@ -7530,6 +7570,52 @@ useCommunityReposQuery.fetcher = ( variables, headers ); +export const CommunityReposSearchDocument = /*#__PURE__*/ ` + query communityReposSearch($label: String!, $page: Int, $per: Int, $type: String) { + communityRepos(label: $label, page: $page, per: $per, type: $type) { + count + items { + label + } + page + totalPage + } +} + `; +export const useCommunityReposSearchQuery = < + TData = CommunityReposSearchQuery, + TError = unknown +>( + client: GraphQLClient, + variables: CommunityReposSearchQueryVariables, + options?: UseQueryOptions, + headers?: RequestInit['headers'] +) => + useQuery( + ['communityReposSearch', variables], + fetcher( + client, + CommunityReposSearchDocument, + variables, + headers + ), + options + ); + +useCommunityReposSearchQuery.getKey = ( + variables: CommunityReposSearchQueryVariables +) => ['communityReposSearch', variables]; +useCommunityReposSearchQuery.fetcher = ( + client: GraphQLClient, + variables: CommunityReposSearchQueryVariables, + headers?: RequestInit['headers'] +) => + fetcher( + client, + CommunityReposSearchDocument, + variables, + headers + ); export const MetricDocument = /*#__PURE__*/ ` query metric($label: String!, $level: String = "repo", $start: ISO8601DateTime, $end: ISO8601DateTime, $repoType: String) { metricCodequality( diff --git a/packages/graphql/src/gql/query.graphql b/packages/graphql/src/gql/query.graphql index a680299d..93a948ee 100644 --- a/packages/graphql/src/gql/query.graphql +++ b/packages/graphql/src/gql/query.graphql @@ -105,7 +105,21 @@ query communityRepos($label: String!, $page: Int, $per: Int, $type: String) { } } } - +query communityReposSearch( + $label: String! + $page: Int + $per: Int + $type: String +) { + communityRepos(label: $label, page: $page, per: $per, type: $type) { + count + items { + label + } + page + totalPage + } +} query metric( $label: String! $level: String = "repo"