Skip to content
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

Display all Tools #726

Merged
merged 11 commits into from
Jul 3, 2024
26 changes: 14 additions & 12 deletions apps/charterafrica/src/components/Tool/DescriptionAndShare.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ const DescriptionAndShare = React.forwardRef(
>
{description}
</RichTypography>
<RichTypography
textAlign="left"
color="neutral.dark"
sx={{
mt: 3.75,
textTransform: "none",
textAlign: { xs: "center", sm: "left" },
}}
variant="captionCap"
>
{activeText} {lastActive}
</RichTypography>
{lastActive ? (
<RichTypography
textAlign="left"
color="neutral.dark"
sx={{
mt: 3.75,
textTransform: "none",
textAlign: { xs: "center", sm: "left" },
}}
variant="captionCap"
>
{activeText} {lastActive}
koechkevin marked this conversation as resolved.
Show resolved Hide resolved
</RichTypography>
) : null}
<Box
display="flex"
sx={{
Expand Down
7 changes: 5 additions & 2 deletions apps/charterafrica/src/components/Tool/Metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ import ViewsIcon from "@/charterafrica/assets/icons/Type=views, Size=24, Color=C
const Metrics = React.forwardRef(function Metrics(props, ref) {
const {
sx,
stars = "0",
stars,
starsText,
commitText,
forksText,
contributorsText,
lastCommit,
forks = "0",
forks,
contributors,
} = props;
if (!contributors?.length && !stars && !forks && !lastCommit.committedDate) {
return null;
}
return (
<Box display="flex" sx={sx} ref={ref} flexWrap="wrap" alignItems="center">
<Box display="flex" alignItems="center" sx={{ mb: 2, mr: 2 }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const OrgThemeAndOperatingCountries = React.forwardRef(
function OrgThemeAndOperatingCountries(props, ref) {
const { sx, organisation, theme, operatingCountries } = props;
const countries = operatingCountries?.join(", ");
if (!organisation) {
if (!organisation && !theme) {
return null;
}
return (
Expand All @@ -25,8 +25,8 @@ const OrgThemeAndOperatingCountries = React.forwardRef(
>
<Figure
ImageProps={{
alt: organisation.name,
src: organisation.avatarUrl,
alt: organisation?.name,
src: organisation?.avatarUrl,
}}
sx={{
height: 50,
Expand All @@ -51,7 +51,7 @@ const OrgThemeAndOperatingCountries = React.forwardRef(
sx={{ textDecoration: "none", fontWeight: 400 }}
variant="h4"
>
{organisation.name}
{organisation?.name}
</Link>
</Box>
<Box
Expand Down
64 changes: 34 additions & 30 deletions apps/charterafrica/src/components/Tool/Tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,44 +121,48 @@ const Tool = React.forwardRef(function Tool(props, ref) {
ml: "auto",
}}
>
<Button
component={goToRepo?.href ? Link : undefined}
href={goToRepo?.href}
variant="contained"
target="_blank"
sx={{
mt: 1.25,
width: "100%",
height: 50,
}}
>
<SvgIcon
component={GithubIcon}
{goToRepo?.href ? (
<Button
component={Link}
href={goToRepo?.href}
variant="contained"
target="_blank"
sx={{
color: "text.secondary",
display: "inline-flex",
fill: "none",
width: 16,
height: 16,
mr: 1,
mt: 1.25,
width: "100%",
height: 50,
}}
/>
{goToRepo?.label}
</Button>
>
<SvgIcon
component={GithubIcon}
sx={{
color: "text.secondary",
display: "inline-flex",
fill: "none",
width: 16,
height: 16,
mr: 1,
}}
/>
{goToRepo?.label}
</Button>
) : null}
</Box>
<TechSkills
list={techSkills}
title="Skills Needed"
sx={{ mt: 3.75 }}
/>
<Box sx={{ mt: 3.75 }}>
<RichTypography variant="p3SemiBold" color="neutral.dark">
{collectionText}
</RichTypography>
<RichTypography sx={{ mt: 1 }} variant="p3">
{classification}
</RichTypography>
</Box>
{classification ? (
<Box sx={{ mt: 3.75 }}>
<RichTypography variant="p3SemiBold" color="neutral.dark">
{collectionText}
</RichTypography>
<RichTypography sx={{ mt: 1 }} variant="p3">
{classification}
</RichTypography>
</Box>
) : null}
<Contributors
sx={{ mt: 3.75 }}
list={contributors}
Expand Down
35 changes: 2 additions & 33 deletions apps/charterafrica/src/components/Tool/Tool.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,7 @@ exports[`<Tool /> renders unchanged 1`] = `
/>
<div
class="MuiBox-root css-1isemmb"
>
<div
class="MuiTypography-root MuiTypography-p1 css-1tpbw3s-MuiTypography-root"
>
0
</div>
</div>
/>
</div>
<div
class="MuiBox-root css-33u6ly"
Expand All @@ -106,13 +100,7 @@ exports[`<Tool /> renders unchanged 1`] = `
/>
<div
class="MuiBox-root css-1isemmb"
>
<div
class="MuiTypography-root MuiTypography-p1 css-1tpbw3s-MuiTypography-root"
>
0
</div>
</div>
/>
</div>
</div>
<div
Expand Down Expand Up @@ -190,25 +178,6 @@ exports[`<Tool /> renders unchanged 1`] = `
>
<div
class="MuiBox-root css-11uk14q"
>
<button
class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-qy1l2s-MuiButtonBase-root-MuiButton-root"
href=""
tabindex="0"
target="_blank"
type="button"
>
<div
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-1bnrqzj-MuiSvgIcon-root"
focusable="false"
viewbox="0 0 24 24"
/>
Go to Repo
</button>
</div>
<div
class="MuiBox-root css-46b038"
/>
<div
class="MuiBox-root css-46b038"
Expand Down
5 changes: 3 additions & 2 deletions apps/charterafrica/src/lib/ecosystem/airtable/processData.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ export function processTool(item, config, { partnersData }) {
} = config;
const data = { ...item.fields, id: item.id };
const externalId = getValue(data, toolTableColumns.slug)?.trim();
if (!externalId?.length) {
const message = `Missing externalId for Tool ${data.id}. Skipping`;
const toolName = getValue(data, toolTableColumns.name)?.trim();
if (!toolName) {
const message = `Missing name for Tool ${data.id}. Skipping`;
Sentry.captureMessage(message);
return null;
}
Expand Down
3 changes: 3 additions & 0 deletions apps/charterafrica/src/lib/ecosystem/github/processData.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ function fetchUserQuery(username) {
}

export async function fetchTool({ externalId }) {
if (!externalId) {
return null;
}
let [repositoryOwner, repositoryName] = externalId
.replace(/^https?:\/\/github\.com\//, "")
.replace(/\/$/, "")
Expand Down
Loading