@backstage-community/plugin-gocd 0.1.42 → 0.1.43

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @backstage-community/plugin-gocd
2
2
 
3
+ ## 0.1.43
4
+
5
+ ### Patch Changes
6
+
7
+ - 1edd3db: Backstage version bump to v1.29.2
8
+
3
9
  ## 0.1.42
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,28 @@
1
+ import { ResponseError } from '@backstage/errors';
2
+
3
+ const DEFAULT_PAGE_SIZE = 100;
4
+ class GoCdClientApi {
5
+ constructor(discoveryApi, fetchApi) {
6
+ this.discoveryApi = discoveryApi;
7
+ this.fetchApi = fetchApi;
8
+ }
9
+ async getPipelineHistory(pipelineName) {
10
+ const { fetch } = this.fetchApi;
11
+ const baseUrl = await this.discoveryApi.getBaseUrl("proxy");
12
+ const pipelineHistoryResponse = await fetch(
13
+ `${baseUrl}/gocd/pipelines/${pipelineName}/history?page_size=${DEFAULT_PAGE_SIZE}`,
14
+ {
15
+ headers: {
16
+ Accept: "application/vnd.go.cd+json"
17
+ }
18
+ }
19
+ );
20
+ if (!pipelineHistoryResponse.ok) {
21
+ throw await ResponseError.fromResponse(pipelineHistoryResponse);
22
+ }
23
+ return await pipelineHistoryResponse.json();
24
+ }
25
+ }
26
+
27
+ export { GoCdClientApi };
28
+ //# sourceMappingURL=gocdApi.client.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gocdApi.client.esm.js","sources":["../../src/api/gocdApi.client.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { GoCdApi } from './gocdApi';\nimport { GoCdApiError, PipelineHistory } from './gocdApi.model';\nimport { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\n\nconst DEFAULT_PAGE_SIZE = 100;\n\nexport class GoCdClientApi implements GoCdApi {\n constructor(\n private readonly discoveryApi: DiscoveryApi,\n private readonly fetchApi: FetchApi,\n ) {}\n\n async getPipelineHistory(\n pipelineName: string,\n ): Promise<PipelineHistory | GoCdApiError> {\n const { fetch } = this.fetchApi;\n\n const baseUrl = await this.discoveryApi.getBaseUrl('proxy');\n const pipelineHistoryResponse = await fetch(\n `${baseUrl}/gocd/pipelines/${pipelineName}/history?page_size=${DEFAULT_PAGE_SIZE}`,\n {\n headers: {\n Accept: 'application/vnd.go.cd+json',\n },\n },\n );\n\n if (!pipelineHistoryResponse.ok) {\n throw await ResponseError.fromResponse(pipelineHistoryResponse);\n }\n\n return await pipelineHistoryResponse.json();\n }\n}\n"],"names":[],"mappings":";;AAqBA,MAAM,iBAAoB,GAAA,GAAA,CAAA;AAEnB,MAAM,aAAiC,CAAA;AAAA,EAC5C,WAAA,CACmB,cACA,QACjB,EAAA;AAFiB,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA,CAAA;AACA,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA,CAAA;AAAA,GAChB;AAAA,EAEH,MAAM,mBACJ,YACyC,EAAA;AACzC,IAAM,MAAA,EAAE,KAAM,EAAA,GAAI,IAAK,CAAA,QAAA,CAAA;AAEvB,IAAA,MAAM,OAAU,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,WAAW,OAAO,CAAA,CAAA;AAC1D,IAAA,MAAM,0BAA0B,MAAM,KAAA;AAAA,MACpC,CAAG,EAAA,OAAO,CAAmB,gBAAA,EAAA,YAAY,sBAAsB,iBAAiB,CAAA,CAAA;AAAA,MAChF;AAAA,QACE,OAAS,EAAA;AAAA,UACP,MAAQ,EAAA,4BAAA;AAAA,SACV;AAAA,OACF;AAAA,KACF,CAAA;AAEA,IAAI,IAAA,CAAC,wBAAwB,EAAI,EAAA;AAC/B,MAAM,MAAA,MAAM,aAAc,CAAA,YAAA,CAAa,uBAAuB,CAAA,CAAA;AAAA,KAChE;AAEA,IAAO,OAAA,MAAM,wBAAwB,IAAK,EAAA,CAAA;AAAA,GAC5C;AACF;;;;"}
@@ -0,0 +1,28 @@
1
+ var GoCdBuildResultStatus = /* @__PURE__ */ ((GoCdBuildResultStatus2) => {
2
+ GoCdBuildResultStatus2[GoCdBuildResultStatus2["running"] = 0] = "running";
3
+ GoCdBuildResultStatus2[GoCdBuildResultStatus2["successful"] = 1] = "successful";
4
+ GoCdBuildResultStatus2[GoCdBuildResultStatus2["warning"] = 2] = "warning";
5
+ GoCdBuildResultStatus2[GoCdBuildResultStatus2["aborted"] = 3] = "aborted";
6
+ GoCdBuildResultStatus2[GoCdBuildResultStatus2["error"] = 4] = "error";
7
+ GoCdBuildResultStatus2[GoCdBuildResultStatus2["pending"] = 5] = "pending";
8
+ return GoCdBuildResultStatus2;
9
+ })(GoCdBuildResultStatus || {});
10
+ const toBuildResultStatus = (status) => {
11
+ switch (status.toLocaleLowerCase("en-US")) {
12
+ case "passed":
13
+ return 1 /* successful */;
14
+ case "failed":
15
+ return 4 /* error */;
16
+ case "aborted":
17
+ return 3 /* aborted */;
18
+ case "building":
19
+ return 0 /* running */;
20
+ case "pending":
21
+ return 5 /* pending */;
22
+ default:
23
+ return 3 /* aborted */;
24
+ }
25
+ };
26
+
27
+ export { GoCdBuildResultStatus, toBuildResultStatus };
28
+ //# sourceMappingURL=gocdApi.model.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gocdApi.model.esm.js","sources":["../../src/api/gocdApi.model.ts"],"sourcesContent":["/*\n * Copyright 2021 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 */\nexport interface GoCdApiError {\n message: string;\n}\n\nexport interface PipelineHistory {\n _links: Links;\n pipelines: Pipeline[];\n}\n\nexport interface Links {\n next: Next;\n}\n\nexport interface Next {\n href: string;\n}\n\nexport interface Pipeline {\n name: string;\n counter: number;\n label: string;\n natural_order?: number;\n can_run?: boolean;\n preparing_to_schedule?: boolean;\n comment: string | null;\n scheduled_date?: number;\n build_cause?: BuildCause;\n stages: Stage[];\n}\n\nexport interface BuildCause {\n trigger_message: string;\n trigger_forced: boolean;\n approver: string;\n material_revisions: MaterialRevision[];\n}\n\nexport interface MaterialRevision {\n changed: boolean;\n material: Material;\n modifications: Modification[];\n}\n\nexport interface Material {\n name: string;\n fingerprint: string;\n type: string;\n description: string;\n}\n\nexport interface Modification {\n revision: string;\n modified_time: number;\n user_name: string;\n comment: string | null;\n email_address: string | null;\n}\n\nexport interface Stage {\n result?: string;\n status: string;\n rerun_of_counter?: number | null;\n name: string;\n counter: string;\n scheduled: boolean;\n approval_type?: string | null;\n approved_by?: string | null;\n operate_permission?: boolean;\n can_run?: boolean;\n jobs: Job[];\n}\n\nexport interface Job {\n name: string;\n scheduled_date?: number;\n state: string;\n result: string;\n}\n\nexport enum GoCdBuildResultStatus {\n running,\n successful,\n warning,\n aborted,\n error,\n pending,\n}\n\nexport const toBuildResultStatus = (status: string): GoCdBuildResultStatus => {\n switch (status.toLocaleLowerCase('en-US')) {\n case 'passed':\n return GoCdBuildResultStatus.successful;\n case 'failed':\n return GoCdBuildResultStatus.error;\n case 'aborted':\n return GoCdBuildResultStatus.aborted;\n case 'building':\n return GoCdBuildResultStatus.running;\n case 'pending':\n return GoCdBuildResultStatus.pending;\n default:\n return GoCdBuildResultStatus.aborted;\n }\n};\n\nexport interface GoCdBuildStageResult {\n status: GoCdBuildResultStatus;\n text: string;\n}\n\nexport interface GoCdBuildResult {\n id: number;\n source: string;\n stages: GoCdBuildStageResult[];\n buildSlug: string;\n message: string;\n pipeline: string;\n author: string | undefined;\n commitHash: string;\n triggerTime: number | undefined;\n}\n"],"names":["GoCdBuildResultStatus"],"mappings":"AA8FY,IAAA,qBAAA,qBAAAA,sBAAL,KAAA;AACL,EAAAA,sBAAA,CAAA,sBAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAA,CAAA;AACA,EAAAA,sBAAA,CAAA,sBAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAA,CAAA;AACA,EAAAA,sBAAA,CAAA,sBAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAA,CAAA;AACA,EAAAA,sBAAA,CAAA,sBAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAA,CAAA;AACA,EAAAA,sBAAA,CAAA,sBAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAA,CAAA;AACA,EAAAA,sBAAA,CAAA,sBAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAA,CAAA;AANU,EAAAA,OAAAA,sBAAAA,CAAAA;AAAA,CAAA,EAAA,qBAAA,IAAA,EAAA,EAAA;AASC,MAAA,mBAAA,GAAsB,CAAC,MAA0C,KAAA;AAC5E,EAAQ,QAAA,MAAA,CAAO,iBAAkB,CAAA,OAAO,CAAG;AAAA,IACzC,KAAK,QAAA;AACH,MAAO,OAAA,CAAA,kBAAA;AAAA,IACT,KAAK,QAAA;AACH,MAAO,OAAA,CAAA,aAAA;AAAA,IACT,KAAK,SAAA;AACH,MAAO,OAAA,CAAA,eAAA;AAAA,IACT,KAAK,UAAA;AACH,MAAO,OAAA,CAAA,eAAA;AAAA,IACT,KAAK,SAAA;AACH,MAAO,OAAA,CAAA,eAAA;AAAA,IACT;AACE,MAAO,OAAA,CAAA,eAAA;AAAA,GACX;AACF;;;;"}
@@ -0,0 +1,87 @@
1
+ import React, { useState } from 'react';
2
+ import { useEntity, MissingAnnotationEmptyState } from '@backstage/plugin-catalog-react';
3
+ import { EmptyState, Page, Content, ContentHeader } from '@backstage/core-components';
4
+ import { useApi, configApiRef } from '@backstage/core-plugin-api';
5
+ import useAsync from 'react-use/esm/useAsync';
6
+ import { gocdApiRef } from '../../plugin.esm.js';
7
+ import { GoCdBuildsTable } from '../GoCdBuildsTable/GoCdBuildsTable.esm.js';
8
+ import { GoCdBuildsInsights } from '../GoCdBuildsInsights/GoCdBuildsInsights.esm.js';
9
+ import { SelectComponent } from '../Select/Select.esm.js';
10
+
11
+ const GOCD_PIPELINES_ANNOTATION = "gocd.org/pipelines";
12
+ const isGoCdAvailable = (entity) => Boolean(entity.metadata.annotations?.[GOCD_PIPELINES_ANNOTATION]);
13
+ const GoCdBuildsComponent = () => {
14
+ const { entity } = useEntity();
15
+ const config = useApi(configApiRef);
16
+ const rawPipelines = entity.metadata.annotations?.[GOCD_PIPELINES_ANNOTATION]?.split(",").map((p) => p.trim());
17
+ const gocdApi = useApi(gocdApiRef);
18
+ const [selectedPipeline, setSelectedPipeline] = useState(
19
+ rawPipelines ? rawPipelines[0] : ""
20
+ );
21
+ const {
22
+ value: pipelineHistory,
23
+ loading,
24
+ error
25
+ } = useAsync(async () => {
26
+ return await gocdApi.getPipelineHistory(selectedPipeline);
27
+ }, [selectedPipeline]);
28
+ const onSelectedPipelineChanged = (pipeline) => {
29
+ setSelectedPipeline(pipeline);
30
+ };
31
+ const getSelectionItems = (pipelines) => {
32
+ return pipelines.map((p) => ({ label: p, value: p }));
33
+ };
34
+ function isError(apiResult) {
35
+ return apiResult?.message !== void 0;
36
+ }
37
+ if (!rawPipelines) {
38
+ return /* @__PURE__ */ React.createElement(MissingAnnotationEmptyState, { annotation: GOCD_PIPELINES_ANNOTATION });
39
+ }
40
+ if (isError(pipelineHistory)) {
41
+ return /* @__PURE__ */ React.createElement(
42
+ EmptyState,
43
+ {
44
+ title: "GoCD pipelines",
45
+ description: `Could not fetch pipelines defined for entity ${entity.metadata.name}. Error: ${pipelineHistory.message}`,
46
+ missing: "content"
47
+ }
48
+ );
49
+ }
50
+ if (!loading && !pipelineHistory) {
51
+ return /* @__PURE__ */ React.createElement(
52
+ EmptyState,
53
+ {
54
+ title: "GoCD pipelines",
55
+ description: `We could not find pipelines defined for entity ${entity.metadata.name}.`,
56
+ missing: "data"
57
+ }
58
+ );
59
+ }
60
+ return /* @__PURE__ */ React.createElement(Page, { themeId: "tool" }, /* @__PURE__ */ React.createElement(Content, { noPadding: true }, /* @__PURE__ */ React.createElement(ContentHeader, { title: entity.metadata.name }, /* @__PURE__ */ React.createElement(
61
+ SelectComponent,
62
+ {
63
+ value: selectedPipeline,
64
+ onChange: (pipeline) => onSelectedPipelineChanged(pipeline),
65
+ label: "Pipeline",
66
+ items: getSelectionItems(rawPipelines)
67
+ }
68
+ )), /* @__PURE__ */ React.createElement(
69
+ GoCdBuildsInsights,
70
+ {
71
+ pipelineHistory,
72
+ loading,
73
+ error
74
+ }
75
+ ), /* @__PURE__ */ React.createElement(
76
+ GoCdBuildsTable,
77
+ {
78
+ goCdBaseUrl: config.getString("gocd.baseUrl"),
79
+ pipelineHistory,
80
+ loading,
81
+ error
82
+ }
83
+ )));
84
+ };
85
+
86
+ export { GOCD_PIPELINES_ANNOTATION, GoCdBuildsComponent, isGoCdAvailable };
87
+ //# sourceMappingURL=GoCdBuildsComponent.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoCdBuildsComponent.esm.js","sources":["../../../src/components/GoCdBuildsComponent/GoCdBuildsComponent.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 React, { useState } from 'react';\nimport { Entity } from '@backstage/catalog-model';\nimport {\n useEntity,\n MissingAnnotationEmptyState,\n} from '@backstage/plugin-catalog-react';\nimport {\n Content,\n ContentHeader,\n EmptyState,\n Page,\n} from '@backstage/core-components';\nimport { useApi, configApiRef } from '@backstage/core-plugin-api';\nimport useAsync from 'react-use/esm/useAsync';\nimport { gocdApiRef } from '../../plugin';\nimport { GoCdBuildsTable } from '../GoCdBuildsTable/GoCdBuildsTable';\nimport { GoCdBuildsInsights } from '../GoCdBuildsInsights/GoCdBuildsInsights';\nimport { GoCdApiError, PipelineHistory } from '../../api/gocdApi.model';\nimport { Item, Select } from '../Select';\n\n/**\n * Constant storing GoCD pipelines annotation.\n *\n * @public\n */\nexport const GOCD_PIPELINES_ANNOTATION = 'gocd.org/pipelines';\n\n/**\n * Returns true if GoCD annotation is present in the given entity.\n *\n * @public\n */\nexport const isGoCdAvailable = (entity: Entity): boolean =>\n Boolean(entity.metadata.annotations?.[GOCD_PIPELINES_ANNOTATION]);\n\nexport const GoCdBuildsComponent = (): JSX.Element => {\n const { entity } = useEntity();\n const config = useApi(configApiRef);\n const rawPipelines: string[] | undefined = (\n entity.metadata.annotations?.[GOCD_PIPELINES_ANNOTATION] as\n | string\n | undefined\n )\n ?.split(',')\n .map(p => p.trim());\n const gocdApi = useApi(gocdApiRef);\n\n const [selectedPipeline, setSelectedPipeline] = useState<string>(\n rawPipelines ? rawPipelines[0] : '',\n );\n\n const {\n value: pipelineHistory,\n loading,\n error,\n } = useAsync(async (): Promise<PipelineHistory | GoCdApiError> => {\n return await gocdApi.getPipelineHistory(selectedPipeline);\n }, [selectedPipeline]);\n\n const onSelectedPipelineChanged = (pipeline: string) => {\n setSelectedPipeline(pipeline);\n };\n\n const getSelectionItems = (pipelines: string[]): Item[] => {\n return pipelines.map(p => ({ label: p, value: p }));\n };\n\n function isError(\n apiResult: PipelineHistory | GoCdApiError | undefined,\n ): apiResult is GoCdApiError {\n return (apiResult as GoCdApiError)?.message !== undefined;\n }\n\n if (!rawPipelines) {\n return (\n <MissingAnnotationEmptyState annotation={GOCD_PIPELINES_ANNOTATION} />\n );\n }\n\n if (isError(pipelineHistory)) {\n return (\n <EmptyState\n title=\"GoCD pipelines\"\n description={`Could not fetch pipelines defined for entity ${entity.metadata.name}. Error: ${pipelineHistory.message}`}\n missing=\"content\"\n />\n );\n }\n\n if (!loading && !pipelineHistory) {\n return (\n <EmptyState\n title=\"GoCD pipelines\"\n description={`We could not find pipelines defined for entity ${entity.metadata.name}.`}\n missing=\"data\"\n />\n );\n }\n\n return (\n <Page themeId=\"tool\">\n <Content noPadding>\n <ContentHeader title={entity.metadata.name}>\n <Select\n value={selectedPipeline}\n onChange={pipeline => onSelectedPipelineChanged(pipeline)}\n label=\"Pipeline\"\n items={getSelectionItems(rawPipelines)}\n />\n </ContentHeader>\n <GoCdBuildsInsights\n pipelineHistory={pipelineHistory}\n loading={loading}\n error={error}\n />\n <GoCdBuildsTable\n goCdBaseUrl={config.getString('gocd.baseUrl')}\n pipelineHistory={pipelineHistory}\n loading={loading}\n error={error}\n />\n </Content>\n </Page>\n );\n};\n"],"names":["Select"],"mappings":";;;;;;;;;;AAwCO,MAAM,yBAA4B,GAAA,qBAAA;AAO5B,MAAA,eAAA,GAAkB,CAAC,MAC9B,KAAA,OAAA,CAAQ,OAAO,QAAS,CAAA,WAAA,GAAc,yBAAyB,CAAC,EAAA;AAE3D,MAAM,sBAAsB,MAAmB;AACpD,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA,CAAA;AAC7B,EAAM,MAAA,MAAA,GAAS,OAAO,YAAY,CAAA,CAAA;AAClC,EAAA,MAAM,YACJ,GAAA,MAAA,CAAO,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AA,MACC,WAAA,EAAa,MAAO,CAAA,SAAA,CAAU,cAAc,CAAA;AAAA,MAC5C,eAAA;AAAA,MACA,OAAA;AAAA,MACA,KAAA;AAAA,KAAA;AAAA,GAEJ,CACF,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,2 @@
1
+ export { GOCD_PIPELINES_ANNOTATION, GoCdBuildsComponent, isGoCdAvailable } from './GoCdBuildsComponent.esm.js';
2
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,126 @@
1
+ import React from 'react';
2
+ import { mean, groupBy } from 'lodash';
3
+ import { toBuildResultStatus, GoCdBuildResultStatus } from '../../api/gocdApi.model.esm.js';
4
+ import Box from '@material-ui/core/Box';
5
+ import Grid from '@material-ui/core/Grid';
6
+ import Card from '@material-ui/core/Card';
7
+ import CardContent from '@material-ui/core/CardContent';
8
+ import Tooltip from '@material-ui/core/Tooltip';
9
+ import Typography from '@material-ui/core/Typography';
10
+ import { DateTime, Duration } from 'luxon';
11
+
12
+ function runFrequency(pipelineHistory) {
13
+ const lastMonth = DateTime.now().minus({ month: 1 });
14
+ const buildLastMonth = pipelineHistory.pipelines.map((p) => p.scheduled_date).filter((d) => !!d).map((d) => DateTime.fromMillis(d)).filter((d) => d > lastMonth).length;
15
+ return `${buildLastMonth} last month`;
16
+ }
17
+ function meanTimeBetweenFailures(jobs) {
18
+ const timeBetweenFailures = [];
19
+ for (let index = 1; index < jobs.length; index++) {
20
+ const job = jobs[index];
21
+ if (!job.result) {
22
+ continue;
23
+ }
24
+ if (toBuildResultStatus(job.result) === GoCdBuildResultStatus.error) {
25
+ let previousFailedJob = null;
26
+ for (let j = index - 1; j >= 0; j--) {
27
+ const candidateJob = jobs[j];
28
+ if (!candidateJob.result) {
29
+ continue;
30
+ }
31
+ if (toBuildResultStatus(candidateJob.result) === GoCdBuildResultStatus.error) {
32
+ previousFailedJob = candidateJob;
33
+ break;
34
+ }
35
+ }
36
+ if (!previousFailedJob || !job.scheduled_date || !previousFailedJob.scheduled_date) {
37
+ continue;
38
+ }
39
+ const failedJobDate = DateTime.fromMillis(job.scheduled_date);
40
+ const previousFailedJobDate = DateTime.fromMillis(
41
+ previousFailedJob.scheduled_date
42
+ );
43
+ const timeBetweenFailure = failedJobDate.diff(previousFailedJobDate);
44
+ timeBetweenFailures.push(timeBetweenFailure);
45
+ }
46
+ }
47
+ return formatMean(timeBetweenFailures);
48
+ }
49
+ function meanTimeToRecovery(jobs) {
50
+ const timeToRecoverIntervals = [];
51
+ for (let index = 0; index < jobs.length; index++) {
52
+ const job = jobs[index];
53
+ if (!job.result) {
54
+ continue;
55
+ }
56
+ if (toBuildResultStatus(job.result) === GoCdBuildResultStatus.error) {
57
+ let nextSuccessfulJob = null;
58
+ for (let j = index + 1; j < jobs.length; j++) {
59
+ const candidateJob = jobs[j];
60
+ if (!candidateJob.result) {
61
+ continue;
62
+ }
63
+ if (toBuildResultStatus(candidateJob.result) === GoCdBuildResultStatus.successful) {
64
+ nextSuccessfulJob = candidateJob;
65
+ break;
66
+ }
67
+ }
68
+ if (!nextSuccessfulJob || !job.scheduled_date || !nextSuccessfulJob.scheduled_date) {
69
+ continue;
70
+ }
71
+ const failedJobDate = DateTime.fromMillis(job.scheduled_date);
72
+ const successfulJobDate = DateTime.fromMillis(
73
+ nextSuccessfulJob.scheduled_date
74
+ );
75
+ const timeToRecovery = successfulJobDate.diff(failedJobDate);
76
+ timeToRecoverIntervals.push(timeToRecovery);
77
+ }
78
+ }
79
+ return formatMean(timeToRecoverIntervals);
80
+ }
81
+ function formatMean(durations) {
82
+ if (durations.length === 0) {
83
+ return "N/A";
84
+ }
85
+ const mttr = Duration.fromMillis(
86
+ mean(durations.map((i) => i.milliseconds))
87
+ );
88
+ return mttr.toFormat("d'd' h'h' m'm' s's'");
89
+ }
90
+ function failureRate(jobs) {
91
+ const resultGroups = new Map(
92
+ Object.entries(groupBy(jobs, "result")).map(([key, value]) => [
93
+ toBuildResultStatus(key),
94
+ value.flat()
95
+ ])
96
+ );
97
+ const failedJobs = resultGroups.get(GoCdBuildResultStatus.error);
98
+ if (!failedJobs) {
99
+ return {
100
+ title: "0",
101
+ subtitle: "(no failed jobs found)"
102
+ };
103
+ }
104
+ resultGroups.delete(GoCdBuildResultStatus.error);
105
+ const nonFailedJobs = Array.from(resultGroups.values()).flat();
106
+ const totalJobs = failedJobs.length + nonFailedJobs.length;
107
+ const percentage = failedJobs.length / totalJobs * 100;
108
+ const decimalPercentage = (Math.round(percentage * 100) / 100).toFixed(2);
109
+ return {
110
+ title: `${decimalPercentage}%`,
111
+ subtitle: `(${failedJobs.length} out of ${totalJobs} jobs)`
112
+ };
113
+ }
114
+ const GoCdBuildsInsights = (props) => {
115
+ const { pipelineHistory, loading, error } = props;
116
+ if (loading || error || !pipelineHistory) {
117
+ return /* @__PURE__ */ React.createElement(React.Fragment, null);
118
+ }
119
+ const stages = pipelineHistory.pipelines.slice().reverse().map((p) => p.stages).flat();
120
+ const jobs = stages.map((s) => s.jobs).flat();
121
+ const failureRateObj = failureRate(jobs);
122
+ return /* @__PURE__ */ React.createElement(Box, { "data-testid": "GoCdBuildsInsightsBox", sx: { mb: 1 } }, /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 1 }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 6, sm: 3 }, /* @__PURE__ */ React.createElement(Tooltip, { title: "What is your deployment frequency?" }, /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, "Run Frequency"), /* @__PURE__ */ React.createElement(Typography, { variant: "h4" }, runFrequency(pipelineHistory)))))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 6, sm: 3 }, /* @__PURE__ */ React.createElement(Tooltip, { title: "How long does it take to fix a failure?" }, /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, "Mean Time to Recovery"), /* @__PURE__ */ React.createElement(Typography, { variant: "h4" }, meanTimeToRecovery(jobs)))))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 6, sm: 3 }, /* @__PURE__ */ React.createElement(Tooltip, { title: "How often do changes fail?" }, /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, "Mean Time Between Failures"), /* @__PURE__ */ React.createElement(Typography, { variant: "h4" }, meanTimeBetweenFailures(jobs)))))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 6, sm: 3 }, /* @__PURE__ */ React.createElement(Tooltip, { title: "What percentage of changes result in a failure?" }, /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, "Failure Rate"), /* @__PURE__ */ React.createElement(Typography, { variant: "h4" }, failureRateObj.title), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, failureRateObj.subtitle)))))));
123
+ };
124
+
125
+ export { GoCdBuildsInsights };
126
+ //# sourceMappingURL=GoCdBuildsInsights.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoCdBuildsInsights.esm.js","sources":["../../../src/components/GoCdBuildsInsights/GoCdBuildsInsights.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 React from 'react';\nimport { groupBy, mean } from 'lodash';\nimport {\n PipelineHistory,\n Job,\n toBuildResultStatus,\n GoCdBuildResultStatus,\n} from '../../api/gocdApi.model';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport Card from '@material-ui/core/Card';\nimport CardContent from '@material-ui/core/CardContent';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Typography from '@material-ui/core/Typography';\nimport { DateTime, Duration } from 'luxon';\n\nexport type GoCdBuildsInsightsProps = {\n pipelineHistory: PipelineHistory | undefined;\n loading: boolean;\n error: Error | undefined;\n};\n\nfunction runFrequency(pipelineHistory: PipelineHistory): string {\n const lastMonth = DateTime.now().minus({ month: 1 });\n const buildLastMonth = pipelineHistory.pipelines\n .map(p => p.scheduled_date)\n .filter((d): d is number => !!d)\n .map(d => DateTime.fromMillis(d))\n .filter(d => d > lastMonth).length;\n return `${buildLastMonth} last month`;\n}\n\nfunction meanTimeBetweenFailures(jobs: Job[]): string {\n const timeBetweenFailures: Duration[] = [];\n for (let index = 1; index < jobs.length; index++) {\n const job = jobs[index];\n if (!job.result) {\n continue;\n }\n if (toBuildResultStatus(job.result) === GoCdBuildResultStatus.error) {\n let previousFailedJob: Job | null = null;\n for (let j = index - 1; j >= 0; j--) {\n const candidateJob = jobs[j];\n if (!candidateJob.result) {\n continue;\n }\n if (\n toBuildResultStatus(candidateJob.result) ===\n GoCdBuildResultStatus.error\n ) {\n previousFailedJob = candidateJob;\n break;\n }\n }\n if (\n !previousFailedJob ||\n !job.scheduled_date ||\n !previousFailedJob.scheduled_date\n ) {\n continue;\n }\n const failedJobDate = DateTime.fromMillis(job.scheduled_date);\n const previousFailedJobDate = DateTime.fromMillis(\n previousFailedJob.scheduled_date,\n );\n const timeBetweenFailure = failedJobDate.diff(previousFailedJobDate);\n timeBetweenFailures.push(timeBetweenFailure);\n }\n }\n return formatMean(timeBetweenFailures);\n}\n\n/**\n * Imagine a sequence like:\n * S - S - S - F - S - F - F - S - S\n *\n * We iterate until finding a failure, and then iterate forward\n * until we find the first immediate success to then\n * calculate the time difference between the scheduling of the jobs.\n */\nfunction meanTimeToRecovery(jobs: Job[]): string {\n const timeToRecoverIntervals: Duration[] = [];\n for (let index = 0; index < jobs.length; index++) {\n const job = jobs[index];\n if (!job.result) {\n continue;\n }\n if (toBuildResultStatus(job.result) === GoCdBuildResultStatus.error) {\n let nextSuccessfulJob: Job | null = null;\n for (let j = index + 1; j < jobs.length; j++) {\n const candidateJob = jobs[j];\n if (!candidateJob.result) {\n continue;\n }\n if (\n toBuildResultStatus(candidateJob.result) ===\n GoCdBuildResultStatus.successful\n ) {\n nextSuccessfulJob = candidateJob;\n break;\n }\n }\n if (\n !nextSuccessfulJob ||\n !job.scheduled_date ||\n !nextSuccessfulJob.scheduled_date\n ) {\n continue;\n }\n const failedJobDate = DateTime.fromMillis(job.scheduled_date);\n const successfulJobDate = DateTime.fromMillis(\n nextSuccessfulJob.scheduled_date,\n );\n const timeToRecovery = successfulJobDate.diff(failedJobDate);\n timeToRecoverIntervals.push(timeToRecovery);\n }\n }\n\n return formatMean(timeToRecoverIntervals);\n}\n\nfunction formatMean(durations: Duration[]): string {\n if (durations.length === 0) {\n return 'N/A';\n }\n\n const mttr: Duration = Duration.fromMillis(\n mean(durations.map(i => i.milliseconds)),\n );\n return mttr.toFormat(\"d'd' h'h' m'm' s's'\");\n}\n\nfunction failureRate(jobs: Job[]): {\n title: string;\n subtitle: string;\n} {\n const resultGroups = new Map(\n Object.entries(groupBy(jobs, 'result')).map(([key, value]) => [\n toBuildResultStatus(key),\n value.flat(),\n ]),\n );\n const failedJobs = resultGroups.get(GoCdBuildResultStatus.error);\n if (!failedJobs) {\n return {\n title: '0',\n subtitle: '(no failed jobs found)',\n };\n }\n\n resultGroups.delete(GoCdBuildResultStatus.error);\n const nonFailedJobs = Array.from(resultGroups.values()).flat();\n\n const totalJobs = failedJobs.length + nonFailedJobs.length;\n const percentage = (failedJobs.length / totalJobs) * 100;\n const decimalPercentage = (Math.round(percentage * 100) / 100).toFixed(2);\n return {\n title: `${decimalPercentage}%`,\n subtitle: `(${failedJobs.length} out of ${totalJobs} jobs)`,\n };\n}\n\nexport const GoCdBuildsInsights = (\n props: GoCdBuildsInsightsProps,\n): JSX.Element => {\n const { pipelineHistory, loading, error } = props;\n\n if (loading || error || !pipelineHistory) {\n return <></>;\n }\n\n // We reverse the array to calculate insights to make sure jobs are ordered\n // by their schedule date.\n const stages = pipelineHistory.pipelines\n .slice()\n .reverse()\n .map(p => p.stages)\n .flat();\n const jobs = stages.map(s => s.jobs).flat();\n\n const failureRateObj: { title: string; subtitle: string } = failureRate(jobs);\n\n return (\n <Box data-testid=\"GoCdBuildsInsightsBox\" sx={{ mb: 1 }}>\n <Grid container spacing={1}>\n <Grid item xs={6} sm={3}>\n <Tooltip title=\"What is your deployment frequency?\">\n <Card>\n <CardContent>\n <Typography variant=\"body2\">Run Frequency</Typography>\n <Typography variant=\"h4\">\n {runFrequency(pipelineHistory)}\n </Typography>\n </CardContent>\n </Card>\n </Tooltip>\n </Grid>\n <Grid item xs={6} sm={3}>\n <Tooltip title=\"How long does it take to fix a failure?\">\n <Card>\n <CardContent>\n <Typography variant=\"body2\">Mean Time to Recovery</Typography>\n <Typography variant=\"h4\">{meanTimeToRecovery(jobs)}</Typography>\n </CardContent>\n </Card>\n </Tooltip>\n </Grid>\n <Grid item xs={6} sm={3}>\n <Tooltip title=\"How often do changes fail?\">\n <Card>\n <CardContent>\n <Typography variant=\"body2\">\n Mean Time Between Failures\n </Typography>\n <Typography variant=\"h4\">\n {meanTimeBetweenFailures(jobs)}\n </Typography>\n </CardContent>\n </Card>\n </Tooltip>\n </Grid>\n <Grid item xs={6} sm={3}>\n <Tooltip title=\"What percentage of changes result in a failure?\">\n <Card>\n <CardContent>\n <Typography variant=\"body2\">Failure Rate</Typography>\n <Typography variant=\"h4\">{failureRateObj.title}</Typography>\n <Typography variant=\"body2\">\n {failureRateObj.subtitle}\n </Typography>\n </CardContent>\n </Card>\n </Tooltip>\n </Grid>\n </Grid>\n </Box>\n );\n};\n"],"names":[],"mapp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@ -0,0 +1,135 @@
1
+ import React, { useState } from 'react';
2
+ import { getEntitySourceLocation } from '@backstage/catalog-model';
3
+ import { useEntity } from '@backstage/plugin-catalog-react';
4
+ import Alert from '@material-ui/lab/Alert';
5
+ import Button from '@material-ui/core/Button';
6
+ import GitHubIcon from '@material-ui/icons/GitHub';
7
+ import { toBuildResultStatus, GoCdBuildResultStatus } from '../../api/gocdApi.model.esm.js';
8
+ import { DateTime } from 'luxon';
9
+ import { Table, SubvalueCell, StatusWarning, StatusPending, StatusAborted, StatusRunning, StatusError, StatusOK, Link } from '@backstage/core-components';
10
+
11
+ const renderTrigger = (build) => {
12
+ const subvalue = /* @__PURE__ */ React.createElement(React.Fragment, null, build.pipeline, /* @__PURE__ */ React.createElement("br", null), build.author);
13
+ return /* @__PURE__ */ React.createElement(SubvalueCell, { value: build.message, subvalue });
14
+ };
15
+ const renderStages = (build) => {
16
+ return build.stages.map((s) => {
17
+ switch (s.status) {
18
+ case GoCdBuildResultStatus.successful: {
19
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(StatusOK, null, s.text), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("br", null));
20
+ }
21
+ case GoCdBuildResultStatus.error: {
22
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(StatusError, null, s.text), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("br", null));
23
+ }
24
+ case GoCdBuildResultStatus.running: {
25
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(StatusRunning, null, s.text), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("br", null));
26
+ }
27
+ case GoCdBuildResultStatus.aborted: {
28
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(StatusAborted, null, s.text), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("br", null));
29
+ }
30
+ case GoCdBuildResultStatus.pending: {
31
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(StatusPending, null, s.text), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("br", null));
32
+ }
33
+ default: {
34
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(StatusWarning, null, s.text), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("br", null));
35
+ }
36
+ }
37
+ });
38
+ };
39
+ const renderSource = (build) => {
40
+ return /* @__PURE__ */ React.createElement(
41
+ Button,
42
+ {
43
+ href: build.source,
44
+ target: "_blank",
45
+ rel: "noreferrer",
46
+ startIcon: /* @__PURE__ */ React.createElement(GitHubIcon, null)
47
+ },
48
+ build.commitHash
49
+ );
50
+ };
51
+ const renderId = (goCdBaseUrl, build) => {
52
+ const goCdBuildUrl = `${goCdBaseUrl}/go/pipelines/value_stream_map/${build.buildSlug}`;
53
+ return /* @__PURE__ */ React.createElement(
54
+ SubvalueCell,
55
+ {
56
+ value: /* @__PURE__ */ React.createElement(Link, { to: goCdBuildUrl, target: "_blank", rel: "noreferrer" }, build.id),
57
+ subvalue: build.triggerTime && DateTime.fromMillis(build.triggerTime).toLocaleString(
58
+ DateTime.DATETIME_MED
59
+ )
60
+ }
61
+ );
62
+ };
63
+ const renderError = (error) => {
64
+ return /* @__PURE__ */ React.createElement(Alert, { severity: "error" }, error.message);
65
+ };
66
+ const toBuildResults = (entity, builds) => {
67
+ const entitySourceLocation = getEntitySourceLocation(entity).target.split("/tree")[0];
68
+ return builds.map((build) => ({
69
+ id: build.counter,
70
+ source: `${entitySourceLocation}/commit/${build.build_cause?.material_revisions[0]?.modifications[0].revision}`,
71
+ stages: build.stages.map((s) => ({
72
+ status: toBuildResultStatus(s.status),
73
+ text: s.name
74
+ })),
75
+ buildSlug: `${build.name}/${build.counter}`,
76
+ message: build.build_cause?.material_revisions[0]?.modifications[0].comment ?? "",
77
+ pipeline: build.name,
78
+ author: build.build_cause?.material_revisions[0]?.modifications[0].user_name,
79
+ commitHash: build.label,
80
+ triggerTime: build.scheduled_date
81
+ }));
82
+ };
83
+ const GoCdBuildsTable = (props) => {
84
+ const { pipelineHistory, loading, error } = props;
85
+ const { entity } = useEntity();
86
+ const [, setSelectedSearchTerm] = useState("");
87
+ const columns = [
88
+ {
89
+ title: "ID",
90
+ field: "id",
91
+ highlight: true,
92
+ render: (build) => renderId(props.goCdBaseUrl, build)
93
+ },
94
+ {
95
+ title: "Trigger",
96
+ customFilterAndSearch: (query, row) => `${row.message} ${row.pipeline} ${row.author}`.toLocaleUpperCase("en-US").includes(query.toLocaleUpperCase("en-US")),
97
+ field: "message",
98
+ highlight: true,
99
+ render: (build) => renderTrigger(build)
100
+ },
101
+ {
102
+ title: "Stages",
103
+ field: "status",
104
+ render: (build) => renderStages(build)
105
+ },
106
+ {
107
+ title: "Source",
108
+ field: "source",
109
+ render: (build) => renderSource(build)
110
+ }
111
+ ];
112
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, error && renderError(error), !error && /* @__PURE__ */ React.createElement(
113
+ Table,
114
+ {
115
+ title: "GoCD builds",
116
+ isLoading: loading,
117
+ options: {
118
+ search: true,
119
+ searchAutoFocus: true,
120
+ debounceInterval: 800,
121
+ paging: true,
122
+ padding: "dense",
123
+ pageSizeOptions: [5, 10, 20, 50],
124
+ showFirstLastPageButtons: false,
125
+ pageSize: 20
126
+ },
127
+ columns,
128
+ data: pipelineHistory ? toBuildResults(entity, pipelineHistory.pipelines) || [] : [],
129
+ onSearchChange: (searchTerm) => setSelectedSearchTerm(searchTerm)
130
+ }
131
+ ));
132
+ };
133
+
134
+ export { GoCdBuildsTable };
135
+ //# sourceMappingURL=GoCdBuildsTable.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoCdBuildsTable.esm.js","sources":["../../../src/components/GoCdBuildsTable/GoCdBuildsTable.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 React, { useState } from 'react';\nimport { Entity, getEntitySourceLocation } from '@backstage/catalog-model';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport Alert from '@material-ui/lab/Alert';\nimport Button from '@material-ui/core/Button';\nimport GitHubIcon from '@material-ui/icons/GitHub';\nimport {\n GoCdBuildResult,\n GoCdBuildResultStatus,\n toBuildResultStatus,\n PipelineHistory,\n Pipeline,\n} from '../../api/gocdApi.model';\nimport { DateTime } from 'luxon';\nimport {\n Table,\n TableColumn,\n Link,\n SubvalueCell,\n StatusOK,\n StatusWarning,\n StatusAborted,\n StatusError,\n StatusRunning,\n StatusPending,\n} from '@backstage/core-components';\n\ntype GoCdBuildsProps = {\n goCdBaseUrl: string;\n pipelineHistory: PipelineHistory | undefined;\n loading: boolean;\n error: Error | undefined;\n};\n\nconst renderTrigger = (build: GoCdBuildResult): React.ReactNode => {\n const subvalue = (\n <>\n {build.pipeline}\n <br />\n {build.author}\n </>\n );\n return <SubvalueCell value={build.message} subvalue={subvalue} />;\n};\n\nconst renderStages = (build: GoCdBuildResult): React.ReactNode => {\n return build.stages.map(s => {\n switch (s.status) {\n case GoCdBuildResultStatus.successful: {\n return (\n <>\n <StatusOK>{s.text}</StatusOK>\n <br />\n <br />\n </>\n );\n }\n case GoCdBuildResultStatus.error: {\n return (\n <>\n <StatusError>{s.text}</StatusError>\n <br />\n <br />\n </>\n );\n }\n case GoCdBuildResultStatus.running: {\n return (\n <>\n <StatusRunning>{s.text}</StatusRunning>\n <br />\n <br />\n </>\n );\n }\n case GoCdBuildResultStatus.aborted: {\n return (\n <>\n <StatusAborted>{s.text}</StatusAborted>\n <br />\n <br />\n </>\n );\n }\n case GoCdBuildResultStatus.pending: {\n return (\n <>\n <StatusPending>{s.text}</StatusPending>\n <br />\n <br />\n </>\n );\n }\n default: {\n return (\n <>\n <StatusWarning>{s.text}</StatusWarning>\n <br />\n <br />\n </>\n );\n }\n }\n });\n};\n\nconst renderSource = (build: GoCdBuildResult): React.ReactNode => {\n return (\n <Button\n href={build.source}\n target=\"_blank\"\n rel=\"noreferrer\"\n startIcon={<GitHubIcon />}\n >\n {build.commitHash}\n </Button>\n );\n};\n\nconst renderId = (\n goCdBaseUrl: string,\n build: GoCdBuildResult,\n): React.ReactNode => {\n const goCdBuildUrl = `${goCdBaseUrl}/go/pipelines/value_stream_map/${build.buildSlug}`;\n return (\n <SubvalueCell\n value={\n <Link to={goCdBuildUrl} target=\"_blank\" rel=\"noreferrer\">\n {build.id}\n </Link>\n }\n subvalue={\n build.triggerTime &&\n DateTime.fromMillis(build.triggerTime).toLocaleString(\n DateTime.DATETIME_MED,\n )\n }\n />\n );\n};\n\nconst renderError = (error: Error): JSX.Element => {\n return <Alert severity=\"error\">{error.message}</Alert>;\n};\n\nconst toBuildResults = (\n entity: Entity,\n builds: Pipeline[],\n): GoCdBuildResult[] | undefined => {\n // TODO(julioz): What if not git 'type'?\n const entitySourceLocation =\n getEntitySourceLocation(entity).target.split('/tree')[0];\n return builds.map(build => ({\n id: build.counter,\n source: `${entitySourceLocation}/commit/${build.build_cause?.material_revisions[0]?.modifications[0].revision}`,\n stages: build.stages.map(s => ({\n status: toBuildResultStatus(s.status),\n text: s.name,\n })),\n buildSlug: `${build.name}/${build.counter}`,\n message:\n build.build_cause?.material_revisions[0]?.modifications[0].comment ?? '',\n pipeline: build.name,\n author:\n build.build_cause?.material_revisions[0]?.modifications[0].user_name,\n commitHash: build.label,\n triggerTime: build.scheduled_date,\n }));\n};\n\nexport const GoCdBuildsTable = (props: GoCdBuildsProps): JSX.Element => {\n const { pipelineHistory, loading, error } = props;\n const { entity } = useEntity();\n const [, setSelectedSearchTerm] = useState<string>('');\n\n const columns: TableColumn<GoCdBuildResult>[] = [\n {\n title: 'ID',\n field: 'id',\n highlight: true,\n render: build => renderId(props.goCdBaseUrl, build),\n },\n {\n title: 'Trigger',\n customFilterAndSearch: (query, row: GoCdBuildResult) =>\n `${row.message} ${row.pipeline} ${row.author}`\n .toLocaleUpperCase('en-US')\n .includes(query.toLocaleUpperCase('en-US')),\n field: 'message',\n highlight: true,\n render: build => renderTrigger(build),\n },\n {\n title: 'Stages',\n field: 'status',\n render: build => renderStages(build),\n },\n {\n title: 'Source',\n field: 'source',\n render: build => renderSource(build),\n },\n ];\n\n return (\n <>\n {error && renderError(error)}\n {!error && (\n <Table\n title=\"GoCD builds\"\n isLoading={loading}\n options={{\n search: true,\n searchAutoFocus: true,\n debounceInterval: 800,\n paging: true,\n padding: 'dense',\n pageSizeOptions: [5, 10, 20, 50],\n showFirstLastPageButtons: false,\n pageSize: 20,\n }}\n columns={columns}\n data={\n pipelineHistory\n ? toBuildResults(entity, pipelineHistory.pipelines) || []\n : []\n }\n onSearchChange={(searchTerm: string) =>\n setSelectedSearchTerm(searchTerm)\n }\n />\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAiDA,MAAM,aAAA,GAAgB,CAAC,KAA4C,KAAA;AACjE,EAAM,MAAA,QAAA,6DAED,KAAM,CAAA,QAAA,sCACN,IAAG,EAAA,IAAA,CAAA,EACH,MAAM,MACT,CAAA,CAAA;AAEF,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,KAAO,EAAA,KAAA,CAAM,SAAS,QAAoB,EAAA,CAAA,CAAA;AACjE,CAAA,CAAA;AAEA,MAAM,YAAA,GAAe,CAAC,KAA4C,KAAA;AAChE,EAAO,OAAA,KAAA,CAAM,MAAO,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA;AAC3B,IAAA,QAAQ,EAAE,MAAQ;AAAA,MAChB,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,MACX,MAAA,EAAQ,CAAS,KAAA,KAAA,aAAA,CAAc,KAAK,CAAA;AAAA,KACtC;AAAA,IACA;AAAA,MACE,KAAO,EAAA,QAAA;AAAA,MACP,KAAO,EAAA,QAAA;AAAA,MACP,MAAA,EAAQ,CAAS,KAAA,KAAA,YAAA,CAAa,KAAK,CAAA;AAAA,KACrC;AAAA,IACA;AAAA,MACE,KAAO,EAAA,QAAA;AAAA,MACP,KAAO,EAAA,QAAA;AAAA,MACP,MAAA,EAAQ,CAAS,KAAA,KAAA,YAAA,CAAa,KAAK,CAAA;AAAA,KACrC;AAAA,GACF,CAAA;AAEA,EAAA,iEAEK,KAAS,IAAA,WAAA,CAAY,KAAK,CAAA,EAC1B,CAAC,KACA,oBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,KAAM,EAAA,aAAA;AAAA,MACN,SAAW,EAAA,OAAA;AAAA,MACX,OAAS,EAAA;AAAA,QACP,MAAQ,EAAA,IAAA;AAAA,QACR,eAAiB,EAAA,IAAA;AAAA,QACjB,gBAAkB,EAAA,GAAA;AAAA,QAClB,MAAQ,EAAA,IAAA;AAAA,QACR,OAAS,EAAA,OAAA;AAAA,QACT,eAAiB,EAAA,CAAC,CAAG,EAAA,EAAA,EAAI,IAAI,EAAE,CAAA;AAAA,QAC/B,wBAA0B,EAAA,KAAA;AAAA,QAC1B,QAAU,EAAA,EAAA;AAAA,OACZ;AAAA,MACA,OAAA;AAAA,MACA,IAAA,EACE,kBACI,cAAe,CAAA,MAAA,EAAQ,gBAAgB,SAAS,CAAA,IAAK,EAAC,GACtD,EAAC;AAAA,MAEP,cAAgB,EAAA,CAAC,UACf,KAAA,qBAAA,CAAsB,UAAU,CAAA;AAAA,KAAA;AAAA,GAIxC,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,48 @@
1
+ import FormControl from '@material-ui/core/FormControl';
2
+ import InputLabel from '@material-ui/core/InputLabel';
3
+ import MenuItem from '@material-ui/core/MenuItem';
4
+ import Select from '@material-ui/core/Select';
5
+ import { makeStyles, createStyles } from '@material-ui/core/styles';
6
+ import React from 'react';
7
+
8
+ const useStyles = makeStyles(
9
+ (theme) => createStyles({
10
+ formControl: {
11
+ margin: theme.spacing(1),
12
+ minWidth: 120
13
+ },
14
+ selectEmpty: {
15
+ marginTop: theme.spacing(2)
16
+ }
17
+ })
18
+ );
19
+ const renderItems = (items) => {
20
+ return items.map((item) => {
21
+ return /* @__PURE__ */ React.createElement(MenuItem, { value: item.value, key: item.label }, item.label);
22
+ });
23
+ };
24
+ const SelectComponent = ({
25
+ value,
26
+ items,
27
+ label,
28
+ onChange
29
+ }) => {
30
+ const classes = useStyles();
31
+ const handleChange = (event) => {
32
+ const val = event.target.value;
33
+ onChange(val);
34
+ };
35
+ return /* @__PURE__ */ React.createElement(
36
+ FormControl,
37
+ {
38
+ variant: "outlined",
39
+ className: classes.formControl,
40
+ disabled: items.length === 0
41
+ },
42
+ /* @__PURE__ */ React.createElement(InputLabel, null, label),
43
+ /* @__PURE__ */ React.createElement(Select, { label, value, onChange: handleChange }, renderItems(items))
44
+ );
45
+ };
46
+
47
+ export { SelectComponent };
48
+ //# sourceMappingURL=Select.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.esm.js","sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 FormControl from '@material-ui/core/FormControl';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport React from 'react';\n\nexport type Item = {\n label: string;\n value: string | number;\n};\n\nconst useStyles = makeStyles((theme: Theme) =>\n createStyles({\n formControl: {\n margin: theme.spacing(1),\n minWidth: 120,\n },\n selectEmpty: {\n marginTop: theme.spacing(2),\n },\n }),\n);\n\ntype SelectComponentProps = {\n value: string;\n items: Item[];\n label: string;\n onChange: (value: string) => void;\n};\n\nconst renderItems = (items: Item[]) => {\n return items.map(item => {\n return (\n <MenuItem value={item.value} key={item.label}>\n {item.label}\n </MenuItem>\n );\n });\n};\n\nexport const SelectComponent = ({\n value,\n items,\n label,\n onChange,\n}: SelectComponentProps): JSX.Element => {\n const classes = useStyles();\n\n const handleChange = (event: React.ChangeEvent<{ value: unknown }>) => {\n const val = event.target.value as string;\n onChange(val);\n };\n\n return (\n <FormControl\n variant=\"outlined\"\n className={classes.formControl}\n disabled={items.length === 0}\n >\n <InputLabel>{label}</InputLabel>\n <Select label={label} value={value} onChange={handleChange}>\n {renderItems(items)}\n </Select>\n </FormControl>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA2BA,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,CAAC,UAC5B,YAAa,CAAA;AAAA,IACX,WAAa,EAAA;AAAA,MACX,MAAA,EAAQ,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,MACvB,QAAU,EAAA,GAAA;AAAA,KACZ;AAAA,IACA,WAAa,EAAA;AAAA,MACX,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,KAC5B;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AASA,MAAM,WAAA,GAAc,CAAC,KAAkB,KAAA;AACrC,EAAO,OAAA,KAAA,CAAM,IAAI,CAAQ,IAAA,KAAA;AACvB,IACE,uBAAA,KAAA,CAAA,aAAA,CAAC,YAAS,KAAO,EAAA,IAAA,CAAK,OAAO,GAAK,EAAA,IAAA,CAAK,KACpC,EAAA,EAAA,IAAA,CAAK,KACR,CAAA,CAAA;AAAA,GAEH,CAAA,CAAA;AACH,CAAA,CAAA;AAEO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AACF,CAAyC,KAAA;AACvC,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAE1B,EAAM,MAAA,YAAA,GAAe,CAAC,KAAiD,KAAA;AACrE,IAAM,MAAA,GAAA,GAAM,MAAM,MAAO,CAAA,KAAA,CAAA;AACzB,IAAA,QAAA,CAAS,GAAG,CAAA,CAAA;AAAA,GACd,CAAA;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,OAAQ,EAAA,UAAA;AAAA,MACR,WAAW,OAAQ,CAAA,WAAA;AAAA,MACnB,QAAA,EAAU,MAAM,MAAW,KAAA,CAAA;AAAA,KAAA;AAAA,oBAE3B,KAAA,CAAA,aAAA,CAAC,kBAAY,KAAM,CAAA;AAAA,oBACnB,KAAA,CAAA,aAAA,CAAC,UAAO,KAAc,EAAA,KAAA,EAAc,UAAU,YAC3C,EAAA,EAAA,WAAA,CAAY,KAAK,CACpB,CAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,16 @@
1
+ import { gocdPlugin } from './plugin.esm.js';
2
+ import { createComponentExtension } from '@backstage/core-plugin-api';
3
+
4
+ const EntityGoCdContent = gocdPlugin.provide(
5
+ createComponentExtension({
6
+ name: "EntityGoCdContent",
7
+ component: {
8
+ lazy: () => import('./components/GoCdBuildsComponent/index.esm.js').then(
9
+ (m) => m.GoCdBuildsComponent
10
+ )
11
+ }
12
+ })
13
+ );
14
+
15
+ export { EntityGoCdContent };
16
+ //# sourceMappingURL=extensions.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.esm.js","sources":["../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { gocdPlugin } from './plugin';\nimport { createComponentExtension } from '@backstage/core-plugin-api';\n\n/**\n * GoCD builds table component.\n *\n * @public\n */\nexport const EntityGoCdContent = gocdPlugin.provide(\n createComponentExtension({\n name: 'EntityGoCdContent',\n component: {\n lazy: () =>\n import('./components/GoCdBuildsComponent').then(\n m => m.GoCdBuildsComponent,\n ),\n },\n }),\n);\n"],"names":[],"mappings":";;;AAuBO,MAAM,oBAAoB,UAAW,CAAA,OAAA;AAAA,EAC1C,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,mBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,+CAAkC,CAAE,CAAA,IAAA;AAAA,QACzC,OAAK,CAAE,CAAA,mBAAA;AAAA,OACT;AAAA,KACJ;AAAA,GACD,CAAA;AACH;;;;"}