@backstage/core-components 0.12.0-next.0 → 0.12.0-next.1
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 +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +21 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage/core-components
|
|
2
2
|
|
|
3
|
+
## 0.12.0-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b4fb5c8ecc: MissingAnnotationEmptyState now accepts either a string or an array of strings to support multiple missing annotations.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/config@1.0.4-next.0
|
|
10
|
+
- @backstage/core-plugin-api@1.1.0-next.0
|
|
11
|
+
- @backstage/errors@1.1.3-next.0
|
|
12
|
+
- @backstage/theme@0.2.16
|
|
13
|
+
- @backstage/version-bridge@1.0.1
|
|
14
|
+
|
|
3
15
|
## 0.12.0-next.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -576,7 +576,7 @@ declare function EmptyState(props: Props$h): JSX.Element;
|
|
|
576
576
|
declare type EmptyStateImageClassKey = 'generalImg';
|
|
577
577
|
|
|
578
578
|
declare type Props$g = {
|
|
579
|
-
annotation: string;
|
|
579
|
+
annotation: string | string[];
|
|
580
580
|
readMoreUrl?: string;
|
|
581
581
|
};
|
|
582
582
|
declare type MissingAnnotationEmptyStateClassKey = 'code';
|
package/dist/index.esm.js
CHANGED
|
@@ -1045,7 +1045,7 @@ function EmptyState(props) {
|
|
|
1045
1045
|
}) : missing.customImage));
|
|
1046
1046
|
}
|
|
1047
1047
|
|
|
1048
|
-
const
|
|
1048
|
+
const COMPONENT_YAML_TEMPLATE = `apiVersion: backstage.io/v1alpha1
|
|
1049
1049
|
kind: Component
|
|
1050
1050
|
metadata:
|
|
1051
1051
|
name: example
|
|
@@ -1056,6 +1056,11 @@ spec:
|
|
|
1056
1056
|
type: website
|
|
1057
1057
|
lifecycle: production
|
|
1058
1058
|
owner: user:guest`;
|
|
1059
|
+
const ANNOTATION_REGEXP = /^.*ANNOTATION.*$/m;
|
|
1060
|
+
const ANNOTATION_YAML = COMPONENT_YAML_TEMPLATE.match(ANNOTATION_REGEXP)[0];
|
|
1061
|
+
const ANNOTATION_LINE = COMPONENT_YAML_TEMPLATE.split("\n").findIndex(
|
|
1062
|
+
(line) => ANNOTATION_REGEXP.test(line)
|
|
1063
|
+
);
|
|
1059
1064
|
const useStyles$J = makeStyles(
|
|
1060
1065
|
(theme) => ({
|
|
1061
1066
|
code: {
|
|
@@ -1066,24 +1071,35 @@ const useStyles$J = makeStyles(
|
|
|
1066
1071
|
}),
|
|
1067
1072
|
{ name: "BackstageMissingAnnotationEmptyState" }
|
|
1068
1073
|
);
|
|
1074
|
+
function generateLineNumbers(lineCount) {
|
|
1075
|
+
return Array.from(Array(lineCount + 1).keys(), (i) => i + ANNOTATION_LINE);
|
|
1076
|
+
}
|
|
1077
|
+
function generateComponentYaml(annotations) {
|
|
1078
|
+
const annotationYaml = annotations.map((ann) => ANNOTATION_YAML.replace("ANNOTATION", ann)).join("\n");
|
|
1079
|
+
return COMPONENT_YAML_TEMPLATE.replace(ANNOTATION_YAML, annotationYaml);
|
|
1080
|
+
}
|
|
1081
|
+
function generateDescription(annotations) {
|
|
1082
|
+
const isSingular = annotations.length <= 1;
|
|
1083
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, "The ", isSingular ? "annotation" : "annotations", " ", annotations.map((ann) => /* @__PURE__ */ React.createElement("code", null, ann)).reduce((prev, curr) => /* @__PURE__ */ React.createElement(React.Fragment, null, prev, ", ", curr)), " ", isSingular ? "is" : "are", " missing. You need to add the", " ", isSingular ? "annotation" : "annotations", " to your component if you want to enable this tool.");
|
|
1084
|
+
}
|
|
1069
1085
|
function MissingAnnotationEmptyState(props) {
|
|
1070
1086
|
const { annotation, readMoreUrl } = props;
|
|
1087
|
+
const annotations = Array.isArray(annotation) ? annotation : [annotation];
|
|
1071
1088
|
const url = readMoreUrl || "https://backstage.io/docs/features/software-catalog/well-known-annotations";
|
|
1072
1089
|
const classes = useStyles$J();
|
|
1073
|
-
const description = /* @__PURE__ */ React.createElement(React.Fragment, null, "The ", /* @__PURE__ */ React.createElement("code", null, annotation), " annotation is missing. You need to add the annotation to your component if you want to enable this tool.");
|
|
1074
1090
|
return /* @__PURE__ */ React.createElement(EmptyState, {
|
|
1075
1091
|
missing: "field",
|
|
1076
1092
|
title: "Missing Annotation",
|
|
1077
|
-
description,
|
|
1093
|
+
description: generateDescription(annotations),
|
|
1078
1094
|
action: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Typography, {
|
|
1079
1095
|
variant: "body1"
|
|
1080
1096
|
}, "Add the annotation to your component YAML as shown in the highlighted example below:"), /* @__PURE__ */ React.createElement("div", {
|
|
1081
1097
|
className: classes.code
|
|
1082
1098
|
}, /* @__PURE__ */ React.createElement(CodeSnippet, {
|
|
1083
|
-
text:
|
|
1099
|
+
text: generateComponentYaml(annotations),
|
|
1084
1100
|
language: "yaml",
|
|
1085
1101
|
showLineNumbers: true,
|
|
1086
|
-
highlightedNumbers:
|
|
1102
|
+
highlightedNumbers: generateLineNumbers(annotations.length),
|
|
1087
1103
|
customStyle: { background: "inherit", fontSize: "115%" }
|
|
1088
1104
|
})), /* @__PURE__ */ React.createElement(Button$1, {
|
|
1089
1105
|
color: "primary",
|