UNPKG

@azure-utils/storybooks

Version:

Utils to upload and manage Storybooks via Azure Functions and storage.

161 lines (158 loc) 4.97 kB
const require_chunk = require('./chunk-DWy1uDak.cjs'); const require_store = require('./store-CYxr095K.cjs'); const require_table = require('./table-CnB0C2aQ.cjs'); //#region src/components/raw-data.tsx var import_jsx_runtime$1 = require_chunk.__toESM(require_store.require_jsx_runtime()); function RawDataPreview({ data, open, summary }) { if (summary) return /* @__PURE__ */ (0, import_jsx_runtime$1.jsxs)("details", { open, children: [/* @__PURE__ */ (0, import_jsx_runtime$1.jsx)("summary", { children: summary }), /* @__PURE__ */ (0, import_jsx_runtime$1.jsx)("pre", { safe: true, class: "raw-data", children: JSON.stringify(data, null, 2) })] }); return /* @__PURE__ */ (0, import_jsx_runtime$1.jsx)("pre", { safe: true, class: "raw-data", children: JSON.stringify(data, null, 2) }); } //#endregion //#region src/components/builds-table.tsx var import_jsx_runtime = require_chunk.__toESM(require_store.require_jsx_runtime()); async function BuildTable({ caption, toolbar, builds, project, labels }) { const { locale } = require_store.getStore(); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(require_table.Table, { caption: caption ?? `Builds (${builds.length})`, toolbar, data: builds, columns: [ { id: "sha", header: "SHA", cell: (item) => { const labelSlug = item.label.split(",").at(0) || item.label; return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { safe: true, href: require_store.urlBuilder.buildSHA(project.id, item.sha, labelSlug), children: item.sha.slice(0, 7) }); } }, labels ? { id: "label", header: "Labels", cell: (item) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: item.label.split(",").map((labelSlug, index, arr) => { const label = labels.find((label$1) => label$1.slug === labelSlug); return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { safe: true, href: require_store.urlBuilder.labelSlug(project.id, labelSlug), title: labelSlug, children: label ? `${label.value} (${label.type})` : labelSlug }), index === arr.length - 1 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: ", " })] }); }) }); } } : void 0, { id: "storybook", header: "Storybook", cell: (item) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", gap: "1rem" }, children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: require_store.urlBuilder.storybookIndexHtml(project.id, item.sha), target: "_blank", children: "View" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: require_store.urlBuilder.storybookZip(project.id, item.sha), target: "_blank", download: `storybook-${project.id}-${item.sha}.zip`, children: "Download" })] }); } }, { id: "test", header: "Tests", cell: (item) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", gap: "1rem" }, children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: require_store.urlBuilder.storybookTestReport(project.id, item.sha), target: "_blank", children: "Test Report" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: require_store.urlBuilder.storybookCoverage(project.id, item.sha), target: "_blank", children: "Coverage" })] }); } }, { id: "gitHub", header: "GitHub", cell: (item) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "flex", gap: "1rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: require_store.urlBuilder.gitHub(project.gitHubRepo, "commit", item.sha), target: "_blank", children: "Commit" }) }); } }, { id: "message", header: "Message" }, { id: "authorName", header: "Author", cell: (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { safe: true, title: item.authorEmail, children: item.authorName || "Unknown" }) }, { id: "timestamp", header: "Last modified", cell: (item) => { if (!item.timestamp) return null; return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("time", { datetime: item.timestamp, safe: true, children: new Date(item.timestamp).toLocaleString(locale) }); } } ] }); } //#endregion Object.defineProperty(exports, 'BuildTable', { enumerable: true, get: function () { return BuildTable; } }); Object.defineProperty(exports, 'RawDataPreview', { enumerable: true, get: function () { return RawDataPreview; } });