Skip to content

Commit

Permalink
Merge pull request #1690 from florinnania/not-trigger-LoginRequired-f…
Browse files Browse the repository at this point in the history
…or-ContributorsCard-in-EntityPage

Fix for #1665 to not trigger login required for contributors card in entity page
  • Loading branch information
Xantier authored Oct 23, 2024
2 parents 5e556b3 + 0d9c26c commit 85c687f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-ads-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@roadiehq/backstage-plugin-github-insights': patch
---

Fix to not trigger LoginRequired screen for ContributorsCard in EntityPage
4 changes: 4 additions & 0 deletions packages/app/src/components/catalog/EntityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
} from '@roadiehq/backstage-plugin-aws-lambda';
import {
EntityGithubInsightsContent,
EntityGithubInsightsContributorsCard,
EntityGithubInsightsLanguagesCard,
EntityGithubInsightsReadmeCard,
EntityGithubInsightsReleasesCard,
Expand Down Expand Up @@ -239,6 +240,9 @@ const overviewContent = (
</EntitySwitch>
<EntitySwitch>
<EntitySwitch.Case if={e => Boolean(isGithubInsightsAvailable(e))}>
<Grid item md={3}>
<EntityGithubInsightsContributorsCard />
</Grid>
<Grid item md={6}>
<EntityGithubInsightsLanguagesCard />
<EntityGithubInsightsReleasesCard />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,19 @@ const useStyles = makeStyles(theme => ({
},
}));

const ContributorsCard = () => {
const ContributorsCardContent = () => {
const { entity } = useEntity();
const classes = useStyles();
const { value, loading, error } = useRequest(entity, 'contributors', 10);
const { hostname } = useEntityGithubScmIntegration(entity);
const projectAlert = isGithubInsightsAvailable(entity);
const { owner, repo } = useProjectEntity(entity);
const isLoggedIn = useGithubLoggedIn();
if (!projectAlert) {
return (
<MissingAnnotationEmptyState annotation={GITHUB_INSIGHTS_ANNOTATION} />
);
}

if (!isLoggedIn) {
return (
<InfoCard title="Contributors" className={classes.infoCard}>
<GithubNotAuthorized />
</InfoCard>
);
}

if (loading) {
return <Progress />;
} else if (error) {
Expand Down Expand Up @@ -97,4 +88,17 @@ const ContributorsCard = () => {
);
};

const ContributorsCard = () => {
const classes = useStyles();
const isLoggedIn = useGithubLoggedIn();

return isLoggedIn ? (
<ContributorsCardContent />
) : (
<InfoCard title="Contributors" className={classes.infoCard}>
<GithubNotAuthorized />
</InfoCard>
);
};

export default ContributorsCard;

0 comments on commit 85c687f

Please sign in to comment.