@roadiehq/backstage-plugin-jira
Version:
50 lines (47 loc) • 1.54 kB
JavaScript
import { jsx } from 'react/jsx-runtime';
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';
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__ */ jsx(WarningPanel, { message: "jqlQuery prop cannot be empty" });
}
if (loading) {
return /* @__PURE__ */ jsx(LinearProgress, {});
}
if (error) {
return /* @__PURE__ */ jsx(ErrorPanel, { error });
}
return /* @__PURE__ */ jsx(IssuesTable, { issues: issues ?? [], ...tableProps });
};
export { JiraQueryCard };
//# sourceMappingURL=JiraQueryCard.esm.js.map