-
Notifications
You must be signed in to change notification settings - Fork 40
refactor: extract ThankYouNote component from index page #509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hassaansaleem28
wants to merge
15
commits into
jenkins-infra:main
Choose a base branch
from
hassaansaleem28:refactor/section-community-stats-507
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+171
−159
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
80124ef
refactor: extract CommunityStats component
hassaansaleem28 fc1da1a
Merge branch 'main' into refactor/section-community-stats-507
hassaansaleem28 4de6f22
Merge branch 'main' into refactor/section-community-stats-507
hassaansaleem28 accbb99
fix: imports
hassaansaleem28 fd84eed
change file name
hassaansaleem28 e15ad64
fix import name
hassaansaleem28 70e817b
Merge branch 'main' into refactor/section-community-stats-507
hassaansaleem28 972276f
fix:change component name
hassaansaleem28 41d79da
Merge branch 'refactor/section-community-stats-507' of https://github…
hassaansaleem28 7414f3c
Merge branch 'main' into refactor/section-community-stats-507
hassaansaleem28 c369506
Update src/Components/ThankYouNote.jsx
krisstern 50a848d
chore: trigger CI / address review
hassaansaleem28 106fcd7
chore: trigger CI / address review
hassaansaleem28 5917c40
empty commit
hassaansaleem28 6ffb980
Merge branch 'refactor/section-community-stats-507' of https://github…
hassaansaleem28 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| import { Box, Stack, useTheme } from '@mui/material'; | ||
| import React, { useEffect, useState } from 'react'; | ||
| import useMediaQuery from '@mui/material/useMediaQuery'; | ||
| import axios from 'axios'; | ||
| import Papa from 'papaparse'; | ||
| import dayjs from 'dayjs'; | ||
|
|
||
| const ThankYouNote = ({ darkmode }) => { | ||
| const theme = useTheme(); | ||
| const isDesktop = useMediaQuery(theme.breakpoints.up('lg')); | ||
| const isMobile = useMediaQuery(theme.breakpoints.down('sm')); | ||
| const [thankYou, setThankYou] = useState([]); | ||
|
|
||
| useEffect(() => { | ||
| axios | ||
| .get( | ||
| 'https://raw.githubusercontent.com/jenkins-infra/jenkins-contribution-stats/main/data/honored_contributor.csv', | ||
| { responseType: 'text' } | ||
| ) | ||
| .then((response) => { | ||
| setThankYou(Papa.parse(response.data)?.data[1]); | ||
| }); | ||
|
|
||
| const interval = setInterval(() => { | ||
| axios | ||
| .get( | ||
| 'https://raw.githubusercontent.com/jenkins-infra/jenkins-contribution-stats/main/data/honored_contributor.csv', | ||
| { responseType: 'text' } | ||
| ) | ||
| .then((response) => { | ||
| setThankYou(Papa.parse(response.data)?.data[1]); | ||
| }); | ||
| }, 3600000); | ||
|
|
||
| return () => clearInterval(interval); | ||
| }, []); | ||
|
|
||
| if (!thankYou || thankYou.length === 0) return null; | ||
|
|
||
| return ( | ||
| <Box | ||
| sx={{ | ||
| padding: theme.spacing(5, 0), | ||
| display: 'flex', | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| backgroundColor: darkmode ? '#333333' : '#ffffff', | ||
| color: darkmode ? 'white' : 'black', | ||
| }} | ||
| > | ||
| <Box | ||
| sx={{ | ||
| padding: isMobile ? theme.spacing(2) : theme.spacing(3), | ||
| borderRadius: 5, | ||
| maxWidth: 'fit-content', | ||
| height: 'fit-content', | ||
| backgroundColor: 'rgb(218, 209, 198, 0.3)', | ||
| display: 'flex', | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| border: darkmode ? '1px solid white' : '1px solid black', | ||
| }} | ||
| > | ||
| <Stack | ||
| direction='row' | ||
| gap={isMobile ? 1 : 3} | ||
| justifyItems='center' | ||
| alignItems='center' | ||
| > | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| }} | ||
| > | ||
| <img | ||
| src={thankYou[6]?.replace(/['"]+/g, '')} | ||
| alt='Random contributor' | ||
| width={isDesktop ? 100 : isMobile ? 36 : 90} | ||
| height={isDesktop ? 100 : isMobile ? '100%' : 90} | ||
| style={{ | ||
| marginTop: 'auto', | ||
| marginBottom: 'auto', | ||
| }} | ||
| /> | ||
| </Box> | ||
| <Box | ||
| sx={{ | ||
| fontSize: isMobile ? 'small' : 'medium', | ||
| }} | ||
| > | ||
| Thank you{' '} | ||
| {thankYou?.filter((item) => item?.trim() === '') | ||
| .length === 0 && ( | ||
| <a | ||
| target='_blank' | ||
| rel='noreferrer' | ||
| href={thankYou[5]?.replace(/['"]+/g, '')} | ||
| > | ||
| {thankYou[3]?.replace(/['"]+/g, '').trim() | ||
| ? thankYou[3]?.replace(/['"]+/g, '') | ||
| : thankYou[2]?.replace(/['"]+/g, '')} | ||
| </a> | ||
| )} | ||
| <br /> | ||
| for making {thankYou[7]?.replace( | ||
| /['"]+/g, | ||
| '' | ||
| )} pull{' '} | ||
| {parseInt(thankYou[7]?.replace(/['"]+/g, '')) >= 2 | ||
| ? 'requests' | ||
| : 'request'} | ||
| <br /> | ||
| to{' '} | ||
| {thankYou[8]?.split(' ')?.length >= 4 | ||
| ? parseInt(thankYou[8]?.split(' ')?.length) + | ||
| ' Jenkins ' | ||
| : 'the '} | ||
| {thankYou[8]?.split(' ').length < 4 && | ||
| thankYou[8] | ||
| ?.replace(/['"]+/g, '') | ||
| .split(/\s+/) | ||
| .filter(Boolean) | ||
| .map((repo, idx) => ( | ||
| <> | ||
| {thankYou[8]?.split(' ').length > 2 && | ||
| idx === | ||
| thankYou[8]?.split(' ').length - | ||
| 2 && | ||
| 'and '} | ||
| <a | ||
| target='_blank' | ||
| rel='noreferrer' | ||
| href={`https://github.com/${repo}`} | ||
| > | ||
| {repo?.split('/')[1]} | ||
| </a> | ||
| {thankYou[8]?.split(' ').length >= 2 && | ||
| idx < | ||
| thankYou[8]?.split(' ').length - | ||
| 2 ? ( | ||
| <> | ||
| , | ||
| <br /> | ||
| </> | ||
| ) : ( | ||
| ' ' | ||
| )} | ||
| </> | ||
| ))}{' '} | ||
| {thankYou[8]?.split(' ').length > 2 | ||
| ? 'repos' | ||
| : 'repo'}{' '} | ||
| in{' '} | ||
| {dayjs( | ||
| thankYou[1]?.replace(/['"]+/g, '').trim() | ||
| ).format('MMMM YYYY')} | ||
| ! | ||
| </Box> | ||
| </Stack> | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export default ThankYouNote; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.