UNPKG

@red-hat-developer-hub/backstage-plugin-bulk-import

Version:
83 lines (80 loc) 3.17 kB
import { jsx, jsxs, Fragment } from 'react/jsx-runtime'; import { Link } from '@backstage/core-components'; import OpenInNewIcon from '@mui/icons-material/OpenInNew'; import Alert from '@mui/material/Alert'; import AlertTitle from '@mui/material/AlertTitle'; import Box from '@mui/material/Box'; import { useFormikContext } from 'formik'; import { RepositoryStatus } from '../../types/types.esm.js'; import { getCustomisedErrorMessage } from '../../utils/repository-utils.esm.js'; import { PreviewPullRequestForm } from './PreviewPullRequestForm.esm.js'; const PreviewPullRequest = ({ repoId, repoUrl, pullRequest, setPullRequest, formErrors, setFormErrors, others }) => { const { status } = useFormikContext(); const error = status?.errors?.[repoId]; const info = status?.infos?.[repoId]; if (info?.error?.message.includes( RepositoryStatus.CATALOG_INFO_FILE_EXISTS_IN_REPO ) && !error) { return /* @__PURE__ */ jsx(Box, { marginTop: others?.addPaddingTop ? 2 : 0, children: /* @__PURE__ */ jsx(Alert, { severity: "info", children: getCustomisedErrorMessage(info.error.message).message }) }); } return /* @__PURE__ */ jsxs(Fragment, { children: [ error && /* @__PURE__ */ jsxs(Box, { marginTop: others?.addPaddingTop ? 2 : 0, children: [ /* @__PURE__ */ jsxs(Alert, { severity: "error", children: [ /* @__PURE__ */ jsx(AlertTitle, { children: error.error?.title ? error.error?.title : "Failed to create PR" }), getCustomisedErrorMessage(error.error.message).message, " ", error?.repository?.organization && error?.repository?.name && /* @__PURE__ */ jsxs( Link, { to: `https://github.com/${error.repository.organization}/${error.repository.name}`, children: [ "View repository", /* @__PURE__ */ jsx( OpenInNewIcon, { style: { verticalAlign: "sub", paddingTop: "7px" } } ) ] } ) ] }), !others?.addPaddingTop && /* @__PURE__ */ jsx("br", {}) ] }), info && /* @__PURE__ */ jsxs(Box, { marginTop: others?.addPaddingTop ? 2 : 0, children: [ /* @__PURE__ */ jsxs(Alert, { severity: "info", "data-testid": "other-info", children: [ getCustomisedErrorMessage(info.error.message).message, " " ] }), !others?.addPaddingTop && /* @__PURE__ */ jsx("br", {}) ] }), pullRequest[repoId]?.pullRequestUrl && /* @__PURE__ */ jsx(Box, { marginTop: others?.addPaddingTop ? 2 : 0, children: /* @__PURE__ */ jsxs(Alert, { severity: "info", "data-testid": "pull-request-info", children: [ "The", " ", /* @__PURE__ */ jsx(Link, { to: pullRequest[repoId].pullRequestUrl || "", children: "pull request" }), " ", "is pending approval" ] }) }), /* @__PURE__ */ jsx( PreviewPullRequestForm, { repoId, repoUrl, pullRequest, setPullRequest, formErrors, setFormErrors } ) ] }); }; export { PreviewPullRequest }; //# sourceMappingURL=PreviewPullRequest.esm.js.map