Skip to content

Commit

Permalink
feat: add contributor avatar and fix Weekly Meeting date (#319)
Browse files Browse the repository at this point in the history
Signed-off-by: laixingyou <[email protected]>
  • Loading branch information
coder-sett authored Feb 22, 2024
1 parent 63dde50 commit 0b7f788
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';
import { IoPeopleCircle } from 'react-icons/io5';
import Image from 'next/image';

const DomainPersona = ({ name, origin }) => {
let icon = getIcons(origin, name);

return (
<div className="flex">
<div>{icon}</div>
{name}
</div>
);
};

const getIcons = (origin, name) => {
switch (origin) {
case 'github':
return (
<div className="relative mr-2 h-6 w-6 overflow-hidden rounded-full border border-gray-100">
<Image
src={'https://github.com/' + name + '.png'}
onError={(e) => (e.currentTarget.src = '/images/github.png')}
unoptimized
fill={true}
style={{
objectFit: 'cover',
}}
alt="icon"
placeholder="blur"
blurDataURL="/images/github.png"
/>
</div>
);
case 'gitee':
return (
<div className="relative mr-2 h-6 w-6 overflow-hidden rounded-full border border-gray-100">
<Image
src={'https://gitee.com/' + name + '.png'}
onError={(e) =>
(e.currentTarget.src = '/images/logos/gitee-red.svg')
}
unoptimized
fill={true}
style={{
objectFit: 'cover',
}}
alt="icon"
placeholder="blur"
blurDataURL="/images/logos/gitee-red.svg"
/>
</div>
);
// return <SiGitee color="#c71c27" className="mr-0" />;
default:
return <IoPeopleCircle />;
}
};

export default DomainPersona;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getDomainData } from '../utils';
import { toFixed } from '@common/utils';
import classnames from 'classnames';
import Popper from '@mui/material/Popper';
import { ClickAwayListener } from '@mui/base/ClickAwayListener';

const PopperContent = ({ dataList, name, active, setActive }) => {
const { t } = useTranslation();
Expand Down Expand Up @@ -65,7 +64,6 @@ const PopperContent = ({ dataList, name, active, setActive }) => {
};

const DomainPersona = ({ maxDomain, dataList, name }) => {
const { t } = useTranslation();
const contributionTypeMap = useGetContributionTypeI18n();
const domainData = useMemo(() => {
return getDomainData(dataList, contributionTypeMap);
Expand All @@ -80,12 +78,6 @@ const DomainPersona = ({ maxDomain, dataList, name }) => {
};

return (
// <ClickAwayListener
// onClickAway={() => {
// setActive('');
// popperOpen && togglePopperOpen(() => false);
// }}
// >
<div
onMouseLeave={() => {
setActive('');
Expand All @@ -95,10 +87,6 @@ const DomainPersona = ({ maxDomain, dataList, name }) => {
<div className="flex items-center">
{domainData.map(({ type, color, contribution }) => {
const width = toFixed((contribution / maxDomain) * 100, 2);
const bg = {
backgroundColor: color,
width: `${width}%`,
};
return active === type ? (
<div
key={type}
Expand All @@ -113,9 +101,6 @@ const DomainPersona = ({ maxDomain, dataList, name }) => {
</div>
) : (
<div
// onClick={(e) => {
// handleClick(e, type);
// }}
key={type}
onMouseEnter={(e) => {
handleClick(e, type);
Expand Down Expand Up @@ -150,7 +135,6 @@ const DomainPersona = ({ maxDomain, dataList, name }) => {
/>
</Popper>
</div>
// </ClickAwayListener
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import {
useContributionTypeLsit,
useEcologicalType,
useMileageOptions,
} from './contribution';
import { getMaxDomain } from './utils';
} from '../contribution';
import { getMaxDomain } from '../utils';
import { getContributorPolling, getContributorExport } from './tableDownload';
import DomainPersona from './DomainPersona';
import ContributorName from './ContributorName';
import { useTranslation } from 'next-i18next';
import Download from '@common/components/Table/Download';
import { getContributorPolling, getContributorExport } from '../tableDownload';
import { useRouter } from 'next/router';
import { useHandleQueryParams } from '@modules/analyze/hooks/useHandleQueryParams';
import Dialog from '@common/components/Dialog';
Expand Down Expand Up @@ -48,6 +49,8 @@ const MetricTable: React.FC<{
const [openConfirm, setOpenConfirm] = useState(false);
const [currentName, setCurrentName] = useState('');
const [currentOrgName, setCurrentOrgName] = useState('');
const [origin, setOrigin] = useState('');

const { data } = useVerifyDetailRange();
const { isCurrentUser } = useIsCurrentUser();
const ecologicalOptions = useEcologicalType();
Expand Down Expand Up @@ -132,6 +135,7 @@ const MetricTable: React.FC<{
},
});
setData(items);
setOrigin(data.contributorsDetailList.origin);
},
}
);
Expand Down Expand Up @@ -188,6 +192,9 @@ const MetricTable: React.FC<{
width: '200px',
sorter: true,
fixed: 'left',
render: (name) => {
return <ContributorName name={name} origin={origin} />;
},
},
{
title: t('analyze:metric_detail:role_persona'),
Expand Down Expand Up @@ -229,7 +236,6 @@ const MetricTable: React.FC<{
defaultFilterOpts.find((i) => i.type === 'contribution_type')?.values ||
null,
filterMode: 'tree',
// ellipsis: { showTitle: true },
align: 'left',
width: '300px',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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',
},
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import {
PullDetailOverview,
} from '@oss-compass/graphql';
import client from '@common/gqlClient';
import { AiFillGithub } from 'react-icons/ai';
import { SiGitee } from 'react-icons/si';
import { SiGitee, SiGithub } from 'react-icons/si';
import { toFixed } from '@common/utils';
import { useRouter } from 'next/router';
import Image from 'next/image';

const MetricDashboard = () => {
const { compareItems } = useCompareItems();
Expand Down Expand Up @@ -121,7 +121,10 @@ const MetricBoxContributors: React.FC<{
<div>
<div className="flex text-xl font-medium">
<div className="mt-1 mr-2 text-[#ccc]">
<IoPersonCircle />
{getUserIcons(
data.highestContributionContributor.origin,
data.highestContributionContributor.name
)}
</div>
<div className="line-clamp-1">
{data.highestContributionContributor.name || '/'}
Expand Down Expand Up @@ -318,12 +321,51 @@ const Loading = () => (
const getIcons = (type: string) => {
switch (type) {
case 'github':
return <AiFillGithub className="mr-2" />;
return <SiGithub color="#171516" />;
case 'gitee':
return <SiGitee color="#c71c27" className="mr-0" />;
default:
return <IoPeopleCircle />;
}
};

const getUserIcons = (type, name) => {
switch (type) {
case 'github':
return (
<div className="relative h-[22px] w-[22px] overflow-hidden rounded-full border border-gray-100 p-0">
<Image
src={'https://github.com/' + name + '.png'}
onError={(e) => (e.currentTarget.src = '/images/github.png')}
unoptimized
fill={true}
style={{
objectFit: 'cover',
}}
alt="icon"
placeholder="blur"
blurDataURL="/images/github.png"
/>
</div>
);
case 'gitee':
return (
<div className="relative h-[22px] w-[22px] overflow-hidden rounded-full border border-gray-100">
<Image
src={'https://gitee.com/' + name + '.png'}
onError={(e) =>
(e.currentTarget.src = '/images/logos/gitee-red.svg')
}
unoptimized
fill={true}
alt="icon"
placeholder="blur"
blurDataURL="/images/logos/gitee-red.svg"
/>
</div>
);
// return <SiGitee color="#c71c27" className="mr-0" />;
default:
return <IoPersonCircle />;
}
};
export default MetricDashboard;
5 changes: 2 additions & 3 deletions apps/web/src/modules/analyze/components/NavBar/LabelItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ const CommunityItem = ({ label, name }) => {
const { data } = useCommunityReposQuery(client, {
label,
});
const communityOrgUrl =
data?.communityOverview?.communityOrgUrl || 'https://gitee.com/mindspore';
console.log(communityOrgUrl);
const communityOrgUrl = data?.communityOverview?.communityOrgUrl || '';

return communityOrgUrl ? (
<a
className="ml-1 mr-1 whitespace-nowrap font-semibold hover:underline"
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/modules/home/LatestNews/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const eventList = [
key: '2023-08-23',
},
{
titleCn: 'OSS Compass社区2023年会及晚宴',
titleCn: 'OSS Compass 社区 2023 年会及晚宴',
titleEn: 'OSS Compass Community 2023 Annual Meeting and Dinner',
time: '13:00 - 18:00 (UTC+8)',
key: '2023-12-13',
Expand All @@ -37,7 +37,7 @@ const DatePicker = () => {

const bookedDays = [
(date) => {
return date.getDay() === 2 || date.getDay() === 4;
return date.getDay() === 2; //每周二社区例会
},
new Date(2023, 7, 23),
new Date(2023, 11, 13),
Expand All @@ -60,7 +60,7 @@ const DatePicker = () => {
};
const selectEvent = eventList.filter(({ key }, index) => {
if (index === 0) {
return selected?.getDay() === 2 || selected?.getDay() === 4;
return selected?.getDay() === 2;
} else {
return selected && format(selected, 'yyyy-MM-dd') === key;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/graphql/src/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@ export type ContributorDetailPage = {
__typename?: 'ContributorDetailPage';
count?: Maybe<Scalars['Int']>;
items: Array<ContributorDetail>;
/** contributors origin */
origin: Scalars['String'];
page?: Maybe<Scalars['Int']>;
totalPage?: Maybe<Scalars['Int']>;
};
Expand Down Expand Up @@ -4582,6 +4584,7 @@ export type ContributorsDetailListQuery = {
contributorsDetailList: {
__typename?: 'ContributorDetailPage';
count?: number | null;
origin: string;
page?: number | null;
totalPage?: number | null;
items: Array<{
Expand Down Expand Up @@ -8369,6 +8372,7 @@ export const ContributorsDetailListDocument = /*#__PURE__*/ `
mileageType
organization
}
origin
page
totalPage
}
Expand Down
1 change: 1 addition & 0 deletions packages/graphql/src/gql/query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ query contributorsDetailList(
mileageType
organization
}
origin
page
totalPage
}
Expand Down

0 comments on commit 0b7f788

Please sign in to comment.