UNPKG

@spacelift-io/backstage-integration-frontend

Version:

Backstage plugin for integrating Spacelift.io with Backstage

50 lines (47 loc) 2.13 kB
import { jsxs, jsx } from 'react/jsx-runtime'; import { Page, Header, HeaderLabel, Content } from '@backstage/core-components'; import { Box, Button } from '@material-ui/core'; import { Alert } from '@material-ui/lab'; import { useFetchStacks } from '../../hooks/useFetchStacks.esm.js'; import { useTriggerRun } from '../../hooks/useTriggerRun.esm.js'; import { SpaceliftStacksTable } from '../SpaceliftStacksTable/SpaceliftStacksTable.esm.js'; const StacksPage = () => { const { stacks, loading: stacksLoading, error: stacksError, retry: getStacks } = useFetchStacks(); const { triggerRun, loading: loadingTriggerRun, error: errorTriggerRun, clear: clearTriggerRunError } = useTriggerRun(); const handleTriggerRun = async (stackId) => { const res = await triggerRun(stackId); if (res?.id) { getStacks(); } }; const isLoading = stacksLoading || loadingTriggerRun; return /* @__PURE__ */ jsxs(Page, { themeId: "tool", children: [ /* @__PURE__ */ jsx(Header, { title: "Spacelift", subtitle: "Manage your stacks", children: /* @__PURE__ */ jsx(HeaderLabel, { label: "Stacks", value: "List of stacks" }) }), /* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", style: { gap: "16px" }, children: [ stacksError && /* @__PURE__ */ jsxs( Alert, { variant: "outlined", severity: "error", action: /* @__PURE__ */ jsx(Button, { color: "inherit", size: "small", onClick: getStacks, children: "RETRY" }), children: [ "Failed to load Spacelift stacks: ", stacksError.message ] } ), !stacksError && errorTriggerRun && /* @__PURE__ */ jsxs(Alert, { variant: "outlined", severity: "warning", onClose: clearTriggerRunError, children: [ "Spacelift action failed: ", errorTriggerRun.message ] }), /* @__PURE__ */ jsx(SpaceliftStacksTable, { stacks, loading: isLoading, triggerRun: handleTriggerRun }) ] }) }) ] }); }; export { StacksPage }; //# sourceMappingURL=Stacks.esm.js.map