@backstage-community/plugin-lighthouse 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/Router.esm.js +12 -4
- package/dist/Router.esm.js.map +1 -1
- package/dist/components/AuditList/AuditListForEntity.esm.js +19 -13
- package/dist/components/AuditList/AuditListForEntity.esm.js.map +1 -1
- package/dist/components/AuditList/AuditListTable.esm.js +10 -5
- package/dist/components/AuditList/AuditListTable.esm.js.map +1 -1
- package/dist/components/AuditList/index.esm.js +50 -35
- package/dist/components/AuditList/index.esm.js.map +1 -1
- package/dist/components/AuditStatusIcon/index.esm.js +4 -4
- package/dist/components/AuditStatusIcon/index.esm.js.map +1 -1
- package/dist/components/AuditView/index.esm.js +63 -46
- package/dist/components/AuditView/index.esm.js.map +1 -1
- package/dist/components/Cards/LastLighthouseAuditCard.esm.js +28 -13
- package/dist/components/Cards/LastLighthouseAuditCard.esm.js.map +1 -1
- package/dist/components/CreateAudit/index.esm.js +83 -64
- package/dist/components/CreateAudit/index.esm.js.map +1 -1
- package/dist/components/Intro/index.esm.js +48 -35
- package/dist/components/Intro/index.esm.js.map +1 -1
- package/dist/components/SupportButton/index.esm.js +2 -2
- package/dist/components/SupportButton/index.esm.js.map +1 -1
- package/dist/index.d.ts +10 -12
- package/package.json +16 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @backstage-community/plugin-lighthouse
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c91184c: Backstage version bump to v1.38.1
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [c91184c]
|
|
12
|
+
- @backstage-community/plugin-lighthouse-common@0.6.0
|
|
13
|
+
|
|
14
|
+
## 0.8.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 4aad9f3: remove unused devDependency `canvas`
|
|
19
|
+
|
|
3
20
|
## 0.8.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/dist/Router.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Routes, Route } from 'react-router-dom';
|
|
3
3
|
import { useEntity, MissingAnnotationEmptyState } from '@backstage/plugin-catalog-react';
|
|
4
4
|
import AuditList from './components/AuditList/index.esm.js';
|
|
@@ -8,18 +8,26 @@ import { LIGHTHOUSE_WEBSITE_URL_ANNOTATION } from './constants.esm.js';
|
|
|
8
8
|
import { AuditListForEntity } from './components/AuditList/AuditListForEntity.esm.js';
|
|
9
9
|
|
|
10
10
|
const isLighthouseAvailable = (entity) => Boolean(entity.metadata.annotations?.[LIGHTHOUSE_WEBSITE_URL_ANNOTATION]);
|
|
11
|
-
const Router = () => /* @__PURE__ */
|
|
11
|
+
const Router = () => /* @__PURE__ */ jsxs(Routes, { children: [
|
|
12
|
+
/* @__PURE__ */ jsx(Route, { path: "/", element: /* @__PURE__ */ jsx(AuditList, {}) }),
|
|
13
|
+
/* @__PURE__ */ jsx(Route, { path: "/audit/:id", element: /* @__PURE__ */ jsx(ConnectedAuditView, {}) }),
|
|
14
|
+
/* @__PURE__ */ jsx(Route, { path: "/create-audit", element: /* @__PURE__ */ jsx(CreateAudit, {}) })
|
|
15
|
+
] });
|
|
12
16
|
const EmbeddedRouter = () => {
|
|
13
17
|
const { entity } = useEntity();
|
|
14
18
|
if (!isLighthouseAvailable(entity)) {
|
|
15
|
-
return /* @__PURE__ */
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
16
20
|
MissingAnnotationEmptyState,
|
|
17
21
|
{
|
|
18
22
|
annotation: LIGHTHOUSE_WEBSITE_URL_ANNOTATION
|
|
19
23
|
}
|
|
20
24
|
);
|
|
21
25
|
}
|
|
22
|
-
return /* @__PURE__ */
|
|
26
|
+
return /* @__PURE__ */ jsxs(Routes, { children: [
|
|
27
|
+
/* @__PURE__ */ jsx(Route, { path: "/", element: /* @__PURE__ */ jsx(AuditListForEntity, {}) }),
|
|
28
|
+
/* @__PURE__ */ jsx(Route, { path: "/audit/:id", element: /* @__PURE__ */ jsx(AuditViewContent, {}) }),
|
|
29
|
+
/* @__PURE__ */ jsx(Route, { path: "/create-audit", element: /* @__PURE__ */ jsx(CreateAuditContent, {}) })
|
|
30
|
+
] });
|
|
23
31
|
};
|
|
24
32
|
|
|
25
33
|
export { EmbeddedRouter, Router, isLighthouseAvailable };
|
package/dist/Router.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.esm.js","sources":["../src/Router.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"Router.esm.js","sources":["../src/Router.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Route, Routes } from 'react-router-dom';\nimport {\n useEntity,\n MissingAnnotationEmptyState,\n} from '@backstage/plugin-catalog-react';\nimport AuditList from './components/AuditList';\nimport AuditView, { AuditViewContent } from './components/AuditView';\nimport CreateAudit, { CreateAuditContent } from './components/CreateAudit';\nimport { Entity } from '@backstage/catalog-model';\nimport { LIGHTHOUSE_WEBSITE_URL_ANNOTATION } from '../constants';\nimport { AuditListForEntity } from './components/AuditList/AuditListForEntity';\n\n/** @public */\nexport const isLighthouseAvailable = (entity: Entity) =>\n Boolean(entity.metadata.annotations?.[LIGHTHOUSE_WEBSITE_URL_ANNOTATION]);\n\n/** @public */\nexport const Router = () => (\n <Routes>\n <Route path=\"/\" element={<AuditList />} />\n <Route path=\"/audit/:id\" element={<AuditView />} />\n <Route path=\"/create-audit\" element={<CreateAudit />} />\n </Routes>\n);\n\n/** @public */\nexport const EmbeddedRouter = () => {\n const { entity } = useEntity();\n\n if (!isLighthouseAvailable(entity)) {\n return (\n <MissingAnnotationEmptyState\n annotation={LIGHTHOUSE_WEBSITE_URL_ANNOTATION}\n />\n );\n }\n\n return (\n <Routes>\n <Route path=\"/\" element={<AuditListForEntity />} />\n <Route path=\"/audit/:id\" element={<AuditViewContent />} />\n <Route path=\"/create-audit\" element={<CreateAuditContent />} />\n </Routes>\n );\n};\n"],"names":["AuditView"],"mappings":";;;;;;;;;AA6Ba,MAAA,qBAAA,GAAwB,CAAC,MACpC,KAAA,OAAA,CAAQ,OAAO,QAAS,CAAA,WAAA,GAAc,iCAAiC,CAAC;AAG7D,MAAA,MAAA,GAAS,sBACpB,IAAA,CAAC,MACC,EAAA,EAAA,QAAA,EAAA;AAAA,kBAAA,GAAA,CAAC,SAAM,IAAK,EAAA,GAAA,EAAI,OAAS,kBAAA,GAAA,CAAC,aAAU,CAAI,EAAA,CAAA;AAAA,sBACvC,KAAM,EAAA,EAAA,IAAA,EAAK,cAAa,OAAS,kBAAA,GAAA,CAACA,sBAAU,CAAI,EAAA,CAAA;AAAA,sBAChD,KAAM,EAAA,EAAA,IAAA,EAAK,iBAAgB,OAAS,kBAAA,GAAA,CAAC,eAAY,CAAI,EAAA;AAAA,CACxD,EAAA;AAIK,MAAM,iBAAiB,MAAM;AAClC,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA;AAE7B,EAAI,IAAA,CAAC,qBAAsB,CAAA,MAAM,CAAG,EAAA;AAClC,IACE,uBAAA,GAAA;AAAA,MAAC,2BAAA;AAAA,MAAA;AAAA,QACC,UAAY,EAAA;AAAA;AAAA,KACd;AAAA;AAIJ,EAAA,4BACG,MACC,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,SAAM,IAAK,EAAA,GAAA,EAAI,OAAS,kBAAA,GAAA,CAAC,sBAAmB,CAAI,EAAA,CAAA;AAAA,wBAChD,KAAM,EAAA,EAAA,IAAA,EAAK,cAAa,OAAS,kBAAA,GAAA,CAAC,oBAAiB,CAAI,EAAA,CAAA;AAAA,wBACvD,KAAM,EAAA,EAAA,IAAA,EAAK,iBAAgB,OAAS,kBAAA,GAAA,CAAC,sBAAmB,CAAI,EAAA;AAAA,GAC/D,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { AuditListTable } from './AuditListTable.esm.js';
|
|
3
3
|
import { useWebsiteForEntity } from '../../hooks/useWebsiteForEntity.esm.js';
|
|
4
4
|
import { LIGHTHOUSE_WEBSITE_URL_ANNOTATION } from '../../constants.esm.js';
|
|
@@ -21,22 +21,28 @@ const AuditListForEntity = () => {
|
|
|
21
21
|
createAuditButtonUrl += `?url=${encodeURIComponent(websiteUrl)}`;
|
|
22
22
|
}
|
|
23
23
|
let content = null;
|
|
24
|
-
content = /* @__PURE__ */
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
content = /* @__PURE__ */ jsxs(Content, { children: [
|
|
25
|
+
/* @__PURE__ */ jsxs(ContentHeader, { title: "Latest Audit", children: [
|
|
26
|
+
/* @__PURE__ */ jsx(
|
|
27
|
+
Button,
|
|
28
|
+
{
|
|
29
|
+
variant: "contained",
|
|
30
|
+
color: "primary",
|
|
31
|
+
onClick: () => navigate(resolvePath(createAuditButtonUrl, fromPath)),
|
|
32
|
+
children: "Create New Audit"
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
/* @__PURE__ */ jsx(LighthouseSupportButton, {})
|
|
36
|
+
] }),
|
|
37
|
+
/* @__PURE__ */ jsx(AuditListTable, { items: value ? [value] : [] })
|
|
38
|
+
] });
|
|
33
39
|
if (loading) {
|
|
34
|
-
content = /* @__PURE__ */
|
|
40
|
+
content = /* @__PURE__ */ jsx(Progress, {});
|
|
35
41
|
}
|
|
36
42
|
if (error && !error.message.includes("no audited website found for url")) {
|
|
37
|
-
content = /* @__PURE__ */
|
|
43
|
+
content = /* @__PURE__ */ jsx(WarningPanel, { severity: "error", title: "Could not load audit list.", children: error.message });
|
|
38
44
|
}
|
|
39
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ jsx(InfoCard, { noPadding: true, children: content });
|
|
40
46
|
};
|
|
41
47
|
|
|
42
48
|
export { AuditListForEntity };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuditListForEntity.esm.js","sources":["../../../src/components/AuditList/AuditListForEntity.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport
|
|
1
|
+
{"version":3,"file":"AuditListForEntity.esm.js","sources":["../../../src/components/AuditList/AuditListForEntity.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ReactNode } from 'react';\nimport { AuditListTable } from './AuditListTable';\nimport { useWebsiteForEntity } from '../../hooks/useWebsiteForEntity';\nimport { LIGHTHOUSE_WEBSITE_URL_ANNOTATION } from '../../../constants';\nimport {\n Content,\n ContentHeader,\n InfoCard,\n Progress,\n WarningPanel,\n} from '@backstage/core-components';\nimport Button from '@material-ui/core/Button';\nimport { resolvePath, useNavigate } from 'react-router-dom';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { rootRouteRef } from '../../plugin';\nimport LighthouseSupportButton from '../SupportButton';\n\nexport const AuditListForEntity = () => {\n const { value, loading, error } = useWebsiteForEntity();\n const { entity } = useEntity();\n const navigate = useNavigate();\n const fromPath = useRouteRef(rootRouteRef)?.() ?? '../';\n\n let createAuditButtonUrl = 'create-audit';\n const websiteUrl =\n entity.metadata.annotations?.[LIGHTHOUSE_WEBSITE_URL_ANNOTATION] ?? '';\n if (websiteUrl) {\n createAuditButtonUrl += `?url=${encodeURIComponent(websiteUrl)}`;\n }\n\n let content: ReactNode = null;\n content = (\n <Content>\n <ContentHeader title=\"Latest Audit\">\n <Button\n variant=\"contained\"\n color=\"primary\"\n onClick={() => navigate(resolvePath(createAuditButtonUrl, fromPath))}\n >\n Create New Audit\n </Button>\n <LighthouseSupportButton />\n </ContentHeader>\n <AuditListTable items={value ? [value] : []} />\n </Content>\n );\n\n if (loading) {\n content = <Progress />;\n }\n if (error && !error.message.includes('no audited website found for url')) {\n // We only want to display this warning panel when its caused by an error other than no audits for the website\n content = (\n <WarningPanel severity=\"error\" title=\"Could not load audit list.\">\n {error.message}\n </WarningPanel>\n );\n }\n\n return <InfoCard noPadding>{content}</InfoCard>;\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAiCO,MAAM,qBAAqB,MAAM;AACtC,EAAA,MAAM,EAAE,KAAA,EAAO,OAAS,EAAA,KAAA,KAAU,mBAAoB,EAAA;AACtD,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA;AAC7B,EAAA,MAAM,WAAW,WAAY,EAAA;AAC7B,EAAA,MAAM,QAAW,GAAA,WAAA,CAAY,YAAY,CAAA,IAAS,IAAA,KAAA;AAElD,EAAA,IAAI,oBAAuB,GAAA,cAAA;AAC3B,EAAA,MAAM,UACJ,GAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,iCAAiC,CAAK,IAAA,EAAA;AACtE,EAAA,IAAI,UAAY,EAAA;AACd,IAAwB,oBAAA,IAAA,CAAA,KAAA,EAAQ,kBAAmB,CAAA,UAAU,CAAC,CAAA,CAAA;AAAA;AAGhE,EAAA,IAAI,OAAqB,GAAA,IAAA;AACzB,EAAA,OAAA,wBACG,OACC,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAC,IAAA,CAAA,aAAA,EAAA,EAAc,OAAM,cACnB,EAAA,QAAA,EAAA;AAAA,sBAAA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,OAAQ,EAAA,WAAA;AAAA,UACR,KAAM,EAAA,SAAA;AAAA,UACN,SAAS,MAAM,QAAA,CAAS,WAAY,CAAA,oBAAA,EAAsB,QAAQ,CAAC,CAAA;AAAA,UACpE,QAAA,EAAA;AAAA;AAAA,OAED;AAAA,0BACC,uBAAwB,EAAA,EAAA;AAAA,KAC3B,EAAA,CAAA;AAAA,oBACA,GAAA,CAAC,kBAAe,KAAO,EAAA,KAAA,GAAQ,CAAC,KAAK,CAAA,GAAI,EAAI,EAAA;AAAA,GAC/C,EAAA,CAAA;AAGF,EAAA,IAAI,OAAS,EAAA;AACX,IAAA,OAAA,uBAAW,QAAS,EAAA,EAAA,CAAA;AAAA;AAEtB,EAAA,IAAI,SAAS,CAAC,KAAA,CAAM,OAAQ,CAAA,QAAA,CAAS,kCAAkC,CAAG,EAAA;AAExE,IAAA,OAAA,uBACG,YAAa,EAAA,EAAA,QAAA,EAAS,SAAQ,KAAM,EAAA,4BAAA,EAClC,gBAAM,OACT,EAAA,CAAA;AAAA;AAIJ,EAAA,uBAAQ,GAAA,CAAA,QAAA,EAAA,EAAS,SAAS,EAAA,IAAA,EAAE,QAAQ,EAAA,OAAA,EAAA,CAAA;AACtC;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
2
3
|
import Typography from '@material-ui/core/Typography';
|
|
3
4
|
import { lighthouseApiRef } from '../../api.esm.js';
|
|
4
5
|
import useInterval from 'react-use/esm/useInterval';
|
|
@@ -60,7 +61,7 @@ const AuditListTable = ({ items }) => {
|
|
|
60
61
|
const trendlineData = buildSparklinesDataForItem(website);
|
|
61
62
|
const trendlines = {};
|
|
62
63
|
CATEGORIES.forEach((category) => {
|
|
63
|
-
trendlines[category] = /* @__PURE__ */
|
|
64
|
+
trendlines[category] = /* @__PURE__ */ jsx(
|
|
64
65
|
TrendLine,
|
|
65
66
|
{
|
|
66
67
|
title: `trendline for ${CATEGORY_LABELS[category]} category of ${website.url}`,
|
|
@@ -69,13 +70,17 @@ const AuditListTable = ({ items }) => {
|
|
|
69
70
|
);
|
|
70
71
|
});
|
|
71
72
|
return {
|
|
72
|
-
websiteUrl: /* @__PURE__ */
|
|
73
|
+
websiteUrl: /* @__PURE__ */ jsx(Link, { to: generatePath("audit/:id", { id: website.lastAudit.id }), children: website.url }),
|
|
73
74
|
...trendlines,
|
|
74
|
-
lastReport: /* @__PURE__ */
|
|
75
|
+
lastReport: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
76
|
+
/* @__PURE__ */ jsx(AuditStatusIcon, { audit: website.lastAudit }),
|
|
77
|
+
" ",
|
|
78
|
+
/* @__PURE__ */ jsx(Typography, { component: "span", children: website.lastAudit.status.toLocaleUpperCase("en-US") })
|
|
79
|
+
] }),
|
|
75
80
|
lastAuditTriggered: formatTime(website.lastAudit.timeCreated)
|
|
76
81
|
};
|
|
77
82
|
});
|
|
78
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ jsx(
|
|
79
84
|
Table,
|
|
80
85
|
{
|
|
81
86
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuditListTable.esm.js","sources":["../../../src/components/AuditList/AuditListTable.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport
|
|
1
|
+
{"version":3,"file":"AuditListTable.esm.js","sources":["../../../src/components/AuditList/AuditListTable.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useState, useEffect } from 'react';\nimport Typography from '@material-ui/core/Typography';\nimport { Website } from '@backstage-community/plugin-lighthouse-common';\nimport { lighthouseApiRef } from '../../api';\nimport useInterval from 'react-use/esm/useInterval';\nimport {\n formatTime,\n CATEGORIES,\n CATEGORY_LABELS,\n buildSparklinesDataForItem,\n} from '../../utils';\nimport { generatePath } from 'react-router-dom';\nimport AuditStatusIcon from '../AuditStatusIcon';\n\nimport {\n Link,\n Table,\n TableColumn,\n TrendLine,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\n\nconst columns: TableColumn[] = [\n {\n title: 'Website URL',\n field: 'websiteUrl',\n },\n ...CATEGORIES.map(category => ({\n title: CATEGORY_LABELS[category],\n field: category,\n })),\n {\n title: 'Last Report',\n field: 'lastReport',\n cellStyle: {\n whiteSpace: 'nowrap',\n },\n },\n {\n title: 'Last Audit Triggered',\n field: 'lastAuditTriggered',\n cellStyle: {\n minWidth: 120,\n },\n },\n];\n\nexport const AuditListTable = ({ items }: { items: Website[] }) => {\n const [websiteState, setWebsiteState] = useState(items);\n const lighthouseApi = useApi(lighthouseApiRef);\n\n useEffect(() => {\n setWebsiteState(items);\n }, [items]);\n\n const runRefresh = (websites: Website[]) => {\n websites.forEach(async website => {\n const response = await lighthouseApi.getWebsiteForAuditId(\n website.lastAudit.id,\n );\n const auditStatus = response.lastAudit.status;\n if (auditStatus === 'COMPLETED' || auditStatus === 'FAILED') {\n const newWebsiteData = websiteState.slice(0);\n newWebsiteData[newWebsiteData.findIndex(w => w.url === response.url)] =\n response;\n setWebsiteState(newWebsiteData);\n }\n });\n };\n\n const runningWebsiteAudits = websiteState\n ? websiteState.filter(website => website.lastAudit.status === 'RUNNING')\n : [];\n\n useInterval(\n () => runRefresh(runningWebsiteAudits),\n runningWebsiteAudits.length > 0 ? 5000 : null,\n );\n\n const data = websiteState.map(website => {\n const trendlineData = buildSparklinesDataForItem(website);\n const trendlines: any = {};\n CATEGORIES.forEach(category => {\n trendlines[category] = (\n <TrendLine\n title={`trendline for ${CATEGORY_LABELS[category]} category of ${website.url}`}\n data={trendlineData[category] || []}\n />\n );\n });\n\n return {\n websiteUrl: (\n <Link to={generatePath('audit/:id', { id: website.lastAudit.id })}>\n {website.url}\n </Link>\n ),\n ...trendlines,\n lastReport: (\n <>\n <AuditStatusIcon audit={website.lastAudit} />{' '}\n <Typography component=\"span\">\n {website.lastAudit.status.toLocaleUpperCase('en-US')}\n </Typography>\n </>\n ),\n lastAuditTriggered: formatTime(website.lastAudit.timeCreated),\n };\n });\n\n return (\n <Table\n options={{\n paging: false,\n toolbar: false,\n }}\n columns={columns}\n data={data}\n />\n );\n};\n\nexport default AuditListTable;\n"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
1
2
|
import Button from '@material-ui/core/Button';
|
|
2
3
|
import Grid from '@material-ui/core/Grid';
|
|
3
4
|
import Pagination from '@material-ui/lab/Pagination';
|
|
4
|
-
import
|
|
5
|
+
import { useState, useMemo } from 'react';
|
|
5
6
|
import { useNavigate } from 'react-router-dom';
|
|
6
7
|
import useAsync from 'react-use/esm/useAsync';
|
|
7
8
|
import useLocalStorage from 'react-use/esm/useLocalStorage';
|
|
@@ -37,46 +38,60 @@ const AuditList = () => {
|
|
|
37
38
|
const navigate = useNavigate();
|
|
38
39
|
let content = null;
|
|
39
40
|
if (value) {
|
|
40
|
-
content = /* @__PURE__ */
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42
|
+
/* @__PURE__ */ jsx(AuditListTable, { items: value?.items || [] }),
|
|
43
|
+
pageCount > 1 && /* @__PURE__ */ jsx(
|
|
44
|
+
Pagination,
|
|
45
|
+
{
|
|
46
|
+
page,
|
|
47
|
+
count: pageCount,
|
|
48
|
+
onChange: (_event, newPage) => {
|
|
49
|
+
navigate(`?page=${newPage}`);
|
|
50
|
+
}
|
|
47
51
|
}
|
|
48
|
-
|
|
49
|
-
)
|
|
52
|
+
)
|
|
53
|
+
] });
|
|
50
54
|
} else if (loading) {
|
|
51
|
-
content = /* @__PURE__ */
|
|
55
|
+
content = /* @__PURE__ */ jsx(Progress, {});
|
|
52
56
|
} else if (error) {
|
|
53
|
-
content = /* @__PURE__ */
|
|
57
|
+
content = /* @__PURE__ */ jsx(WarningPanel, { severity: "error", title: "Could not load audit list.", children: error.message });
|
|
54
58
|
}
|
|
55
|
-
return /* @__PURE__ */
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
title: "Lighthouse",
|
|
59
|
-
subtitle: "Website audits powered by Lighthouse"
|
|
60
|
-
},
|
|
61
|
-
/* @__PURE__ */ React.createElement(HeaderLabel, { label: "Owner", value: "Spotify" }),
|
|
62
|
-
/* @__PURE__ */ React.createElement(HeaderLabel, { label: "Lifecycle", value: "Alpha" })
|
|
63
|
-
), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(LighthouseIntro, { onDismiss: () => setDismissed(true) }), /* @__PURE__ */ React.createElement(
|
|
64
|
-
ContentHeader,
|
|
65
|
-
{
|
|
66
|
-
title: "Audits",
|
|
67
|
-
description: "View all audits run for your website through Backstage here. Track the trend of your most recent audits."
|
|
68
|
-
},
|
|
69
|
-
/* @__PURE__ */ React.createElement(
|
|
70
|
-
Button,
|
|
59
|
+
return /* @__PURE__ */ jsxs(Page, { themeId: "tool", children: [
|
|
60
|
+
/* @__PURE__ */ jsxs(
|
|
61
|
+
Header,
|
|
71
62
|
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
title: "Lighthouse",
|
|
64
|
+
subtitle: "Website audits powered by Lighthouse",
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ jsx(HeaderLabel, { label: "Owner", value: "Spotify" }),
|
|
67
|
+
/* @__PURE__ */ jsx(HeaderLabel, { label: "Lifecycle", value: "Alpha" })
|
|
68
|
+
]
|
|
69
|
+
}
|
|
77
70
|
),
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
/* @__PURE__ */ jsxs(Content, { children: [
|
|
72
|
+
/* @__PURE__ */ jsx(LighthouseIntro, { onDismiss: () => setDismissed(true) }),
|
|
73
|
+
/* @__PURE__ */ jsxs(
|
|
74
|
+
ContentHeader,
|
|
75
|
+
{
|
|
76
|
+
title: "Audits",
|
|
77
|
+
description: "View all audits run for your website through Backstage here. Track the trend of your most recent audits.",
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx(
|
|
80
|
+
Button,
|
|
81
|
+
{
|
|
82
|
+
variant: "contained",
|
|
83
|
+
color: "primary",
|
|
84
|
+
onClick: () => navigate("create-audit"),
|
|
85
|
+
children: "Create Audit"
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
dismissed && /* @__PURE__ */ jsx(LighthouseSupportButton, {})
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ jsx(Grid, { container: true, spacing: 3, direction: "column", children: /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(InfoCard, { noPadding: true, children: content }) }) })
|
|
93
|
+
] })
|
|
94
|
+
] });
|
|
80
95
|
};
|
|
81
96
|
|
|
82
97
|
export { LIMIT, AuditList as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../src/components/AuditList/index.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Button from '@material-ui/core/Button';\nimport Grid from '@material-ui/core/Grid';\nimport Pagination from '@material-ui/lab/Pagination';\nimport
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../src/components/AuditList/index.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Button from '@material-ui/core/Button';\nimport Grid from '@material-ui/core/Grid';\nimport Pagination from '@material-ui/lab/Pagination';\nimport { ChangeEvent, ReactNode, useMemo, useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport useAsync from 'react-use/esm/useAsync';\nimport useLocalStorage from 'react-use/esm/useLocalStorage';\nimport { lighthouseApiRef } from '../../api';\nimport { useQuery } from '../../utils';\nimport LighthouseIntro, { LIGHTHOUSE_INTRO_LOCAL_STORAGE } from '../Intro';\nimport LighthouseSupportButton from '../SupportButton';\nimport AuditListTable from './AuditListTable';\n\nimport {\n Content,\n ContentHeader,\n Header,\n HeaderLabel,\n InfoCard,\n Page,\n Progress,\n WarningPanel,\n} from '@backstage/core-components';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\n// TODO(freben): move all of this out of index\n\nexport const LIMIT = 10;\n\nconst AuditList = () => {\n const [dismissedStored] = useLocalStorage<boolean>(\n LIGHTHOUSE_INTRO_LOCAL_STORAGE,\n );\n const [dismissed, setDismissed] = useState(dismissedStored);\n\n const query = useQuery();\n const page = query.get('page')\n ? parseInt(query.get('page') as string, 10) || 1\n : 1;\n\n const lighthouseApi = useApi(lighthouseApiRef);\n const { value, loading, error } = useAsync(\n async () =>\n await lighthouseApi.getWebsiteList({\n limit: LIMIT,\n offset: (page - 1) * LIMIT,\n }),\n [page],\n );\n\n const pageCount: number = useMemo(() => {\n if (value?.total && value?.limit)\n return Math.ceil(value?.total / value?.limit);\n return 0;\n }, [value?.total, value?.limit]);\n\n const navigate = useNavigate();\n\n let content: ReactNode = null;\n if (value) {\n content = (\n <>\n <AuditListTable items={value?.items || []} />\n {pageCount > 1 && (\n <Pagination\n page={page}\n count={pageCount}\n onChange={(_event: ChangeEvent<unknown>, newPage: number) => {\n navigate(`?page=${newPage}`);\n }}\n />\n )}\n </>\n );\n } else if (loading) {\n content = <Progress />;\n } else if (error) {\n content = (\n <WarningPanel severity=\"error\" title=\"Could not load audit list.\">\n {error.message}\n </WarningPanel>\n );\n }\n\n return (\n <Page themeId=\"tool\">\n <Header\n title=\"Lighthouse\"\n subtitle=\"Website audits powered by Lighthouse\"\n >\n <HeaderLabel label=\"Owner\" value=\"Spotify\" />\n <HeaderLabel label=\"Lifecycle\" value=\"Alpha\" />\n </Header>\n <Content>\n <LighthouseIntro onDismiss={() => setDismissed(true)} />\n <ContentHeader\n title=\"Audits\"\n description=\"View all audits run for your website through Backstage here. Track the trend of your most recent audits.\"\n >\n <Button\n variant=\"contained\"\n color=\"primary\"\n onClick={() => navigate('create-audit')}\n >\n Create Audit\n </Button>\n {dismissed && <LighthouseSupportButton />}\n </ContentHeader>\n <Grid container spacing={3} direction=\"column\">\n <Grid item>\n <InfoCard noPadding>{content}</InfoCard>\n </Grid>\n </Grid>\n </Content>\n </Page>\n );\n};\n\nexport default AuditList;\n"],"names":[],"mappings":"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"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { StatusError, StatusOK, StatusPending } from '@backstage/core-components';
|
|
3
3
|
|
|
4
4
|
const AuditStatusIcon = ({ audit }) => {
|
|
5
|
-
if (audit.status === "FAILED") return /* @__PURE__ */
|
|
6
|
-
if (audit.status === "COMPLETED") return /* @__PURE__ */
|
|
7
|
-
return /* @__PURE__ */
|
|
5
|
+
if (audit.status === "FAILED") return /* @__PURE__ */ jsx(StatusError, {});
|
|
6
|
+
if (audit.status === "COMPLETED") return /* @__PURE__ */ jsx(StatusOK, {});
|
|
7
|
+
return /* @__PURE__ */ jsx(StatusPending, {});
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export { AuditStatusIcon as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../src/components/AuditStatusIcon/index.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../src/components/AuditStatusIcon/index.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Audit } from '@backstage-community/plugin-lighthouse-common';\nimport {\n StatusError,\n StatusOK,\n StatusPending,\n} from '@backstage/core-components';\n\n// TODO(freben): move all of this out of index\n\nconst AuditStatusIcon = ({ audit }: { audit: Audit }) => {\n if (audit.status === 'FAILED') return <StatusError />;\n if (audit.status === 'COMPLETED') return <StatusOK />;\n return <StatusPending />;\n};\n\nexport default AuditStatusIcon;\n"],"names":[],"mappings":";;;AAyBA,MAAM,eAAkB,GAAA,CAAC,EAAE,KAAA,EAA8B,KAAA;AACvD,EAAA,IAAI,KAAM,CAAA,MAAA,KAAW,QAAU,EAAA,2BAAQ,WAAY,EAAA,EAAA,CAAA;AACnD,EAAA,IAAI,KAAM,CAAA,MAAA,KAAW,WAAa,EAAA,2BAAQ,QAAS,EAAA,EAAA,CAAA;AACnD,EAAA,2BAAQ,aAAc,EAAA,EAAA,CAAA;AACxB;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
1
2
|
import Button from '@material-ui/core/Button';
|
|
2
3
|
import Grid from '@material-ui/core/Grid';
|
|
3
4
|
import List from '@material-ui/core/List';
|
|
@@ -6,7 +7,7 @@ import ListItemIcon from '@material-ui/core/ListItemIcon';
|
|
|
6
7
|
import ListItemText from '@material-ui/core/ListItemText';
|
|
7
8
|
import { makeStyles } from '@material-ui/core/styles';
|
|
8
9
|
import Alert from '@material-ui/lab/Alert';
|
|
9
|
-
import
|
|
10
|
+
import { useState, useEffect } from 'react';
|
|
10
11
|
import { useParams, useNavigate, resolvePath, Link, generatePath } from 'react-router-dom';
|
|
11
12
|
import useAsync from 'react-use/esm/useAsync';
|
|
12
13
|
import { lighthouseApiRef } from '../../api.esm.js';
|
|
@@ -30,46 +31,48 @@ const useStyles = makeStyles({
|
|
|
30
31
|
});
|
|
31
32
|
const AuditLinkList = ({ audits = [], selectedId }) => {
|
|
32
33
|
const fromPath = useRouteRef(rootRouteRef)?.() ?? "../";
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ jsx(
|
|
34
35
|
List,
|
|
35
36
|
{
|
|
36
37
|
"data-testid": "audit-sidebar",
|
|
37
38
|
component: "nav",
|
|
38
|
-
"aria-label": "lighthouse audit history"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
"aria-label": "lighthouse audit history",
|
|
40
|
+
children: audits.map((audit) => /* @__PURE__ */ jsxs(
|
|
41
|
+
ListItem,
|
|
42
|
+
{
|
|
43
|
+
selected: audit.id === selectedId,
|
|
44
|
+
button: true,
|
|
45
|
+
component: Link,
|
|
46
|
+
replace: true,
|
|
47
|
+
to: resolvePath(
|
|
48
|
+
generatePath("audit/:id", { id: audit.id }),
|
|
49
|
+
fromPath
|
|
50
|
+
),
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(AuditStatusIcon, { audit }) }),
|
|
53
|
+
/* @__PURE__ */ jsx(ListItemText, { primary: formatTime(audit.timeCreated) })
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
audit.id
|
|
57
|
+
))
|
|
58
|
+
}
|
|
56
59
|
);
|
|
57
60
|
};
|
|
58
61
|
const AuditView = ({ audit }) => {
|
|
59
62
|
const classes = useStyles();
|
|
60
63
|
const params = useParams();
|
|
61
64
|
const { url: lighthouseUrl } = useApi(lighthouseApiRef);
|
|
62
|
-
if (audit?.status === "RUNNING") return /* @__PURE__ */
|
|
65
|
+
if (audit?.status === "RUNNING") return /* @__PURE__ */ jsx(Progress, {});
|
|
63
66
|
if (audit?.status === "FAILED")
|
|
64
|
-
return /* @__PURE__ */
|
|
65
|
-
return /* @__PURE__ */
|
|
67
|
+
return /* @__PURE__ */ jsx(Alert, { severity: "error", children: "This audit failed when attempting to run after several retries. Check that your instance of lighthouse-audit-service can successfully connect to your website and try again." });
|
|
68
|
+
return /* @__PURE__ */ jsx(InfoCard, { variant: "fullHeight", children: /* @__PURE__ */ jsx(
|
|
66
69
|
"iframe",
|
|
67
70
|
{
|
|
68
71
|
className: classes.iframe,
|
|
69
72
|
title: `Lighthouse audit${audit?.url ? ` for ${audit.url}` : ""}`,
|
|
70
73
|
src: `${lighthouseUrl}/v1/audits/${encodeURIComponent(params.id)}`
|
|
71
74
|
}
|
|
72
|
-
));
|
|
75
|
+
) });
|
|
73
76
|
};
|
|
74
77
|
const AuditViewContent = () => {
|
|
75
78
|
const lighthouseApi = useApi(lighthouseApiRef);
|
|
@@ -93,43 +96,57 @@ const AuditViewContent = () => {
|
|
|
93
96
|
}, [value, nextValue, setValue]);
|
|
94
97
|
let content = null;
|
|
95
98
|
if (value) {
|
|
96
|
-
content = /* @__PURE__ */
|
|
99
|
+
content = /* @__PURE__ */ jsxs(Grid, { container: true, alignItems: "stretch", className: classes.contentGrid, children: [
|
|
100
|
+
/* @__PURE__ */ jsx(Grid, { item: true, xs: 3, children: /* @__PURE__ */ jsx(AuditLinkList, { audits: value?.audits, selectedId: params.id }) }),
|
|
101
|
+
/* @__PURE__ */ jsx(Grid, { item: true, xs: 9, children: /* @__PURE__ */ jsx(AuditView, { audit: value?.audits.find((a) => a.id === params.id) }) })
|
|
102
|
+
] });
|
|
97
103
|
} else if (loading) {
|
|
98
|
-
content = /* @__PURE__ */
|
|
104
|
+
content = /* @__PURE__ */ jsx(Progress, {});
|
|
99
105
|
} else if (error) {
|
|
100
|
-
content = /* @__PURE__ */
|
|
106
|
+
content = /* @__PURE__ */ jsx(
|
|
101
107
|
Alert,
|
|
102
108
|
{
|
|
103
109
|
"data-testid": "error-message",
|
|
104
110
|
severity: "error",
|
|
105
|
-
className: classes.errorOutput
|
|
106
|
-
|
|
107
|
-
|
|
111
|
+
className: classes.errorOutput,
|
|
112
|
+
children: error.message
|
|
113
|
+
}
|
|
108
114
|
);
|
|
109
115
|
}
|
|
110
116
|
let createAuditButtonUrl = "create-audit";
|
|
111
117
|
if (value?.url) {
|
|
112
118
|
createAuditButtonUrl += `?url=${encodeURIComponent(value.url)}`;
|
|
113
119
|
}
|
|
114
|
-
return /* @__PURE__ */
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
title: value?.url || "Audit",
|
|
118
|
-
description: "See a history of all Lighthouse audits for your website run through Backstage."
|
|
119
|
-
},
|
|
120
|
-
/* @__PURE__ */ React.createElement(
|
|
121
|
-
Button,
|
|
120
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
121
|
+
/* @__PURE__ */ jsxs(
|
|
122
|
+
ContentHeader,
|
|
122
123
|
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
title: value?.url || "Audit",
|
|
125
|
+
description: "See a history of all Lighthouse audits for your website run through Backstage.",
|
|
126
|
+
children: [
|
|
127
|
+
/* @__PURE__ */ jsx(
|
|
128
|
+
Button,
|
|
129
|
+
{
|
|
130
|
+
variant: "contained",
|
|
131
|
+
color: "primary",
|
|
132
|
+
onClick: () => navigate(resolvePath(createAuditButtonUrl, fromPath)),
|
|
133
|
+
children: "Create New Audit"
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
/* @__PURE__ */ jsx(LighthouseSupportButton, {})
|
|
137
|
+
]
|
|
138
|
+
}
|
|
128
139
|
),
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
content
|
|
141
|
+
] });
|
|
131
142
|
};
|
|
132
|
-
const ConnectedAuditView = () => /* @__PURE__ */
|
|
143
|
+
const ConnectedAuditView = () => /* @__PURE__ */ jsxs(Page, { themeId: "tool", children: [
|
|
144
|
+
/* @__PURE__ */ jsxs(Header, { title: "Lighthouse", subtitle: "Website audits powered by Lighthouse", children: [
|
|
145
|
+
/* @__PURE__ */ jsx(HeaderLabel, { label: "Owner", value: "Spotify" }),
|
|
146
|
+
/* @__PURE__ */ jsx(HeaderLabel, { label: "Lifecycle", value: "Alpha" })
|
|
147
|
+
] }),
|
|
148
|
+
/* @__PURE__ */ jsx(Content, { stretch: true, children: /* @__PURE__ */ jsx(AuditViewContent, {}) })
|
|
149
|
+
] });
|
|
133
150
|
|
|
134
151
|
export { AuditViewContent, ConnectedAuditView as default };
|
|
135
152
|
//# sourceMappingURL=index.esm.js.map
|