Skip to content

Commit a9c4179

Browse files
authored
Merge branch 'main' into update-landing-909
2 parents 0548c65 + 4242af3 commit a9c4179

File tree

4 files changed

+40
-73
lines changed

4 files changed

+40
-73
lines changed

src/components/ContributorThumbnail.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -177,22 +177,6 @@ const Thumbnail = ({
177177
const classes = useStyles();
178178
let thumbnailImageStyle, thumbnailWrapperStyle;
179179

180-
const githubId = organization.github_id;
181-
182-
if (!githubId) {
183-
if (thumbnailInfo.imageUrl && organization.image_url) {
184-
thumbnailInfo.imageUrl = organization.image_url;
185-
}
186-
if (
187-
thumbnailInfo.imageUrl.includes('undefined') ||
188-
thumbnailInfo.imageUrl.includes('scontent')
189-
) {
190-
thumbnailInfo.imageUrl = '/images/default-github-repo-image.png';
191-
}
192-
} else {
193-
thumbnailInfo.imageUrl = `https://avatars1.githubusercontent.com/u/${githubId}?s=100&v=4`;
194-
}
195-
196180
if (organization.cti_contributor) {
197181
thumbnailWrapperStyle = classes.thumbnailWrapperContributor;
198182
} else {

src/components/getOrgId.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/components/getOrganizationLinks.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
/* eslint-disable no-console */
22

3-
import { getOrgId } from "./getOrgId.js";
4-
53
const getGithubInfo = (organization) => {
6-
const githubInfo = { imageUrl: null, organizationUrl: null };
4+
const info = { imageUrl: null, organizationUrl: null };
75
const { links } = organization;
8-
if (links) {
9-
const githubLink = links.find(link => link.link_type === 'GitHub')
6+
if (links && links.length) {
7+
const githubLink = links.find((link) => link.link_type === 'GitHub');
108
if (githubLink) {
11-
const id = getOrgId(githubLink.url);
12-
const imageUrl = `https://avatars1.githubusercontent.com/u/${id}?s=100&v=4`;
13-
githubInfo.imageUrl = imageUrl;
14-
githubInfo.organizationUrl = githubLink.url;
9+
const githubId = organization.github_id;
10+
11+
info.imageUrl = githubId
12+
? `https://avatars1.githubusercontent.com/u/${githubId}?s=100&v=4`
13+
: organization.image_url;
14+
info.organizationUrl = githubLink.url;
1515
}
1616
}
17-
return githubInfo;
18-
}
17+
return info;
18+
};
1919

2020
const getImageFromOrg = (organization) => {
21-
if (organization.image_url) {
21+
if (organization.image_url && !organization.image_url.includes('scontent')) {
2222
return organization.image_url;
2323
} else {
2424
return '/images/default-github-repo-image.png';
2525
}
26-
}
26+
};
2727

2828
const getLinksFromOrg = (organization) => {
2929
if (organization.links && organization.links.length) {
@@ -33,7 +33,7 @@ const getLinksFromOrg = (organization) => {
3333
console.log(`No links available for ${organization.name}`);
3434
return '/images/default-github-repo-image.png';
3535
}
36-
}
36+
};
3737

3838
export const getOrganizationLinks = (organization) => {
3939
const thumbnailInfo = getGithubInfo(organization);

src/pages/IndvOrganization/index.js

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Error404 from '../Error404';
77
import { IndvPageContainer } from './IndvPageContainer';
88
import Box from '@material-ui/core/Box';
99
import '../../styles.css';
10+
import { getOrganizationLinks } from '../../components/getOrganizationLinks.js';
1011

1112
const IndvOrgPage = ({ match }) => {
1213
const [showHeaderResults, setShowHeaderResults] = useState(false);
@@ -22,7 +23,7 @@ const IndvOrgPage = ({ match }) => {
2223
const [notFound, setNotFound] = useState(true);
2324
const [dropdownTitle, setDropdownTitle] = useState('');
2425

25-
const pathName = (match.params.name)?.toLowerCase()?.trim();
26+
const pathName = match.params.name?.toLowerCase()?.trim();
2627

2728
// Reset variables when the path changes.
2829
useEffect(() => {
@@ -35,7 +36,7 @@ const IndvOrgPage = ({ match }) => {
3536
setGithubLink('');
3637
setParentOrgs([]);
3738
setwebsiteUrlResults('');
38-
if (pathName === ""){
39+
if (pathName === '') {
3940
setNotFound(true);
4041
setIsPathChange(false);
4142
}
@@ -54,11 +55,9 @@ const IndvOrgPage = ({ match }) => {
5455
const name = org.name;
5556
const slug = org.slug;
5657
const orgTag = org.org_tag;
57-
const githubId = org.github_id;
5858
const githubName = org.github_name;
5959
const url = org.url;
6060
const modifiedName = name?.replaceAll(' ', '').toLowerCase();
61-
let imageUrl;
6261

6362
// The matching criteria is matching one of these names from matchingNameArr
6463
const matchingNameArr = [
@@ -88,12 +87,7 @@ const IndvOrgPage = ({ match }) => {
8887
(link) => link.link_type === 'GitHub'
8988
)?.url;
9089

91-
if (githubId === null) {
92-
imageUrl = org.image_url;
93-
} else {
94-
imageUrl = `https://avatars1.githubusercontent.com/u/${githubId}?s=100&v=4`;
95-
}
96-
90+
const imageUrl = getOrganizationLinks(org).imageUrl;
9791
// Create the breadcrums on the Individual Organization Page
9892
const parentOrgs = [];
9993
const crumbs = [
@@ -150,24 +144,28 @@ const IndvOrgPage = ({ match }) => {
150144
}
151145
}, [isPathChange, pathName]);
152146

153-
154-
return (
155-
(!notFound) ? (
156-
<Box className='containerGray'>
157-
<Header crumbs={breadCrumbs}
158-
showHeaderResults={showHeaderResults} githubLink={githubLink}
159-
imageUrl={imageUrl} websiteUrlResults={websiteUrlResults} orgName={orgName}
160-
/>
161-
<IndvPageContainer
162-
orgGithubName={orgGithubName}
163-
projectSearchTopicsArr={projectSearchTopicsArr}
164-
largeScreen={projectSearchTopicsArr}
165-
dropdownTitle={dropdownTitle}
166-
parentOrgs={parentOrgs}
167-
pathName={pathName}
168-
/>
169-
</Box>
170-
) : (<Error404 />))
147+
return !notFound ? (
148+
<Box className='containerGray'>
149+
<Header
150+
crumbs={breadCrumbs}
151+
showHeaderResults={showHeaderResults}
152+
githubLink={githubLink}
153+
imageUrl={imageUrl}
154+
websiteUrlResults={websiteUrlResults}
155+
orgName={orgName}
156+
/>
157+
<IndvPageContainer
158+
orgGithubName={orgGithubName}
159+
projectSearchTopicsArr={projectSearchTopicsArr}
160+
largeScreen={projectSearchTopicsArr}
161+
dropdownTitle={dropdownTitle}
162+
parentOrgs={parentOrgs}
163+
pathName={pathName}
164+
/>
165+
</Box>
166+
) : (
167+
<Error404 />
168+
);
171169
};
172170

173171
export default IndvOrgPage;

0 commit comments

Comments
 (0)