UNPKG

@roadiehq/backstage-plugin-github-insights

Version:
98 lines (95 loc) 2.85 kB
import { jsx } from 'react/jsx-runtime'; import { useProjectEntity } from '../../../hooks/useProjectEntity.esm.js'; import { useEntity } from '@backstage/plugin-catalog-react'; import '../ContributorsCard/ContributorsCard.esm.js'; import '../LanguagesCard/LanguagesCard.esm.js'; import MarkdownContent from '../MarkdownContent/MarkdownContent.esm.js'; import { makeStyles } from '@material-ui/core'; import '@material-ui/icons/LocalOfferOutlined'; import '@material-ui/lab/Alert'; import { InfoCard } from '@backstage/core-components'; import 'react-use'; import '@octokit/rest'; import '@backstage/core-plugin-api'; import { useEntityGithubScmIntegration } from '../../../hooks/useEntityGithubScmIntegration.esm.js'; import '../../store.esm.js'; import '@backstage/integration-react'; import '../../utils/styles.esm.js'; import '@backstage/catalog-model'; import 'git-url-parse'; import '@roadiehq/github-auth-utils-react'; import '@material-ui/icons/ErrorOutline'; import '@material-ui/lab'; const useStyles = makeStyles((theme) => ({ infoCard: { marginBottom: "10px", "& + .MuiAlert-root": { marginTop: theme.spacing(3) }, "& .MuiCardContent-root": { padding: theme.spacing(2, 1, 2, 2) } }, readMe: { overflowY: "auto", paddingRight: theme.spacing(1), "&::-webkit-scrollbar-track": { backgroundColor: "#F5F5F5", borderRadius: "5px" }, "&::-webkit-scrollbar": { width: "5px", backgroundColor: "#F5F5F5", borderRadius: "5px" }, "&::-webkit-scrollbar-thumb": { border: "1px solid #555555", backgroundColor: "#555", borderRadius: "4px" } } })); const ReadMeCard = (props) => { const { entity } = useEntity(); const { owner, repo, readmePath } = useProjectEntity(entity); const { hostname } = useEntityGithubScmIntegration(entity); const classes = useStyles(); const linkPath = readmePath || "README.md"; return /* @__PURE__ */ jsx( InfoCard, { title: props.title || "Readme", className: classes.infoCard, deepLink: { link: `https://${hostname}/${owner}/${repo}/blob/HEAD/${linkPath}`, title: "Readme", onClick: (e) => { e.preventDefault(); window.open( `https://${hostname}/${owner}/${repo}/blob/HEAD/${linkPath}` ); } }, children: /* @__PURE__ */ jsx( "div", { className: classes.readMe, style: { maxHeight: `${props.maxHeight}px` }, children: /* @__PURE__ */ jsx( MarkdownContent, { hostname, owner, repo, path: readmePath } ) } ) } ); }; export { ReadMeCard as default }; //# sourceMappingURL=ReadMeCard.esm.js.map