UNPKG

@roadiehq/backstage-plugin-jira

Version:
50 lines (47 loc) 1.59 kB
import { useApi, identityApiRef } from '@backstage/core-plugin-api'; import { jiraApiRef } from '../../api/index.esm.js'; import { useTemplateParser } from '../../hooks/useTemplateParser.esm.js'; import { useAsync } from 'react-use'; import { WarningPanel, ErrorPanel } from '@backstage/core-components'; import { LinearProgress } from '@material-ui/core'; import { IssuesTable } from '../IssuesTable/IssuesTable.esm.js'; import React from 'react'; const JiraQueryCard = ({ jqlQuery, maxResults, hideOnMissingAnnotation = false, ...tableProps }) => { const api = useApi(jiraApiRef); const identityApi = useApi(identityApiRef); const templateParser = useTemplateParser(); const { value: issues, loading, error } = useAsync(async () => { if (jqlQuery) { const profile = await identityApi.getProfileInfo(); return await api.jqlQuery( templateParser(jqlQuery, { userEmail: profile.email ?? "", userDisplayName: profile.displayName ?? "" }), maxResults ); } return void 0; }, [jqlQuery, api]); if (jqlQuery === "") { return /* @__PURE__ */ React.createElement(WarningPanel, { message: "jqlQuery prop cannot be empty" }); } if (loading) { return /* @__PURE__ */ React.createElement(LinearProgress, null); } if (error) { return /* @__PURE__ */ React.createElement(ErrorPanel, { error }); } return /* @__PURE__ */ React.createElement(IssuesTable, { issues: issues ?? [], ...tableProps }); }; export { JiraQueryCard }; //# sourceMappingURL=JiraQueryCard.esm.js.map