From d6bd27670144ecd923cb96022a273f55aa19ba68 Mon Sep 17 00:00:00 2001 From: laixingyou Date: Wed, 6 Mar 2024 11:37:59 +0800 Subject: [PATCH 1/3] fix: download add timestamp Signed-off-by: laixingyou --- .../ContributorTable/index.tsx | 5 +- .../ContributorTable/tableDownload.ts | 48 ------------------- .../DataView/MetricDetail/tableDownload.ts | 12 +++-- 3 files changed, 13 insertions(+), 52 deletions(-) delete mode 100644 apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable/tableDownload.ts 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 4cb48348..774fa7e8 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 @@ -14,7 +14,10 @@ import { useMileageOptions, } from '../contribution'; import { getMaxDomain } from '../utils'; -import { getContributorPolling, getContributorExport } from './tableDownload'; +import { + getContributorPolling, + getContributorExport, +} from '../../tableDownload'; import DomainPersona from './DomainPersona'; import ContributorName from './ContributorName'; import ContributorDropdown from './ContributorDropdown'; diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable/tableDownload.ts b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable/tableDownload.ts deleted file mode 100644 index bcd8cab6..00000000 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable/tableDownload.ts +++ /dev/null @@ -1,48 +0,0 @@ -import axios from 'axios'; - -export enum Status { - PENDING = 'pending', - PROGRESS = 'progress', - COMPLETE = 'complete', - UNKNOWN = 'unknown', -} -export const apiDownloadFiles = (path, fileName, onFinish) => { - let link = document.createElement('a'); - link.href = path; - link.download = fileName + '.csv'; - link.style.display = 'none'; - document.body.appendChild(link); - link.click(); - onFinish && onFinish(); - document.body.removeChild(link); -}; -export const getContributorPolling = (uuid) => { - return axios.get('/api/v1/contributor/export_state/' + uuid); -}; -export const getContributorExport = (query) => { - return axios.post('/api/v1/contributor/export', query, { - headers: { - accept: 'application/json', - }, - }); -}; -export const getIssuePolling = (uuid) => { - return axios.get('/api/v1/issue/export_state/' + uuid); -}; -export const getIssueExport = (query) => { - return axios.post('/api/v1/issue/export', query, { - headers: { - accept: 'application/json', - }, - }); -}; -export const getPrPolling = (uuid) => { - return axios.get('/api/v1/pull/export_state/' + uuid); -}; -export const getPrExport = (query) => { - return axios.post('/api/v1/pull/export', query, { - headers: { - accept: 'application/json', - }, - }); -}; diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/tableDownload.ts b/apps/web/src/modules/analyze/DataView/MetricDetail/tableDownload.ts index bcd8cab6..4b5db040 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/tableDownload.ts +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/tableDownload.ts @@ -17,7 +17,9 @@ export const apiDownloadFiles = (path, fileName, onFinish) => { document.body.removeChild(link); }; export const getContributorPolling = (uuid) => { - return axios.get('/api/v1/contributor/export_state/' + uuid); + return axios.get( + '/api/v1/contributor/export_state/' + uuid + '?t=' + new Date().getTime() + ); }; export const getContributorExport = (query) => { return axios.post('/api/v1/contributor/export', query, { @@ -27,7 +29,9 @@ export const getContributorExport = (query) => { }); }; export const getIssuePolling = (uuid) => { - return axios.get('/api/v1/issue/export_state/' + uuid); + return axios.get( + '/api/v1/issue/export_state/' + uuid + '?t=' + new Date().getTime() + ); }; export const getIssueExport = (query) => { return axios.post('/api/v1/issue/export', query, { @@ -37,7 +41,9 @@ export const getIssueExport = (query) => { }); }; export const getPrPolling = (uuid) => { - return axios.get('/api/v1/pull/export_state/' + uuid); + return axios.get( + '/api/v1/pull/export_state/' + uuid + '?t=' + new Date().getTime() + ); }; export const getPrExport = (query) => { return axios.post('/api/v1/pull/export', query, { From 0f41676da3c28f2210eab0b546e164bfe0f96de7 Mon Sep 17 00:00:00 2001 From: laixingyou Date: Fri, 8 Mar 2024 17:11:51 +0800 Subject: [PATCH 2/3] fix: add org edit platform Signed-off-by: laixingyou --- .../components/OrgEdit/ManageOrgEdit.tsx | 5 ++++- .../src/common/components/OrgEdit/index.tsx | 6 ++++-- .../ContributorTable/index.tsx | 1 + .../settings/profile/Organizations.tsx | 21 ++++++++++++------- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/apps/web/src/common/components/OrgEdit/ManageOrgEdit.tsx b/apps/web/src/common/components/OrgEdit/ManageOrgEdit.tsx index 136fa962..fdf6812c 100644 --- a/apps/web/src/common/components/OrgEdit/ManageOrgEdit.tsx +++ b/apps/web/src/common/components/OrgEdit/ManageOrgEdit.tsx @@ -17,18 +17,21 @@ const ManageOrgEdit = ({ level, contributor, name, + provider, setShowEdit, }: { label?: string; level?: string; contributor?: string; name?: string; + provider?: string; setShowEdit: (b: boolean) => void; }) => { const { t } = useTranslation(); const [orgName, setOrgName] = useState(name || ''); const [date, setDate] = useState(null); const [form] = Form.useForm(); + const onCheck = async () => { try { const values = await form.validateFields(); @@ -39,7 +42,7 @@ const ManageOrgEdit = ({ label, level, contributor, - platform: 'github', + platform: provider, organizations: [{ orgName, firstDate, lastDate }], }); } catch (errorInfo) { diff --git a/apps/web/src/common/components/OrgEdit/index.tsx b/apps/web/src/common/components/OrgEdit/index.tsx index 4905f716..db72f05a 100644 --- a/apps/web/src/common/components/OrgEdit/index.tsx +++ b/apps/web/src/common/components/OrgEdit/index.tsx @@ -20,12 +20,14 @@ const OrgEdit = ({ organizations = [], type = 'add', index, + provider, setShowEdit, onSuccess, }: { organizations?: ContributorOrgInput[]; type?: 'add' | 'edit'; index?: number; + provider: string; setShowEdit: (b: boolean) => void; onSuccess?: () => void; }) => { @@ -51,12 +53,12 @@ const OrgEdit = ({ if (type === 'edit') { organizations[index] = { orgName, firstDate, lastDate }; mutation.mutate({ - platform: 'github', + platform: provider, organizations: [...organizations], }); } else { mutation.mutate({ - platform: 'github', + platform: provider, organizations: [{ orgName, firstDate, lastDate }, ...organizations], }); } 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 774fa7e8..0388ac87 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 @@ -378,6 +378,7 @@ const MetricTable: React.FC<{ level={level} contributor={currentName} name={currentOrgName} + provider={origin} setShowEdit={() => { setOpenConfirm(false); }} diff --git a/apps/web/src/modules/settings/profile/Organizations.tsx b/apps/web/src/modules/settings/profile/Organizations.tsx index a19784fb..d425c4a7 100644 --- a/apps/web/src/modules/settings/profile/Organizations.tsx +++ b/apps/web/src/modules/settings/profile/Organizations.tsx @@ -12,8 +12,9 @@ import { useModifyUserOrgsMutation, ContributorOrgInput, } from '@oss-compass/graphql'; +import { cookieGetAuthProvider } from '@common/utils/cookie'; -const OrgItem = ({ provider, index, organizations, onSuccess }) => { +const OrgItem = ({ org, index, organizations, onSuccess, provider }) => { const customFormat = (date) => { if (date.startsWith('2099')) { return t('common:up_to_now'); @@ -41,7 +42,7 @@ const OrgItem = ({ provider, index, organizations, onSuccess }) => { const arr = [...organizations]; arr.splice(index, 1); mutation.mutate({ - platform: 'github', + platform: provider, organizations: [...arr], }); }; @@ -52,6 +53,7 @@ const OrgItem = ({ provider, index, organizations, onSuccess }) => { setShowEdit={setShowEdit} organizations={organizations as ContributorOrgInput[]} onSuccess={onSuccess} + provider={provider} type={'edit'} index={index} /> @@ -59,14 +61,13 @@ const OrgItem = ({ provider, index, organizations, onSuccess }) => {
- - {provider.orgName} + + {org.orgName}
-
{customFormat(provider?.firstDate)}
- {'-'}{' '} -
{customFormat(provider?.lastDate)}
+
{customFormat(org?.firstDate)}
+ {'-'}
{customFormat(org?.lastDate)}
@@ -88,6 +89,8 @@ const OrgItem = ({ provider, index, organizations, onSuccess }) => { const Organizations = () => { const { t } = useTranslation(); const { currentUser } = useSnapshot(userInfoStore); + const provider = cookieGetAuthProvider(); + const contributingOrgs = currentUser.contributingOrgs.map((item) => { return { orgName: item.orgName, @@ -112,10 +115,11 @@ const Organizations = () => { return ( ); })} @@ -125,6 +129,7 @@ const Organizations = () => { setShowEdit={setShowEdit} organizations={contributingOrgs as ContributorOrgInput[]} onSuccess={onSuccess} + provider={provider} /> )}
From 9c678177be45d70f161be82de614315596cbc319 Mon Sep 17 00:00:00 2001 From: laixingyou Date: Fri, 8 Mar 2024 17:25:48 +0800 Subject: [PATCH 3/3] fix: mobile style Signed-off-by: laixingyou --- .../MetricContributor/ContributorContribution.tsx | 2 +- .../MetricContributor/ContributorOrganizations.tsx | 5 ++++- .../analyze/DataView/MetricDetail/index.tsx | 14 +++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContribution.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContribution.tsx index 29c75474..74a9c16e 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContribution.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorContribution.tsx @@ -23,7 +23,7 @@ const ContributorContribution: React.FC<{ const [onlyOrg, setOnlyOrg] = useState(false); return ( -
+
+
{ const { isLoading } = useVerifyDetailRangeQuery(); @@ -79,7 +80,7 @@ const MetricDetail = () => { {t('analyze:metric_detail:project_deep_dive_insight')}
-
+
{ }} />
+
+