From 823ef5244d61eef11ebffaaed449b1a50864d11c Mon Sep 17 00:00:00 2001 From: laixingyou Date: Fri, 24 Nov 2023 16:38:32 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=EF=BC=9Arefactor=20report=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laixingyou --- apps/web/i18n | 2 +- apps/web/src/common/components/BaseCard.tsx | 20 +- apps/web/src/common/components/Tab.tsx | 9 +- .../web/src/common/components/Table/index.tsx | 19 +- .../analyze/DataView/ContributorDetail.tsx | 41 +++ .../MetricDetail/MetricChart.tsx | 0 .../ContributorContribution.tsx | 2 +- .../ContributorContributors.tsx | 2 +- .../ContributorOrganizations.tsx | 2 +- .../MetricContributor/ContributorTable.tsx | 23 +- .../MetricContributor/contribution.ts | 0 .../MetricDetail/MetricContributor/index.tsx | 175 +++++++++++++ .../MetricDetail/MetricDashboard.tsx | 94 +------ .../MetricIssue/IssueComments.tsx | 2 +- .../MetricIssue/IssueCompletion.tsx | 2 +- .../MetricDetail/MetricIssue/IssueTable.tsx | 31 +-- .../MetricDetail/MetricIssue/index.tsx | 20 +- .../MetricDetail/MetricIssue/issue.ts | 0 .../MetricDetail/MetricPr/PR.ts | 0 .../MetricDetail/MetricPr/PrComments.tsx | 2 +- .../MetricDetail/MetricPr/PrCompletion.tsx | 4 +- .../MetricDetail/MetricPr/PrTable.tsx | 35 +-- .../MetricDetail/MetricPr/index.tsx | 21 +- .../analyze/DataView/MetricDetail/index.tsx | 39 +++ .../DataView/OverviewSummary/index.tsx | 1 - .../src/modules/analyze/DataView/index.tsx | 35 ++- .../analyze/components/ConnectLine.tsx | 4 +- .../MetricDetail/MetricContributor/index.tsx | 170 ------------- .../MetricDetail/MetricDetailMore.tsx | 130 ---------- .../NavBar/ContributorDateTagPanel.tsx | 191 ++++++++++++++ .../components/NavBar/NavDatePicker.tsx | 28 ++- .../Collaboration/TopicNicheCreation.tsx | 62 +++++ .../Collaboration/TopicProductivity.tsx | 96 +++++++ .../SideBar/Collaboration/TopicRobustness.tsx | 73 ++++++ .../SideBar/Collaboration/index.tsx | 21 ++ .../Contributor/TopicNicheCreation.tsx | 34 +++ .../SideBar/Contributor/TopicProductivity.tsx | 56 +++++ .../SideBar/Contributor/TopicRobustness.tsx | 40 +++ .../components/SideBar/Contributor/index.tsx | 21 ++ .../analyze/components/SideBar/TopicTab.tsx | 32 +++ .../analyze/components/SideBar/config.ts | 31 ++- .../analyze/components/SideBar/index.tsx | 24 +- .../analyze/hooks/useQueryDateRange.ts | 16 +- .../analyze/hooks/useVerifyDetailRange.ts | 15 ++ apps/web/src/modules/analyze/store/index.ts | 1 + .../src/modules/analyze/store/topicType.ts | 12 + apps/web/src/pages/analyze/metric/[slugs].tsx | 23 -- apps/web/src/styles/antd.scss | 30 +++ apps/web/src/styles/globals.scss | 4 +- packages/graphql/src/generated.ts | 237 +++++++----------- packages/graphql/src/gql/query.graphql | 81 +++--- 51 files changed, 1317 insertions(+), 696 deletions(-) create mode 100644 apps/web/src/modules/analyze/DataView/ContributorDetail.tsx rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricChart.tsx (100%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricContributor/ContributorContribution.tsx (97%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricContributor/ContributorContributors.tsx (96%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricContributor/ContributorOrganizations.tsx (97%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricContributor/ContributorTable.tsx (94%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricContributor/contribution.ts (100%) create mode 100644 apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/index.tsx rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricDashboard.tsx (73%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricIssue/IssueComments.tsx (96%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricIssue/IssueCompletion.tsx (96%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricIssue/IssueTable.tsx (92%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricIssue/index.tsx (79%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricIssue/issue.ts (100%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricPr/PR.ts (100%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricPr/PrComments.tsx (96%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricPr/PrCompletion.tsx (93%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricPr/PrTable.tsx (91%) rename apps/web/src/modules/analyze/{components => DataView}/MetricDetail/MetricPr/index.tsx (79%) create mode 100644 apps/web/src/modules/analyze/DataView/MetricDetail/index.tsx delete mode 100644 apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/index.tsx delete mode 100644 apps/web/src/modules/analyze/components/MetricDetail/MetricDetailMore.tsx create mode 100644 apps/web/src/modules/analyze/components/NavBar/ContributorDateTagPanel.tsx create mode 100644 apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicNicheCreation.tsx create mode 100644 apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicProductivity.tsx create mode 100644 apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicRobustness.tsx create mode 100644 apps/web/src/modules/analyze/components/SideBar/Collaboration/index.tsx create mode 100644 apps/web/src/modules/analyze/components/SideBar/Contributor/TopicNicheCreation.tsx create mode 100644 apps/web/src/modules/analyze/components/SideBar/Contributor/TopicProductivity.tsx create mode 100644 apps/web/src/modules/analyze/components/SideBar/Contributor/TopicRobustness.tsx create mode 100644 apps/web/src/modules/analyze/components/SideBar/Contributor/index.tsx create mode 100644 apps/web/src/modules/analyze/components/SideBar/TopicTab.tsx create mode 100644 apps/web/src/modules/analyze/hooks/useVerifyDetailRange.ts create mode 100644 apps/web/src/modules/analyze/store/topicType.ts delete mode 100644 apps/web/src/pages/analyze/metric/[slugs].tsx create mode 100644 apps/web/src/styles/antd.scss diff --git a/apps/web/i18n b/apps/web/i18n index 7ef2f39b..737b1a91 160000 --- a/apps/web/i18n +++ b/apps/web/i18n @@ -1 +1 @@ -Subproject commit 7ef2f39b81adf8d0c089b97a2b9637d73843a611 +Subproject commit 737b1a9190679e1c37ff3d92ec93912e23c420a6 diff --git a/apps/web/src/common/components/BaseCard.tsx b/apps/web/src/common/components/BaseCard.tsx index c3ab655e..6c378600 100644 --- a/apps/web/src/common/components/BaseCard.tsx +++ b/apps/web/src/common/components/BaseCard.tsx @@ -119,15 +119,17 @@ const BaseCard: React.FC = ({ -
- -
+ {description && ( +
+ +
+ )}
{typeof headRight === 'function' ? headRight(cardRef, fullScreen, setFullScreen) diff --git a/apps/web/src/common/components/Tab.tsx b/apps/web/src/common/components/Tab.tsx index 929a9c00..c05c9a48 100644 --- a/apps/web/src/common/components/Tab.tsx +++ b/apps/web/src/common/components/Tab.tsx @@ -2,7 +2,7 @@ import React from 'react'; import classnames from 'classnames'; const Tab: React.FC<{ - options: { value: string; label: string }[]; + options: { value: string; label: string; disable?: boolean }[]; value: string; onChange: (v: string) => void; }> = ({ options, value, onChange }) => ( @@ -13,10 +13,11 @@ const Tab: React.FC<{
onChange(option.value)} + onClick={() => !option.disable && onChange(option.value)} > {option.label}
diff --git a/apps/web/src/common/components/Table/index.tsx b/apps/web/src/common/components/Table/index.tsx index 48a1ac2e..7fd73f23 100644 --- a/apps/web/src/common/components/Table/index.tsx +++ b/apps/web/src/common/components/Table/index.tsx @@ -1,30 +1,29 @@ import React, { useEffect, useState, useRef } from 'react'; import { Table, ConfigProvider } from 'antd'; -import getTableScroll from '@common/utils/getTableScroll'; import getLocale from '@common/utils/getLocale'; import zhCN from 'antd/locale/zh_CN'; import enUS from 'antd/locale/en_US'; const MyTable = (props) => { - const [scrollY, setScrollY] = useState(400); - let countRef = useRef(null); - useEffect(() => { - let scrolly = getTableScroll({ ref: countRef }); - if (countRef) setScrollY(scrolly); - }, [countRef]); + // const [scrollY, setScrollY] = useState(400); + // let countRef = useRef(null); + // useEffect(() => { + // let scrolly = getTableScroll({ ref: countRef }); + // if (countRef) setScrollY(scrolly); + // }, [countRef]); + const [local, setLocale] = useState(enUS); useEffect(() => { const l = getLocale(); setLocale(l === 'zh' ? zhCN : enUS); }, []); return ( -
+
(i % 2 === 1 ? '!bg-[#fafafa]' : '')} - bordered - scroll={{ x: 'max-content', y: scrollY }} + // bordered /> diff --git a/apps/web/src/modules/analyze/DataView/ContributorDetail.tsx b/apps/web/src/modules/analyze/DataView/ContributorDetail.tsx new file mode 100644 index 00000000..346d8cab --- /dev/null +++ b/apps/web/src/modules/analyze/DataView/ContributorDetail.tsx @@ -0,0 +1,41 @@ +import React from 'react'; +import { useTranslation } from 'next-i18next'; +import TopicTitle from '@modules/analyze/components/TopicTitle'; +import { Topic } from '@modules/analyze/components/SideBar/config'; +import { CiGrid41 } from 'react-icons/ci'; +import MetricDashboard from '@modules/analyze/DataView/MetricDetail/MetricDashboard'; +import ProductivityIcon from '@modules/analyze/components/SideBar/assets/Productivity.svg'; +import MetricDetail from './MetricDetail'; + +const ContributorDetail = () => { + const { t } = useTranslation(); + + return ( + <> +

+ + {t('analyze:overview')} + + + # + + +

+ + } + id={Topic.Productivity} + > + {t('analyze:topic.productivity')} + + + + ); +}; + +export default ContributorDetail; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricChart.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricChart.tsx similarity index 100% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricChart.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricChart.tsx diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorContribution.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContribution.tsx similarity index 97% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorContribution.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContribution.tsx index ea02499c..8dce2c2d 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorContribution.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContribution.tsx @@ -2,7 +2,7 @@ import React, { useRef, useMemo } from 'react'; import { useEcoContributorsOverviewQuery } from '@oss-compass/graphql'; import client from '@common/gqlClient'; import { useTranslation } from 'next-i18next'; -import MetricChart from '@modules/analyze/components/MetricDetail/MetricChart'; +import MetricChart from '@modules/analyze/DataView/MetricDetail/MetricChart'; import { useEcologicalType } from './contribution'; import { gradientRamp } from '@common/options'; import type { EChartsOption } from 'echarts'; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorContributors.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContributors.tsx similarity index 96% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorContributors.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContributors.tsx index a3f4e615..c3b39a6d 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorContributors.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContributors.tsx @@ -2,7 +2,7 @@ import React, { useRef, useMemo } from 'react'; import { useContributorsOverviewQuery } from '@oss-compass/graphql'; import client from '@common/gqlClient'; import { useTranslation } from 'next-i18next'; -import MetricChart from '@modules/analyze/components/MetricDetail/MetricChart'; +import MetricChart from '@modules/analyze/DataView/MetricDetail/MetricChart'; import { useEcologicalType } from './contribution'; import type { EChartsOption } from 'echarts'; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorOrganizations.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorOrganizations.tsx similarity index 97% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorOrganizations.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorOrganizations.tsx index 69c4cf48..078eefe8 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorOrganizations.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorOrganizations.tsx @@ -2,7 +2,7 @@ import React, { useRef, useMemo } from 'react'; import { useOrgContributorsOverviewQuery } from '@oss-compass/graphql'; import client from '@common/gqlClient'; import { useTranslation } from 'next-i18next'; -import MetricChart from '@modules/analyze/components/MetricDetail/MetricChart'; +import MetricChart from '@modules/analyze/DataView/MetricDetail/MetricChart'; import { gradientRamp } from '@common/options'; import type { EChartsOption } from 'echarts'; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorTable.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable.tsx similarity index 94% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorTable.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable.tsx index ea76428a..77bfbe70 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/ContributorTable.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable.tsx @@ -53,6 +53,7 @@ const MetricTable: React.FC<{ pagination: { current: 1, pageSize: 10, + showSizeChanger: false, position: ['bottomCenter'], showTotal: (total) => { return `Total ${total} items`; @@ -218,21 +219,21 @@ const MetricTable: React.FC<{ } }, align: 'center', - width: '100px', + width: '200px', sorter: true, }, ]; return ( -
- -
+ ); }; export default MetricTable; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/contribution.ts b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/contribution.ts similarity index 100% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/contribution.ts rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/contribution.ts diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/index.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/index.tsx new file mode 100644 index 00000000..241eb773 --- /dev/null +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/index.tsx @@ -0,0 +1,175 @@ +import React, { useState } from 'react'; +import Tabs from '@mui/material/Tabs'; +import Tab from '@mui/material/Tab'; +import useQueryDateRange from '@modules/analyze/hooks/useQueryDateRange'; +import { Checkbox } from 'antd'; +import { useTranslation } from 'next-i18next'; +import { useMileageOptions } from './contribution'; +import MetricTable from './ContributorTable'; +import ContributorContribution from './ContributorContribution'; +import ContributorOrganizations from './ContributorOrganizations'; +import ContributorContributors from './ContributorContributors'; +import { AiOutlineQuestionCircle } from 'react-icons/ai'; +import Tooltip from '@common/components/Tooltip'; +import useLabelStatus from '@modules/analyze/hooks/useLabelStatus'; +import { ContributorsPersona } from '@modules/analyze/components/SideBar/config'; +import BaseCard from '@common/components/BaseCard'; + +const MetricContributor = () => { + const { t } = useTranslation(); + const { verifiedItems } = useLabelStatus(); + const { label, level } = verifiedItems[0]; + const [tab, setTab] = useState('1'); + const { timeStart, timeEnd } = useQueryDateRange(); + const options = useMileageOptions(); + const [mileage, setMileage] = useState(['core', 'guest']); + const onChange = (checkedValues: string[]) => { + setMileage(checkedValues); + }; + let source; + switch (tab) { + case '1': { + source = ( + + ); + break; + } + case '2': { + source = ( + + ); + break; + } + case '3': { + source = ( + + ); + break; + } + case '4': { + source = ( + + ); + break; + } + default: { + break; + } + } + return ( + +
+ { + setTab(v); + }} + aria-label="Tabs where selection follows focus" + selectionFollowsFocus + > + + + + + +
+ + {t('analyze:metric_detail:milestone_persona_filter')} + +
+ + {t('analyze:metric_detail:core')} : + + {t('analyze:metric_detail:core_desc')} +
+
+ + {t('analyze:metric_detail:regular')} : + + {t('analyze:metric_detail:regular_desc')} +
+ + } + placement="right" + > + + + +
+
+ : + +
+ +
{source}
+
+
+ ); +}; + +export default MetricContributor; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricDashboard.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricDashboard.tsx similarity index 73% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricDashboard.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricDashboard.tsx index bd9e3b8b..2790ae44 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricDashboard.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricDashboard.tsx @@ -6,7 +6,6 @@ import { AiFillClockCircle, AiOutlineIssuesClose } from 'react-icons/ai'; import { BiChat, BiGitPullRequest, BiGitCommit } from 'react-icons/bi'; import useCompareItems from '@modules/analyze/hooks/useCompareItems'; import useQueryDateRange from '@modules/analyze/hooks/useQueryDateRange'; -import { useRouter } from 'next/router'; import { useMetricDashboardQuery, ContributorDetailOverview, @@ -44,9 +43,6 @@ const Main = () => { } return (
-
- {t('analyze:metric_detail:project_deep_dive_insight')} -
@@ -64,8 +60,6 @@ const MetricBoxContributors: React.FC<{ data: ContributorDetailOverview; }> = ({ data }) => { const { t } = useTranslation(); - const router = useRouter(); - const slugs = router.query.slugs; return (
@@ -73,16 +67,6 @@ const MetricBoxContributors: React.FC<{
{t('analyze:metric_detail:contributor')}
-
{ - router.push( - '/analyze/metric/' + slugs + '?range=1M&type=contributor' - ); - }} - > - {t('analyze:metric_detail:details')} -
@@ -141,8 +125,6 @@ const MetricBoxIssues: React.FC<{ data: IssueDetailOverview; }> = ({ data }) => { const { t } = useTranslation(); - const router = useRouter(); - const slugs = router.query.slugs; return (
@@ -150,14 +132,6 @@ const MetricBoxIssues: React.FC<{
{t('analyze:metric_detail:issues')}
-
{ - router.push('/analyze/metric/' + slugs + '?range=1M&type=issue'); - }} - > - {t('analyze:metric_detail:details')} -
@@ -220,22 +194,13 @@ const MetricBoxPr: React.FC<{ data: PullDetailOverview; }> = ({ data }) => { const { t } = useTranslation(); - const router = useRouter(); - const slugs = router.query.slugs; + return (
{t('analyze:metric_detail:pull_requests')}
-
{ - router.push('/analyze/metric/' + slugs + '?range=1M&type=pr'); - }} - className="cursor-pointer pt-1 text-sm text-[#585858]" - > - {t('analyze:metric_detail:details')} -
@@ -292,52 +257,19 @@ const MetricBoxPr: React.FC<{ ); }; const Loading = () => ( -
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
); diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/IssueComments.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueComments.tsx similarity index 96% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/IssueComments.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueComments.tsx index 60f8c648..3dfe820d 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/IssueComments.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueComments.tsx @@ -2,7 +2,7 @@ import React, { useRef, useMemo } from 'react'; import { useIssueCommentQuery } from '@oss-compass/graphql'; import client from '@common/gqlClient'; import { useTranslation } from 'next-i18next'; -import MetricChart from '@modules/analyze/components/MetricDetail/MetricChart'; +import MetricChart from '@modules/analyze/DataView/MetricDetail/MetricChart'; import type { EChartsOption } from 'echarts'; const IssueCompletion: React.FC<{ diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/IssueCompletion.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueCompletion.tsx similarity index 96% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/IssueCompletion.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueCompletion.tsx index 70d68bcf..562de381 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/IssueCompletion.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueCompletion.tsx @@ -2,7 +2,7 @@ import React, { useRef, useMemo } from 'react'; import { useIssueCompletionQuery } from '@oss-compass/graphql'; import client from '@common/gqlClient'; import { useTranslation } from 'next-i18next'; -import MetricChart from '@modules/analyze/components/MetricDetail/MetricChart'; +import MetricChart from '@modules/analyze/DataView/MetricDetail/MetricChart'; import type { EChartsOption } from 'echarts'; import { useStateType } from './issue'; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/IssueTable.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueTable.tsx similarity index 92% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/IssueTable.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueTable.tsx index d0b49ee8..4f721579 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/IssueTable.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/IssueTable.tsx @@ -33,6 +33,7 @@ const MetricTable: React.FC<{ pagination: { current: 1, pageSize: 10, + showSizeChanger: false, position: ['bottomCenter'], showTotal: (total) => { return `Total ${total} items`; @@ -107,7 +108,7 @@ const MetricTable: React.FC<{ title: 'URL', dataIndex: 'url', align: 'center', - width: '250px', + width: '220px', }, { title: t('analyze:metric_detail:state'), @@ -125,7 +126,7 @@ const MetricTable: React.FC<{ dataIndex: 'createdAt', align: 'center', sorter: true, - width: '120px', + width: '140px', render: (time) => format(parseJSON(time)!, 'yyyy-MM-dd'), }, { @@ -141,21 +142,21 @@ const MetricTable: React.FC<{ dataIndex: 'timeToCloseDays', align: 'center', sorter: true, - width: '140px', + width: '200px', }, { title: t('analyze:metric_detail:first_response_time'), dataIndex: 'timeToFirstAttentionWithoutBot', align: 'center', sorter: true, - width: '170px', + width: '220px', }, { title: t('analyze:metric_detail:comments_count'), dataIndex: 'numOfCommentsWithoutBot', align: 'center', sorter: true, - width: '120px', + width: '160px', }, { title: t('analyze:metric_detail:tags'), @@ -180,16 +181,16 @@ const MetricTable: React.FC<{ }, ]; return ( -
- -
+ ); }; export default MetricTable; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/index.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/index.tsx similarity index 79% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/index.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/index.tsx index a5101603..7cb96ef9 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/index.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/index.tsx @@ -6,11 +6,13 @@ import MetricTable from './IssueTable'; import IssueCompletion from './IssueCompletion'; import IssueComments from './IssueComments'; import { useTranslation } from 'next-i18next'; +import useLabelStatus from '@modules/analyze/hooks/useLabelStatus'; +import { ContributorsPersona } from '@modules/analyze/components/SideBar/config'; +import BaseCard from '@common/components/BaseCard'; -const MetricIssue: React.FC<{ - label: string; - level: string; -}> = ({ label, level }) => { +const MetricIssue = () => { + const { verifiedItems } = useLabelStatus(); + const { label, level } = verifiedItems[0]; const { t } = useTranslation(); const [tab, setTab] = useState('1'); const { timeStart, timeEnd } = useQueryDateRange(); @@ -54,7 +56,11 @@ const MetricIssue: React.FC<{ } } return ( -
+ -
{source}
-
+
{source}
+ ); }; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/issue.ts b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/issue.ts similarity index 100% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricIssue/issue.ts rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricIssue/issue.ts diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricPr/PR.ts b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PR.ts similarity index 100% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricPr/PR.ts rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PR.ts diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricPr/PrComments.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrComments.tsx similarity index 96% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricPr/PrComments.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrComments.tsx index bd12784a..5f2d788d 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricPr/PrComments.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrComments.tsx @@ -2,7 +2,7 @@ import React, { useRef, useMemo } from 'react'; import { usePullsCommentQuery } from '@oss-compass/graphql'; import client from '@common/gqlClient'; import { useTranslation } from 'next-i18next'; -import MetricChart from '@modules/analyze/components/MetricDetail/MetricChart'; +import MetricChart from '@modules/analyze/DataView/MetricDetail/MetricChart'; import type { EChartsOption } from 'echarts'; const PrComments: React.FC<{ diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricPr/PrCompletion.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrCompletion.tsx similarity index 93% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricPr/PrCompletion.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrCompletion.tsx index de2ff163..b36f051c 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricPr/PrCompletion.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrCompletion.tsx @@ -2,8 +2,8 @@ import React, { useRef, useMemo } from 'react'; import { usePullsCompletionQuery } from '@oss-compass/graphql'; import client from '@common/gqlClient'; import { useTranslation } from 'next-i18next'; -import MetricChart from '@modules/analyze/components/MetricDetail/MetricChart'; -import { useStateType } from '@modules/analyze/components/MetricDetail/MetricPr/PR'; +import MetricChart from '@modules/analyze/DataView/MetricDetail/MetricChart'; +import { useStateType } from '@modules/analyze/DataView/MetricDetail/MetricPr/PR'; import type { EChartsOption } from 'echarts'; const PrCompletion: React.FC<{ diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricPr/PrTable.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrTable.tsx similarity index 91% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricPr/PrTable.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrTable.tsx index 0be01219..5b0c1d05 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricPr/PrTable.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/PrTable.tsx @@ -11,7 +11,7 @@ import type { ColumnsType, TablePaginationConfig } from 'antd/es/table'; import type { FilterValue, SorterResult } from 'antd/es/table/interface'; import { useTranslation } from 'next-i18next'; import { format, parseJSON } from 'date-fns'; -import { useStateType } from '@modules/analyze/components/MetricDetail/MetricPr/PR'; +import { useStateType } from '@modules/analyze/DataView/MetricDetail/MetricPr/PR'; interface TableParams { pagination?: TablePaginationConfig; @@ -33,6 +33,7 @@ const MetricTable: React.FC<{ pagination: { current: 1, pageSize: 10, + showSizeChanger: false, position: ['bottomCenter'], showTotal: (total) => { return `Total ${total} items`; @@ -107,7 +108,7 @@ const MetricTable: React.FC<{ title: 'URL', dataIndex: 'url', align: 'center', - width: '250px', + width: '220px', }, { title: t('analyze:metric_detail:state'), @@ -124,7 +125,7 @@ const MetricTable: React.FC<{ title: t('analyze:metric_detail:created_time'), dataIndex: 'createdAt', align: 'center', - width: '120px', + width: '140px', sorter: true, render: (time) => (time ? format(parseJSON(time)!, 'yyyy-MM-dd') : ''), }, @@ -140,21 +141,21 @@ const MetricTable: React.FC<{ title: t('analyze:metric_detail:processing_time'), dataIndex: 'timeToCloseDays', align: 'center', - width: '140px', + width: '200px', sorter: true, }, { title: t('analyze:metric_detail:first_response_time'), dataIndex: 'timeToFirstAttentionWithoutBot', align: 'center', - width: '160px', + width: '220px', sorter: true, }, { title: t('analyze:metric_detail:comments_count'), dataIndex: 'numReviewComments', align: 'center', - width: '120px', + width: '160px', sorter: true, }, { @@ -182,21 +183,21 @@ const MetricTable: React.FC<{ title: t('analyze:metric_detail:merge_author'), dataIndex: 'mergeAuthorLogin', align: 'center', - width: '100px', + width: '140px', sorter: true, }, ]; return ( -
- -
+ ); }; export default MetricTable; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricPr/index.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/index.tsx similarity index 79% rename from apps/web/src/modules/analyze/components/MetricDetail/MetricPr/index.tsx rename to apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/index.tsx index 6b4f31bc..de3a9ed9 100644 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricPr/index.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricPr/index.tsx @@ -6,11 +6,13 @@ import MetricTable from './PrTable'; import PrCompletion from './PrCompletion'; import PrComments from './PrComments'; import { useTranslation } from 'next-i18next'; +import useLabelStatus from '@modules/analyze/hooks/useLabelStatus'; +import { ContributorsPersona } from '@modules/analyze/components/SideBar/config'; +import BaseCard from '@common/components/BaseCard'; -const MetricPr: React.FC<{ - label: string; - level: string; -}> = ({ label, level }) => { +const MetricPr = () => { + const { verifiedItems } = useLabelStatus(); + const { label, level } = verifiedItems[0]; const { t } = useTranslation(); const [tab, setTab] = useState('1'); const { timeStart, timeEnd } = useQueryDateRange(); @@ -54,7 +56,11 @@ const MetricPr: React.FC<{ } } return ( -
+ - -
{source}
-
+
{source}
+ ); }; diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/index.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/index.tsx new file mode 100644 index 00000000..1dd5b25e --- /dev/null +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/index.tsx @@ -0,0 +1,39 @@ +import React, { useContext } from 'react'; +import { useTranslation } from 'next-i18next'; +import SectionTitle from '@modules/analyze/components/SectionTitle'; +import { ContributorsPersona } from '@modules/analyze/components/SideBar/config'; +import MetricContributor from './MetricContributor'; +import MetricIssue from './MetricIssue'; +import MetricPr from './MetricPr'; + +import { withErrorBoundary } from 'react-error-boundary'; +import ErrorFallback from '@common/components/ErrorFallback'; +import ConnectLine from '@modules/analyze/components/ConnectLine'; + +const OrganizationsActivity = () => { + const { t } = useTranslation(); + + return ( + <> + + {t('metrics_models:contributors_persona.title')} + + +
+ + + + +
+ + ); +}; + +export default withErrorBoundary(OrganizationsActivity, { + FallbackComponent: ErrorFallback, + onError(error, info) { + console.log(error, info); + // Do something with the error + // E.g. log to an error logging client here + }, +}); diff --git a/apps/web/src/modules/analyze/DataView/OverviewSummary/index.tsx b/apps/web/src/modules/analyze/DataView/OverviewSummary/index.tsx index a307e17f..a4bddd3a 100644 --- a/apps/web/src/modules/analyze/DataView/OverviewSummary/index.tsx +++ b/apps/web/src/modules/analyze/DataView/OverviewSummary/index.tsx @@ -19,7 +19,6 @@ const Overview: React.FC<{ <> {data[0].level === Level.COMMUNITY && } - ); } diff --git a/apps/web/src/modules/analyze/DataView/index.tsx b/apps/web/src/modules/analyze/DataView/index.tsx index dc15378d..a0d2b01f 100644 --- a/apps/web/src/modules/analyze/DataView/index.tsx +++ b/apps/web/src/modules/analyze/DataView/index.tsx @@ -6,9 +6,15 @@ import UnderAnalysis from './Status/UnderAnalysis'; import NotFoundAnalysis from './Status/NotFoundAnalysis'; import LoadingAnalysis from './Status/LoadingAnalysis'; import Charts from './Charts'; +import ContributorDetail from './ContributorDetail'; +import useVerifyDetailRange from '@modules/analyze/hooks/useVerifyDetailRange'; +import AuthRequire from '@modules/auth/AuthRequire'; +import { useTopicType } from '@modules/analyze/store'; +import { useSnapshot } from 'valtio'; const DataView = () => { const { notFound, isLoading, status, verifiedItems } = useStatusContext(); + const { topicType } = useSnapshot(useTopicType); if (isLoading) { return ; @@ -22,11 +28,36 @@ const DataView = () => { return ; } + let source; + if (topicType === 'collaboration') { + source = ; + } else { + source = ; + } + return
{source}
; +}; +const CollaborationDataView = () => { return ( -
+ <> -
+ + ); +}; +const ContributorDataView = () => { + const { isLoading } = useVerifyDetailRange(); + // const statusFalse = !data?.verifyDetailDataRange?.status; + // const { switchRange } = useSwitchRange(); + + if (isLoading) { + return ; + } + return ( + <> + + + + ); }; diff --git a/apps/web/src/modules/analyze/components/ConnectLine.tsx b/apps/web/src/modules/analyze/components/ConnectLine.tsx index 44d0c5bd..835db619 100644 --- a/apps/web/src/modules/analyze/components/ConnectLine.tsx +++ b/apps/web/src/modules/analyze/components/ConnectLine.tsx @@ -1,7 +1,9 @@ import React from 'react'; const ConnectLine = () => { - return
; + return ( +
+ ); }; export default ConnectLine; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/index.tsx b/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/index.tsx deleted file mode 100644 index 6cda24ad..00000000 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricContributor/index.tsx +++ /dev/null @@ -1,170 +0,0 @@ -import React, { useState } from 'react'; -import Tabs from '@mui/material/Tabs'; -import Tab from '@mui/material/Tab'; -import useQueryDateRange from '@modules/analyze/hooks/useQueryDateRange'; -import { Checkbox } from 'antd'; -import { useTranslation } from 'next-i18next'; -import { useMileageOptions } from './contribution'; -import MetricTable from './ContributorTable'; -import ContributorContribution from './ContributorContribution'; -import ContributorOrganizations from './ContributorOrganizations'; -import ContributorContributors from './ContributorContributors'; -import { AiOutlineQuestionCircle } from 'react-icons/ai'; -import Tooltip from '@common/components/Tooltip'; - -const MetricContributor: React.FC<{ - label: string; - level: string; -}> = ({ label, level }) => { - const { t } = useTranslation(); - const [tab, setTab] = useState('1'); - const { timeStart, timeEnd } = useQueryDateRange(); - const options = useMileageOptions(); - const [mileage, setMileage] = useState(['core', 'guest']); - const onChange = (checkedValues: string[]) => { - setMileage(checkedValues); - }; - let source; - switch (tab) { - case '1': { - source = ( - - ); - break; - } - case '2': { - source = ( - - ); - break; - } - case '3': { - source = ( - - ); - break; - } - case '4': { - source = ( - - ); - break; - } - default: { - break; - } - } - return ( -
- { - setTab(v); - }} - aria-label="Tabs where selection follows focus" - selectionFollowsFocus - > - - - - - -
- {/* - {t('analyze:metric_detail:milestone_persona_filter')}: - */} - - {t('analyze:metric_detail:milestone_persona_filter')} - -
- - {t('analyze:metric_detail:core')} : - - {t('analyze:metric_detail:core_desc')} -
-
- - {t('analyze:metric_detail:regular')} : - - {t('analyze:metric_detail:regular_desc')} -
- - } - placement="right" - > - - - -
-
- : - -
- -
{source}
-
- ); -}; - -export default MetricContributor; diff --git a/apps/web/src/modules/analyze/components/MetricDetail/MetricDetailMore.tsx b/apps/web/src/modules/analyze/components/MetricDetail/MetricDetailMore.tsx deleted file mode 100644 index 47279587..00000000 --- a/apps/web/src/modules/analyze/components/MetricDetail/MetricDetailMore.tsx +++ /dev/null @@ -1,130 +0,0 @@ -import React, { useState } from 'react'; -import { useTranslation } from 'next-i18next'; -import MyTab from '@common/components/Tab'; -import MetricContributor from './MetricContributor'; -import MetricIssue from './MetricIssue'; -import MetricPr from './MetricPr'; -import { AiOutlineLeftCircle } from 'react-icons/ai'; -import { useRouter } from 'next/router'; -import NavDatePicker from '@modules/analyze/components/NavBar/NavDatePicker'; -import useLabelStatus from '@modules/analyze/hooks/useLabelStatus'; - -const MetricDetailPage = () => { - const { t } = useTranslation(); - const router = useRouter(); - const slugs = router.query.slugs; - const type = (router.query.type as string) || 'contributor'; - const { isLoading, verifiedItems } = useLabelStatus(); - const [tab, setTab] = useState(type); - if (isLoading || verifiedItems.length > 1) { - return null; - } - const { label, level } = verifiedItems[0]; - - const tabOptions = [ - { - label: t('analyze:metric_detail:contributors_persona'), - value: 'contributor', - }, - { label: t('analyze:metric_detail:issues'), value: 'issue' }, - { label: t('analyze:metric_detail:pull_requests'), value: 'pr' }, - ]; - - let source; - switch (tab) { - case 'contributor': { - source = ; - break; - } - case 'issue': { - source = ; - break; - } - case 'pr': { - source = ; - break; - } - default: { - break; - } - } - return ( -
-
-
- { - router.push('/analyze/' + slugs); - }} - className="mt-1 mr-4 cursor-pointer text-[#3f60ef]" - /> - - {t('analyze:metric_detail:project_deep_dive_insight')} - -
-
- setTab(v)} /> -
-
- -
-
-
- {source} -
-
- ); -}; - -export default MetricDetailPage; - -// const Loading = () => ( -//
-//
-//
-//
-//
-//
-//
-//
-//
-//
- -//
-//
-//
-//
-//
-//
- -//
-//
-//
-//
-//
-//
- -//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
- -//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-// ); diff --git a/apps/web/src/modules/analyze/components/NavBar/ContributorDateTagPanel.tsx b/apps/web/src/modules/analyze/components/NavBar/ContributorDateTagPanel.tsx new file mode 100644 index 00000000..0a21a5a8 --- /dev/null +++ b/apps/web/src/modules/analyze/components/NavBar/ContributorDateTagPanel.tsx @@ -0,0 +1,191 @@ +import React, { useMemo } from 'react'; +import { BiCheck } from 'react-icons/bi'; +import { rangeTags } from '@modules/analyze/constant'; +import classnames from 'classnames'; +import { useToggle } from 'react-use'; +import useI18RangeTag from './useI18RangeTag'; +import useQueryDateRange from '@modules/analyze/hooks/useQueryDateRange'; +import useSwitchRange from '@modules/analyze/components/NavBar/useSwitchRange'; +import 'react-datepicker/dist/react-datepicker.css'; +import { useTranslation } from 'next-i18next'; +import DateRangePicker from './DateRangePicker'; +import Tooltip from '@common/components/Tooltip'; +import useVerifyDetailRange from '@modules/analyze/hooks/useVerifyDetailRange'; +import { AiOutlineLoading } from 'react-icons/ai'; + +const ContributorDateTagPanel = ({ + togglePickerPanel, +}: { + togglePickerPanel: (v: boolean) => void; +}) => { + const { t } = useTranslation(); + const i18RangeTag = useI18RangeTag(); + const [showRangePicker, setShowRangePicker] = useToggle(false); + const { range } = useQueryDateRange(); + const { switchRange } = useSwitchRange(); + const { isLoading, data } = useVerifyDetailRange(); + if (isLoading) { + return ( +
+
+ +
+
+ ); + } + const statusFalse = !data?.verifyDetailDataRange?.status; + if (statusFalse) { + return ( +
+
+ {rangeTags.map((time, index) => { + return ( + +
{t('analyze:only_the_latest_month')}
+
+ {t('analyze:for_more_time_frames')} + + + {t('analyze:contact_us')} + + +
+ + } + > +
+ {i18RangeTag[time]} + {range === time && !showRangePicker && ( +
+ +
+ )} +
+
+ ); + })} + +
{t('analyze:only_the_latest_month')}
+
+ {t('analyze:for_more_time_frames')} + + + {t('analyze:contact_us')} + + +
+ + } + > +
+ {t('analyze:custom')} +
+
+
+
+ ); + } else { + return ( +
+
+ {rangeTags.map((t, index) => { + return ( +
{ + await switchRange(t); + togglePickerPanel(false); + setShowRangePicker(false); + }} + > + {i18RangeTag[t]} + {range === t && !showRangePicker && ( +
+ +
+ )} +
+ ); + })} +
{ + setShowRangePicker(true); + }} + > + {t('analyze:custom')} + {showRangePicker && ( +
+ +
+ )} +
+
+
+ { + await switchRange(t); + togglePickerPanel(false); + }} + /> +
+
+ ); + } +}; +export default ContributorDateTagPanel; diff --git a/apps/web/src/modules/analyze/components/NavBar/NavDatePicker.tsx b/apps/web/src/modules/analyze/components/NavBar/NavDatePicker.tsx index e69b31ec..8bde3f99 100644 --- a/apps/web/src/modules/analyze/components/NavBar/NavDatePicker.tsx +++ b/apps/web/src/modules/analyze/components/NavBar/NavDatePicker.tsx @@ -1,8 +1,8 @@ -import React, { useState, useRef, useEffect } from 'react'; +import React from 'react'; import { BiCalendar, BiCaretDown, BiCheck } from 'react-icons/bi'; import { rangeTags } from '@modules/analyze/constant'; import classnames from 'classnames'; -import { useClickAway, useToggle } from 'react-use'; +import { useToggle } from 'react-use'; import useI18RangeTag from './useI18RangeTag'; import useQueryDateRange from '@modules/analyze/hooks/useQueryDateRange'; import useSwitchRange from '@modules/analyze/components/NavBar/useSwitchRange'; @@ -11,6 +11,9 @@ import { useTranslation } from 'next-i18next'; import { ClickAwayListener } from '@mui/base/ClickAwayListener'; import DateRangePicker from './DateRangePicker'; import Popper from '@mui/material/Popper'; +import { useTopicType } from '@modules/analyze/store'; +import { useSnapshot } from 'valtio'; +import ContributorDateTagPanel from './ContributorDateTagPanel'; const DateTagPanel = ({ togglePickerPanel, @@ -20,7 +23,6 @@ const DateTagPanel = ({ const { t } = useTranslation(); const i18RangeTag = useI18RangeTag(); const [showRangePicker, setShowRangePicker] = useToggle(false); - const { range } = useQueryDateRange(); const { switchRange } = useSwitchRange(); @@ -91,7 +93,7 @@ const DateTagPanel = ({ const NavDatePicker = ({ disable }: { disable?: boolean }) => { const i18RangeTag = useI18RangeTag(); const { range } = useQueryDateRange(); - + const { topicType } = useSnapshot(useTopicType); const [anchorEl, setAnchorEl] = React.useState(null); const [pickerPanelOpen, togglePickerPanel] = React.useState(false); @@ -135,11 +137,19 @@ const NavDatePicker = ({ disable }: { disable?: boolean }) => { }, ]} > - { - togglePickerPanel(v); - }} - /> + {topicType === 'contributor' ? ( + { + togglePickerPanel(v); + }} + /> + ) : ( + { + togglePickerPanel(v); + }} + /> + )}
diff --git a/apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicNicheCreation.tsx b/apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicNicheCreation.tsx new file mode 100644 index 00000000..ae807567 --- /dev/null +++ b/apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicNicheCreation.tsx @@ -0,0 +1,62 @@ +import React, { useContext } from 'react'; +import { useTranslation } from 'next-i18next'; +import MenuTopicItem from '../Menu/MenuTopicItem'; +import MenuItem from '../Menu/MenuItem'; +import MenuSubItem from '../Menu/MenuSubItem'; +import { useOrganizationsActivity, Organizations, Topic } from '../config'; +import NicheCreationIcon from '@modules/analyze/components/SideBar/assets/NicheCreation.svg'; +import { SideBarContext } from '@modules/analyze/context/SideBarContext'; + +const NicheCreation = () => { + const { t } = useTranslation(); + const organizationsActivity = useOrganizationsActivity(); + const { menuId, subMenuId } = useContext(SideBarContext); + + const menus = ( + <> + {/* + {t('metrics_models:developer_attraction.title')} + */} + + {organizationsActivity.groups.map((item) => { + return ( + + {item.name} + + ); + })} + + } + > + {t('metrics_models:organizations_activity.title')} + + {/* + {t('metrics_models:technological_advancement.title')} + */} + + ); + + return ( + + + + } + menus={menus} + > + {t('analyze:topic.niche_creation')} + + ); +}; + +export default NicheCreation; diff --git a/apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicProductivity.tsx b/apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicProductivity.tsx new file mode 100644 index 00000000..bab53d0a --- /dev/null +++ b/apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicProductivity.tsx @@ -0,0 +1,96 @@ +import React, { useContext } from 'react'; +import { useTranslation } from 'next-i18next'; +import Chaoss from '@common/components/PoweredBy/Chaoss'; +import ProductivityIcon from '@modules/analyze/components/SideBar/assets/Productivity.svg'; +import MenuTopicItem from '../Menu/MenuTopicItem'; +import MenuItem from '../Menu/MenuItem'; +import MenuSubItem from '../Menu/MenuSubItem'; +import { + CollaborationDevelopment, + useCollaborationDevelopmentIndex, + useCommunityServiceAndSupport, + Support, + Topic, +} from '../config'; +import { SideBarContext } from '@modules/analyze/context/SideBarContext'; + +const Productivity = () => { + const { t } = useTranslation(); + const { menuId, subMenuId } = useContext(SideBarContext); + const collaborationDevelopmentIndex = useCollaborationDevelopmentIndex(); + const communityServiceAndSupport = useCommunityServiceAndSupport(); + + const menu = ( + <> + } + subMenu={ + <> + {collaborationDevelopmentIndex.groups.map((item) => { + return ( + + {item.name} + + ); + })} + + } + > + {t('metrics_models:collaboration_development_index.title')} + + } + subMenu={ + <> + {communityServiceAndSupport.groups.map((item) => { + return ( + + {item.name} + + ); + })} + + } + > + {t('metrics_models:community_service_and_support.title')} + + {/* + {t('metrics_models:code_compliance_guarantee.title')} + + + {t('metrics_models:code_security_guarantee.title')} + + + {t('metrics_models:content.title')} + */} + + ); + + return ( + + + + } + menus={menu} + > + {t('analyze:topic.productivity')} + + ); +}; + +export default Productivity; diff --git a/apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicRobustness.tsx b/apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicRobustness.tsx new file mode 100644 index 00000000..ba9c9909 --- /dev/null +++ b/apps/web/src/modules/analyze/components/SideBar/Collaboration/TopicRobustness.tsx @@ -0,0 +1,73 @@ +import React, { useContext } from 'react'; +import { useTranslation } from 'next-i18next'; +import RobustnessIcon from '@modules/analyze/components/SideBar/assets/Robustness.svg'; +import { Activity, useCommunityActivity, Topic } from '../config'; +import MenuItem from '../Menu/MenuItem'; +import MenuTopicItem from '../Menu/MenuTopicItem'; +import MenuSubItem from '../Menu/MenuSubItem'; +import { SideBarContext } from '@modules/analyze/context/SideBarContext'; +import Chaoss from '@common/components/PoweredBy/Chaoss'; + +const Robustness = () => { + const { t } = useTranslation(); + const communityActivity = useCommunityActivity(); + const { menuId, subMenuId } = useContext(SideBarContext); + + const menu = ( + <> + } + subMenu={ + <> + {communityActivity.groups.map((item) => { + return ( + + {item.name} + + ); + })} + + } + > + {t('metrics_models:activity.title')} + + {/* + {t('metrics_models:developer_convertion.title')} + + + {t('metrics_models:developer_retention.title')} + + + {t('metrics_models:inner_connectedness.title')} + + + {t('metrics_models:organization_collaboration_relationships.title')} + + + {t('metrics_models:outbound_connectedness.title')} + */} + + ); + + return ( + + + + } + menus={menu} + > + {t('analyze:topic.robustness')} + + ); +}; + +export default Robustness; diff --git a/apps/web/src/modules/analyze/components/SideBar/Collaboration/index.tsx b/apps/web/src/modules/analyze/components/SideBar/Collaboration/index.tsx new file mode 100644 index 00000000..db977fdf --- /dev/null +++ b/apps/web/src/modules/analyze/components/SideBar/Collaboration/index.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import TopicProductivity from '@modules/analyze/components/SideBar/Collaboration/TopicProductivity'; +import TopicRobustness from '@modules/analyze/components/SideBar/Collaboration/TopicRobustness'; +import TopicNicheCreation from '@modules/analyze/components/SideBar/Collaboration/TopicNicheCreation'; + +const Divider = () => ( +
+); +const Collaboration = () => { + return ( + <> + + + + + + + + ); +}; +export default Collaboration; diff --git a/apps/web/src/modules/analyze/components/SideBar/Contributor/TopicNicheCreation.tsx b/apps/web/src/modules/analyze/components/SideBar/Contributor/TopicNicheCreation.tsx new file mode 100644 index 00000000..14cc4324 --- /dev/null +++ b/apps/web/src/modules/analyze/components/SideBar/Contributor/TopicNicheCreation.tsx @@ -0,0 +1,34 @@ +import React, { useContext } from 'react'; +import { useTranslation } from 'next-i18next'; +import MenuTopicItem from '../Menu/MenuTopicItem'; +import MenuItem from '../Menu/MenuItem'; +import { Topic } from '../config'; +import NicheCreationIcon from '@modules/analyze/components/SideBar/assets/NicheCreation.svg'; + +const NicheCreation = () => { + const { t } = useTranslation(); + + const menus = ( + <> + + {t('metrics_models:contributor_route.title')} + + + ); + + return ( + + + + } + menus={menus} + > + {t('analyze:topic.niche_creation')} + + ); +}; + +export default NicheCreation; diff --git a/apps/web/src/modules/analyze/components/SideBar/Contributor/TopicProductivity.tsx b/apps/web/src/modules/analyze/components/SideBar/Contributor/TopicProductivity.tsx new file mode 100644 index 00000000..268cc539 --- /dev/null +++ b/apps/web/src/modules/analyze/components/SideBar/Contributor/TopicProductivity.tsx @@ -0,0 +1,56 @@ +import React, { useContext } from 'react'; +import { useTranslation } from 'next-i18next'; +import ProductivityIcon from '@modules/analyze/components/SideBar/assets/Productivity.svg'; +import MenuTopicItem from '../Menu/MenuTopicItem'; +import MenuItem from '../Menu/MenuItem'; +import MenuSubItem from '../Menu/MenuSubItem'; +import { ContributorsPersona, useContributorsPersona, Topic } from '../config'; +import { SideBarContext } from '@modules/analyze/context/SideBarContext'; + +const Productivity = () => { + const { t } = useTranslation(); + const { menuId, subMenuId } = useContext(SideBarContext); + const contributorsPersonaItems = useContributorsPersona(); + + const menu = ( + <> + + {contributorsPersonaItems.groups.map((item) => { + return ( + + {item.name} + + ); + })} + + } + > + {t('metrics_models:contributors_persona.title')} + + + ); + + return ( + + + + } + menus={menu} + > + {t('analyze:topic.productivity')} + + ); +}; + +export default Productivity; diff --git a/apps/web/src/modules/analyze/components/SideBar/Contributor/TopicRobustness.tsx b/apps/web/src/modules/analyze/components/SideBar/Contributor/TopicRobustness.tsx new file mode 100644 index 00000000..9494e68d --- /dev/null +++ b/apps/web/src/modules/analyze/components/SideBar/Contributor/TopicRobustness.tsx @@ -0,0 +1,40 @@ +import React, { useContext } from 'react'; +import { useTranslation } from 'next-i18next'; +import RobustnessIcon from '@modules/analyze/components/SideBar/assets/Robustness.svg'; +import { Activity, useCommunityActivity, Topic } from '../config'; +import MenuItem from '../Menu/MenuItem'; +import MenuTopicItem from '../Menu/MenuTopicItem'; +import MenuSubItem from '../Menu/MenuSubItem'; +import { SideBarContext } from '@modules/analyze/context/SideBarContext'; +import Chaoss from '@common/components/PoweredBy/Chaoss'; + +const Robustness = () => { + const { t } = useTranslation(); + + const menu = ( + <> + + {t('metrics_models:contributor_reputation.title')} + + + {t('metrics_models:user_reputation.title')} + + + ); + + return ( + + + + } + menus={menu} + > + {t('analyze:topic.robustness')} + + ); +}; + +export default Robustness; diff --git a/apps/web/src/modules/analyze/components/SideBar/Contributor/index.tsx b/apps/web/src/modules/analyze/components/SideBar/Contributor/index.tsx new file mode 100644 index 00000000..fbacc217 --- /dev/null +++ b/apps/web/src/modules/analyze/components/SideBar/Contributor/index.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import TopicProductivity from '@modules/analyze/components/SideBar/Contributor/TopicProductivity'; +import TopicRobustness from '@modules/analyze/components/SideBar/Contributor/TopicRobustness'; +import TopicNicheCreation from '@modules/analyze/components/SideBar/Contributor/TopicNicheCreation'; + +const Divider = () => ( +
+); +const Contributor = () => { + return ( + <> + + + + + + + + ); +}; +export default Contributor; diff --git a/apps/web/src/modules/analyze/components/SideBar/TopicTab.tsx b/apps/web/src/modules/analyze/components/SideBar/TopicTab.tsx new file mode 100644 index 00000000..9d233ec6 --- /dev/null +++ b/apps/web/src/modules/analyze/components/SideBar/TopicTab.tsx @@ -0,0 +1,32 @@ +import React from 'react'; +import { useTranslation } from 'next-i18next'; +import MyTab from '@common/components/Tab'; +import { useTopicType, setTopicType, TopicType } from '@modules/analyze/store'; +import { useSnapshot } from 'valtio'; + +const TopicTab = () => { + const { t } = useTranslation(); + const { topicType } = useSnapshot(useTopicType); + const tabOptions = [ + { + label: t('analyze:collaboration'), + value: 'collaboration', + }, + { label: t('analyze:contributor'), value: 'contributor' }, + { label: t('analyze:software'), value: 'software', disable: true }, + ]; + + return ( +
+
+ setTopicType(v as TopicType)} + /> +
+
+ ); +}; + +export default TopicTab; diff --git a/apps/web/src/modules/analyze/components/SideBar/config.ts b/apps/web/src/modules/analyze/components/SideBar/config.ts index 5e8d9737..90335ced 100644 --- a/apps/web/src/modules/analyze/components/SideBar/config.ts +++ b/apps/web/src/modules/analyze/components/SideBar/config.ts @@ -46,7 +46,12 @@ export enum Organizations { // MeetingFrequency= 'MeetingFrequency', // MeetingAttendeeCount = "MeetingAttendeeCount" } - +export enum ContributorsPersona { + Overview = 'contributors_persona_overview', + Contributor = 'contributors_persona_contributor', + Issue = 'contributors_persona_issue', + Pr = 'contributors_persona_pr', +} export enum Topic { Overview = 'topic_overview', Productivity = 'topic_productivity', @@ -59,7 +64,7 @@ export enum Section { CommunityServiceAndSupport = 'community_service_support', CommunityActivity = 'community_activity', OrganizationsActivity = 'organizations_activity', - StarterProjectHealth = 'starter_project_health', + ContributorsPersona = 'contributors_persona', } export const useCollaborationDevelopmentIndex = () => { @@ -263,3 +268,25 @@ export const useOrganizationsActivity = () => { ], }; }; +export const useContributorsPersona = () => { + const { t } = useTranslation(); + return { + topic: Topic.NicheCreation, + name: t('metrics_models:contributors_persona.title'), + id: Organizations.Overview, + groups: [ + { + name: t('metrics_models:contributors_persona.metrics.contributor'), + id: ContributorsPersona.Contributor, + }, + { + name: t('metrics_models:contributors_persona.metrics.issue'), + id: ContributorsPersona.Issue, + }, + { + name: t('metrics_models:contributors_persona.metrics.pr'), + id: ContributorsPersona.Pr, + }, + ], + }; +}; diff --git a/apps/web/src/modules/analyze/components/SideBar/index.tsx b/apps/web/src/modules/analyze/components/SideBar/index.tsx index 02c51beb..571f74f9 100644 --- a/apps/web/src/modules/analyze/components/SideBar/index.tsx +++ b/apps/web/src/modules/analyze/components/SideBar/index.tsx @@ -7,13 +7,15 @@ import { checkIsPending } from '@modules/analyze/constant'; import useHashchangeEvent from '@common/hooks/useHashchangeEvent'; import MenuLoading from '@modules/analyze/components/SideBar/Menu/MenuLoading'; import TopicOverview from '@modules/analyze/components/SideBar/TopicOverview'; -import TopicProductivity from '@modules/analyze/components/SideBar/TopicProductivity'; -import TopicRobustness from '@modules/analyze/components/SideBar/TopicRobustness'; -import TopicNicheCreation from '@modules/analyze/components/SideBar/TopicNicheCreation'; +import TopicTab from '@modules/analyze/components/SideBar/TopicTab'; +import Collaboration from '@modules/analyze/components/SideBar/Collaboration'; +import Contributor from '@modules/analyze/components/SideBar/Contributor'; import useActiveMenuId from '@modules/analyze/components/SideBar/useActiveMenuId'; import NoSsr from '@common/components/NoSsr'; import { SideBarContextProvider } from '@modules/analyze/context/SideBarContext'; import ErrorFallback from '@common/components/ErrorFallback'; +import { useTopicType } from '@modules/analyze/store'; +import { useSnapshot } from 'valtio'; const Divider = () => (
@@ -22,15 +24,19 @@ const Divider = () => ( const SideBarMenuContent = () => { const activeId = useHashchangeEvent(); const active = useActiveMenuId(activeId); + const { topicType } = useSnapshot(useTopicType); + + let source; + if (topicType === 'collaboration') { + source = ; + } else { + source = ; + } return ( + - - - - - - + {source} ); }; diff --git a/apps/web/src/modules/analyze/hooks/useQueryDateRange.ts b/apps/web/src/modules/analyze/hooks/useQueryDateRange.ts index 615da9d3..dff8fa9b 100644 --- a/apps/web/src/modules/analyze/hooks/useQueryDateRange.ts +++ b/apps/web/src/modules/analyze/hooks/useQueryDateRange.ts @@ -1,12 +1,20 @@ import { useMemo } from 'react'; import { useRouter } from 'next/router'; import { RangeTag, rangeTags, timeRange } from '../constant'; +import { useTopicType } from '@modules/analyze/store'; +import { useSnapshot } from 'valtio'; +import useVerifyDetailRange from '@modules/analyze/hooks/useVerifyDetailRange'; const defaultVal = { range: '6M' as RangeTag, timeStart: timeRange['6M'].start, timeEnd: timeRange['6M'].end, }; +const contributorDefaultVal = { + range: '1M' as RangeTag, + timeStart: timeRange['1M'].start, + timeEnd: timeRange['1M'].end, +}; export const isDateRange = (range: string) => { if (range.includes(' ~ ')) { const start = range.split(' ~ ')[0]; @@ -23,7 +31,13 @@ export const isDateRange = (range: string) => { const useQueryDateRange = () => { const router = useRouter(); const range = router.query.range as RangeTag; + const { topicType } = useSnapshot(useTopicType); + const { isLoading, data } = useVerifyDetailRange(); + return useMemo(() => { + if (topicType === 'contributor' && !data?.verifyDetailDataRange?.status) { + return contributorDefaultVal; + } if (!range) { return defaultVal; } else if (rangeTags.includes(range)) { @@ -42,7 +56,7 @@ const useQueryDateRange = () => { } else { return defaultVal; } - }, [range]); + }, [range, topicType, data]); }; export default useQueryDateRange; diff --git a/apps/web/src/modules/analyze/hooks/useVerifyDetailRange.ts b/apps/web/src/modules/analyze/hooks/useVerifyDetailRange.ts new file mode 100644 index 00000000..61cfca87 --- /dev/null +++ b/apps/web/src/modules/analyze/hooks/useVerifyDetailRange.ts @@ -0,0 +1,15 @@ +import client from '@common/gqlClient'; +import { useVerifyDetailDataRangeQuery } from '@oss-compass/graphql'; +import useExtractShortIds from './useExtractShortIds'; + +const useVerifyDetailRange = () => { + const { shortIds } = useExtractShortIds(); + + const { data, isLoading } = useVerifyDetailDataRangeQuery(client, { + shortCode: shortIds[0], + }); + + return { isLoading, data }; +}; + +export default useVerifyDetailRange; diff --git a/apps/web/src/modules/analyze/store/index.ts b/apps/web/src/modules/analyze/store/index.ts index 5927bfda..3ac8c645 100644 --- a/apps/web/src/modules/analyze/store/index.ts +++ b/apps/web/src/modules/analyze/store/index.ts @@ -1,2 +1,3 @@ export * from './chartTheme'; export * from './chartUserSetting'; +export * from './topicType'; diff --git a/apps/web/src/modules/analyze/store/topicType.ts b/apps/web/src/modules/analyze/store/topicType.ts new file mode 100644 index 00000000..7acdf776 --- /dev/null +++ b/apps/web/src/modules/analyze/store/topicType.ts @@ -0,0 +1,12 @@ +import { proxy } from 'valtio'; + +export type TopicType = 'collaboration' | 'contributor' | null; +export const useTopicType = proxy<{ + topicType: TopicType; +}>({ + topicType: 'collaboration', +}); + +export const setTopicType = (v: TopicType) => { + useTopicType.topicType = v; +}; diff --git a/apps/web/src/pages/analyze/metric/[slugs].tsx b/apps/web/src/pages/analyze/metric/[slugs].tsx deleted file mode 100644 index 342ebbab..00000000 --- a/apps/web/src/pages/analyze/metric/[slugs].tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import { GetServerSideProps } from 'next'; -import getLocalesFile from '@common/utils/getLocalesFile'; -import MetricDetailPage from '@modules/analyze/MetricDetailPage'; -import AuthRequire from '@modules/auth/AuthRequire'; - -export const getServerSideProps: GetServerSideProps = async ({ req, res }) => { - return { - props: { - ...(await getLocalesFile(req.cookies, ['analyze', 'metrics_models'])), - }, - }; -}; - -const MetricDetail = () => { - return ( - - - - ); -}; - -export default MetricDetail; diff --git a/apps/web/src/styles/antd.scss b/apps/web/src/styles/antd.scss new file mode 100644 index 00000000..baa3e8b0 --- /dev/null +++ b/apps/web/src/styles/antd.scss @@ -0,0 +1,30 @@ +:where(.css-dev-only-do-not-override-pr0fja).ant-btn-primary { + background-color: #1677ff !important; +} +.ant-spin-nested-loading { + height: 100%; + .ant-spin-container { + height: 100%; + display: flex; + flex-direction: column; + } + .ant-table-container { + height: 100%; + display: flex; + flex-direction: column; + .ant-table-body { + position: relative; + flex: 1; + table { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + } + } + } + .ant-table { + flex: 1; + } +} diff --git a/apps/web/src/styles/globals.scss b/apps/web/src/styles/globals.scss index a342a942..5700d8c6 100644 --- a/apps/web/src/styles/globals.scss +++ b/apps/web/src/styles/globals.scss @@ -1,4 +1,5 @@ @import 'tailwind.css'; +@import 'antd.scss'; html, body { @@ -77,6 +78,3 @@ input[type='submit'] { .viewer-backdrop { background-color: rgba(0, 0, 0, 70%); } -:where(.css-dev-only-do-not-override-pr0fja).ant-btn-primary { - background-color: #1677ff !important; -} diff --git a/packages/graphql/src/generated.ts b/packages/graphql/src/generated.ts index 139b9360..dc415cde 100644 --- a/packages/graphql/src/generated.ts +++ b/packages/graphql/src/generated.ts @@ -1401,8 +1401,6 @@ export type Query = { metricGroupActivity: Array; /** Get overview data of metrics set on compass lab */ metricSetOverview?: Maybe>; - /** Get starter project health metrics data of compass */ - metricStarterProjectHealth: Array; /** Get my member permissions of a lab model */ myMemberPermission?: Maybe; /** Get detail data of my lab models */ @@ -1424,6 +1422,8 @@ export type Query = { summaryGroupActivity: Array; /** Get trending data of compass */ trending: Array; + /** Check if the data range is valid */ + verifyDetailDataRange: ValidDataRange; }; export type QueryAnalysisStatusArgs = { @@ -1647,13 +1647,6 @@ export type QueryMetricGroupActivityArgs = { repoType?: InputMaybe; }; -export type QueryMetricStarterProjectHealthArgs = { - beginDate?: InputMaybe; - endDate?: InputMaybe; - label: Scalars['String']; - level?: InputMaybe; -}; - export type QueryMyMemberPermissionArgs = { modelId?: InputMaybe; }; @@ -1718,6 +1711,13 @@ export type QueryTrendingArgs = { level?: InputMaybe; }; +export type QueryVerifyDetailDataRangeArgs = { + beginDate?: InputMaybe; + endDate?: InputMaybe; + label?: InputMaybe; + shortCode?: InputMaybe; +}; + export type Repo = { __typename?: 'Repo'; backend?: Maybe; @@ -1822,46 +1822,6 @@ export type SortOptionInput = { type: Scalars['String']; }; -export type StarterProjectHealthMetric = { - __typename?: 'StarterProjectHealthMetric'; - /** the smallest number of people that make 50% of contributions */ - busFactor?: Maybe; - /** the change request closure ratio same period */ - changeRequestClosedCountAllPeriod?: Maybe; - /** the change request closed count recently */ - changeRequestClosedCountRecently?: Maybe; - /** the change request closure ratio all period */ - changeRequestClosureRatioAllPeriod?: Maybe; - /** the change request closure ratio recently */ - changeRequestClosureRatioRecently?: Maybe; - /** the change request created count all period */ - changeRequestCreatedCountAllPeriod?: Maybe; - /** the change request created count recently */ - changeRequestCreatedCountRecently?: Maybe; - /** metric model creatiton time */ - grimoireCreationDate?: Maybe; - /** metric model object identification */ - label?: Maybe; - /** metric model object level */ - level?: Maybe; - /** mean of pull request time to close */ - prTimeToCloseAvg?: Maybe; - /** middle of pull request time to close */ - prTimeToCloseMid?: Maybe; - /** mean of pull request time to first response */ - prTimeToFirstResponseAvg?: Maybe; - /** middle of pull request time to first response */ - prTimeToFirstResponseMid?: Maybe; - /** the frequency of project releases (including point releases with bug fixes) */ - releaseFrequency?: Maybe; - /** metric model object short code */ - shortCode?: Maybe; - /** score of starter project health model */ - starterProjectHealth?: Maybe; - /** metric scores for repositories type, only for community (software-artifact/governance) */ - type?: Maybe; -}; - export type SubjectSubscriptionCount = { __typename?: 'SubjectSubscriptionCount'; count: Scalars['Int']; @@ -2078,6 +2038,22 @@ export type UserUnbindPayload = { status: Scalars['String']; }; +export type ValidDataRange = { + __typename?: 'ValidDataRange'; + /** metric model object identification */ + label?: Maybe; + /** metric model object level (project or repo) */ + level?: Maybe; + /** max valid date */ + max?: Maybe; + /** min valid date */ + min?: Maybe; + /** metric model object short code */ + shortCode?: Maybe; + /** whether it is a valid data range */ + status?: Maybe; +}; + export type CommentFragment = { __typename?: 'ModelComment'; content: string; @@ -4060,38 +4036,6 @@ export type SummaryQuery = { }>; }; -export type LabMetricQueryVariables = Exact<{ - label: Scalars['String']; - level?: InputMaybe; - start?: InputMaybe; - end?: InputMaybe; -}>; - -export type LabMetricQuery = { - __typename?: 'Query'; - metricStarterProjectHealth: Array<{ - __typename?: 'StarterProjectHealthMetric'; - busFactor?: number | null; - changeRequestClosedCountAllPeriod?: number | null; - changeRequestClosedCountRecently?: number | null; - changeRequestClosureRatioAllPeriod?: number | null; - changeRequestClosureRatioRecently?: number | null; - changeRequestCreatedCountAllPeriod?: number | null; - changeRequestCreatedCountRecently?: number | null; - grimoireCreationDate?: any | null; - label?: string | null; - level?: string | null; - shortCode?: string | null; - prTimeToCloseAvg?: number | null; - prTimeToCloseMid?: number | null; - prTimeToFirstResponseAvg?: number | null; - prTimeToFirstResponseMid?: number | null; - releaseFrequency?: number | null; - starterProjectHealth?: number | null; - type?: string | null; - }>; -}; - export type MetricStatFragment = { __typename?: 'MetricStat'; mean?: number | null; @@ -4560,6 +4504,23 @@ export type PullsCommentQuery = { }; }; +export type VerifyDetailDataRangeQueryVariables = Exact<{ + label?: InputMaybe; + shortCode?: InputMaybe; + beginDate?: InputMaybe; + endDate?: InputMaybe; +}>; + +export type VerifyDetailDataRangeQuery = { + __typename?: 'Query'; + verifyDetailDataRange: { + __typename?: 'ValidDataRange'; + status?: boolean | null; + max?: any | null; + min?: any | null; + }; +}; + export const MetricsFragmentDoc = /*#__PURE__*/ ` fragment metrics on ModelMetric { category @@ -7363,67 +7324,6 @@ useSummaryQuery.fetcher = ( variables, headers ); -export const LabMetricDocument = /*#__PURE__*/ ` - query labMetric($label: String!, $level: String = "repo", $start: ISO8601DateTime, $end: ISO8601DateTime) { - metricStarterProjectHealth( - label: $label - level: $level - beginDate: $start - endDate: $end - ) { - busFactor - changeRequestClosedCountAllPeriod - changeRequestClosedCountRecently - changeRequestClosureRatioAllPeriod - changeRequestClosureRatioRecently - changeRequestCreatedCountAllPeriod - changeRequestCreatedCountRecently - grimoireCreationDate - label - level - shortCode - prTimeToCloseAvg - prTimeToCloseMid - prTimeToFirstResponseAvg - prTimeToFirstResponseMid - releaseFrequency - starterProjectHealth - type - } -} - `; -export const useLabMetricQuery = ( - client: GraphQLClient, - variables: LabMetricQueryVariables, - options?: UseQueryOptions, - headers?: RequestInit['headers'] -) => - useQuery( - ['labMetric', variables], - fetcher( - client, - LabMetricDocument, - variables, - headers - ), - options - ); - -useLabMetricQuery.getKey = (variables: LabMetricQueryVariables) => [ - 'labMetric', - variables, -]; -useLabMetricQuery.fetcher = ( - client: GraphQLClient, - variables: LabMetricQueryVariables, - headers?: RequestInit['headers'] -) => - fetcher( - client, - LabMetricDocument, - variables, - headers - ); export const CollectionHottestDocument = /*#__PURE__*/ ` query collectionHottest($ident: String!, $limit: Int) { collectionHottest(ident: $ident, limit: $limit) { @@ -8420,3 +8320,56 @@ usePullsCommentQuery.fetcher = ( variables, headers ); +export const VerifyDetailDataRangeDocument = /*#__PURE__*/ ` + query verifyDetailDataRange($label: String, $shortCode: String, $beginDate: ISO8601DateTime, $endDate: ISO8601DateTime) { + verifyDetailDataRange( + label: $label + shortCode: $shortCode + beginDate: $beginDate + endDate: $endDate + ) { + status + max + min + } +} + `; +export const useVerifyDetailDataRangeQuery = < + TData = VerifyDetailDataRangeQuery, + TError = unknown +>( + client: GraphQLClient, + variables?: VerifyDetailDataRangeQueryVariables, + options?: UseQueryOptions, + headers?: RequestInit['headers'] +) => + useQuery( + variables === undefined + ? ['verifyDetailDataRange'] + : ['verifyDetailDataRange', variables], + fetcher( + client, + VerifyDetailDataRangeDocument, + variables, + headers + ), + options + ); + +useVerifyDetailDataRangeQuery.getKey = ( + variables?: VerifyDetailDataRangeQueryVariables +) => + variables === undefined + ? ['verifyDetailDataRange'] + : ['verifyDetailDataRange', variables]; +useVerifyDetailDataRangeQuery.fetcher = ( + client: GraphQLClient, + variables?: VerifyDetailDataRangeQueryVariables, + headers?: RequestInit['headers'] +) => + fetcher( + client, + VerifyDetailDataRangeDocument, + variables, + headers + ); diff --git a/packages/graphql/src/gql/query.graphql b/packages/graphql/src/gql/query.graphql index 1526bd4b..7f43afb8 100644 --- a/packages/graphql/src/gql/query.graphql +++ b/packages/graphql/src/gql/query.graphql @@ -422,38 +422,38 @@ query summary($start: ISO8601DateTime, $end: ISO8601DateTime) { # } } -query labMetric( - $label: String! - $level: String = "repo" - $start: ISO8601DateTime - $end: ISO8601DateTime -) { - metricStarterProjectHealth( - label: $label - level: $level - beginDate: $start - endDate: $end - ) { - busFactor - changeRequestClosedCountAllPeriod - changeRequestClosedCountRecently - changeRequestClosureRatioAllPeriod - changeRequestClosureRatioRecently - changeRequestCreatedCountAllPeriod - changeRequestCreatedCountRecently - grimoireCreationDate - label - level - shortCode - prTimeToCloseAvg - prTimeToCloseMid - prTimeToFirstResponseAvg - prTimeToFirstResponseMid - releaseFrequency - starterProjectHealth - type - } -} +# query labMetric( +# $label: String! +# $level: String = "repo" +# $start: ISO8601DateTime +# $end: ISO8601DateTime +# ) { +# metricStarterProjectHealth( +# label: $label +# level: $level +# beginDate: $start +# endDate: $end +# ) { +# busFactor +# changeRequestClosedCountAllPeriod +# changeRequestClosedCountRecently +# changeRequestClosureRatioAllPeriod +# changeRequestClosureRatioRecently +# changeRequestCreatedCountAllPeriod +# changeRequestCreatedCountRecently +# grimoireCreationDate +# label +# level +# shortCode +# prTimeToCloseAvg +# prTimeToCloseMid +# prTimeToFirstResponseAvg +# prTimeToFirstResponseMid +# releaseFrequency +# starterProjectHealth +# type +# } +# } fragment metricStat on MetricStat { mean @@ -879,3 +879,20 @@ query pullsComment( } } } +query verifyDetailDataRange( + $label: String + $shortCode: String + $beginDate: ISO8601DateTime + $endDate: ISO8601DateTime +) { + verifyDetailDataRange( + label: $label + shortCode: $shortCode + beginDate: $beginDate + endDate: $endDate + ) { + status + max + min + } +}