@backstage/core-components 0.18.3 → 0.18.4-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 +27 -0
- package/dist/alpha.d.ts +1 -0
- package/dist/components/LogViewer/LogViewerControls.esm.js +4 -1
- package/dist/components/LogViewer/LogViewerControls.esm.js.map +1 -1
- package/dist/components/LogViewer/RealLogViewer.esm.js +104 -76
- package/dist/components/LogViewer/RealLogViewer.esm.js.map +1 -1
- package/dist/components/LogViewer/styles.esm.js +7 -2
- package/dist/components/LogViewer/styles.esm.js.map +1 -1
- package/dist/components/LogViewer/useLogViewerSelection.esm.js +139 -19
- package/dist/components/LogViewer/useLogViewerSelection.esm.js.map +1 -1
- package/dist/components/WarningPanel/WarningPanel.esm.js +1 -0
- package/dist/components/WarningPanel/WarningPanel.esm.js.map +1 -1
- package/dist/translation.esm.js +5 -0
- package/dist/translation.esm.js.map +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @backstage/core-components
|
|
2
2
|
|
|
3
|
+
## 0.18.4-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9a942a4: Fixed bug in the `LogViewer` component where shift + click always opened a new window instead of just changing the selection.
|
|
8
|
+
|
|
9
|
+
In addition, improved the `LogViewer` component by a few usability enhancements:
|
|
10
|
+
|
|
11
|
+
- Added support for multiple selections using cmd/ctrl + click
|
|
12
|
+
- Improved the generated hash that is added to the URL to also support ranges & multiple selections
|
|
13
|
+
- Added an hover effect & info tooltip to the "Copy to clipboard" button to indicate its functionality
|
|
14
|
+
- Added some color and a separator to the line numbers to improve readability
|
|
15
|
+
|
|
16
|
+
- 207c3c8: long words like urls now breaks to new line on warning panels instead of overflowing the container
|
|
17
|
+
- 5d52dab: Add i18n support for LogViewer search control
|
|
18
|
+
|
|
19
|
+
## 0.18.4-next.0
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- @backstage/core-plugin-api@1.12.1-next.0
|
|
25
|
+
- @backstage/theme@0.7.1-next.0
|
|
26
|
+
- @backstage/config@1.3.6
|
|
27
|
+
- @backstage/errors@1.2.7
|
|
28
|
+
- @backstage/version-bridge@1.0.11
|
|
29
|
+
|
|
3
30
|
## 0.18.3
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/dist/alpha.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ declare const coreComponentsTranslationRef: _backstage_core_plugin_api_alpha.Tra
|
|
|
56
56
|
readonly "autoLogout.stillTherePrompt.buttonText": "Yes! Don't log me out";
|
|
57
57
|
readonly "dependencyGraph.fullscreenTooltip": "Toggle fullscreen";
|
|
58
58
|
readonly "proxiedSignInPage.title": "You do not appear to be signed in. Please try reloading the browser page.";
|
|
59
|
+
readonly "logViewer.searchField.placeholder": "Search";
|
|
59
60
|
}>;
|
|
60
61
|
|
|
61
62
|
export { coreComponentsTranslationRef };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
2
3
|
import IconButton from '@material-ui/core/IconButton';
|
|
3
4
|
import TextField from '@material-ui/core/TextField';
|
|
4
5
|
import Typography from '@material-ui/core/Typography';
|
|
5
6
|
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
|
|
6
7
|
import ChevronRight from '@material-ui/icons/ChevronRight';
|
|
7
8
|
import FilterList from '@material-ui/icons/FilterList';
|
|
9
|
+
import { coreComponentsTranslationRef } from '../../translation.esm.js';
|
|
8
10
|
|
|
9
11
|
function LogViewerControls(props) {
|
|
12
|
+
const { t } = useTranslationRef(coreComponentsTranslationRef);
|
|
10
13
|
const { resultCount, resultIndexStep, toggleShouldFilter } = props;
|
|
11
14
|
const resultIndex = props.resultIndex ?? 0;
|
|
12
15
|
const handleKeyPress = (event) => {
|
|
@@ -33,7 +36,7 @@ function LogViewerControls(props) {
|
|
|
33
36
|
{
|
|
34
37
|
size: "small",
|
|
35
38
|
variant: "standard",
|
|
36
|
-
placeholder: "
|
|
39
|
+
placeholder: t("logViewer.searchField.placeholder"),
|
|
37
40
|
value: props.searchInput,
|
|
38
41
|
onKeyPress: handleKeyPress,
|
|
39
42
|
onChange: (e) => props.setSearchInput(e.target.value)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogViewerControls.esm.js","sources":["../../../src/components/LogViewer/LogViewerControls.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 */\n\nimport { KeyboardEvent } from 'react';\nimport IconButton from '@material-ui/core/IconButton';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport ChevronLeftIcon from '@material-ui/icons/ChevronLeft';\nimport ChevronRightIcon from '@material-ui/icons/ChevronRight';\nimport FilterListIcon from '@material-ui/icons/FilterList';\nimport { LogViewerSearch } from './useLogViewerSearch';\n\nexport interface LogViewerControlsProps extends LogViewerSearch {}\n\nexport function LogViewerControls(props: LogViewerControlsProps) {\n const { resultCount, resultIndexStep, toggleShouldFilter } = props;\n const resultIndex = props.resultIndex ?? 0;\n\n const handleKeyPress = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n if (event.metaKey || event.ctrlKey || event.altKey) {\n toggleShouldFilter();\n } else {\n resultIndexStep(event.shiftKey);\n }\n }\n };\n\n return (\n <>\n {resultCount !== undefined && (\n <>\n <IconButton size=\"small\" onClick={() => resultIndexStep(true)}>\n <ChevronLeftIcon />\n </IconButton>\n <Typography>\n {Math.min(resultIndex + 1, resultCount)}/{resultCount}\n </Typography>\n <IconButton size=\"small\" onClick={() => resultIndexStep()}>\n <ChevronRightIcon />\n </IconButton>\n </>\n )}\n <TextField\n size=\"small\"\n variant=\"standard\"\n placeholder
|
|
1
|
+
{"version":3,"file":"LogViewerControls.esm.js","sources":["../../../src/components/LogViewer/LogViewerControls.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 */\n\nimport { KeyboardEvent } from 'react';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport IconButton from '@material-ui/core/IconButton';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport ChevronLeftIcon from '@material-ui/icons/ChevronLeft';\nimport ChevronRightIcon from '@material-ui/icons/ChevronRight';\nimport FilterListIcon from '@material-ui/icons/FilterList';\nimport { coreComponentsTranslationRef } from '../../translation';\nimport { LogViewerSearch } from './useLogViewerSearch';\n\nexport interface LogViewerControlsProps extends LogViewerSearch {}\n\nexport function LogViewerControls(props: LogViewerControlsProps) {\n const { t } = useTranslationRef(coreComponentsTranslationRef);\n const { resultCount, resultIndexStep, toggleShouldFilter } = props;\n const resultIndex = props.resultIndex ?? 0;\n\n const handleKeyPress = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n if (event.metaKey || event.ctrlKey || event.altKey) {\n toggleShouldFilter();\n } else {\n resultIndexStep(event.shiftKey);\n }\n }\n };\n\n return (\n <>\n {resultCount !== undefined && (\n <>\n <IconButton size=\"small\" onClick={() => resultIndexStep(true)}>\n <ChevronLeftIcon />\n </IconButton>\n <Typography>\n {Math.min(resultIndex + 1, resultCount)}/{resultCount}\n </Typography>\n <IconButton size=\"small\" onClick={() => resultIndexStep()}>\n <ChevronRightIcon />\n </IconButton>\n </>\n )}\n <TextField\n size=\"small\"\n variant=\"standard\"\n placeholder={t('logViewer.searchField.placeholder')}\n value={props.searchInput}\n onKeyPress={handleKeyPress}\n onChange={e => props.setSearchInput(e.target.value)}\n />\n <IconButton size=\"small\" onClick={toggleShouldFilter}>\n {props.shouldFilter ? (\n <FilterListIcon color=\"primary\" />\n ) : (\n <FilterListIcon color=\"disabled\" />\n )}\n </IconButton>\n </>\n );\n}\n"],"names":["ChevronRightIcon","FilterListIcon"],"mappings":";;;;;;;;;;AA6BO,SAAS,kBAAkB,KAAA,EAA+B;AAC/D,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,4BAA4B,CAAA;AAC5D,EAAA,MAAM,EAAE,WAAA,EAAa,eAAA,EAAiB,kBAAA,EAAmB,GAAI,KAAA;AAC7D,EAAA,MAAM,WAAA,GAAc,MAAM,WAAA,IAAe,CAAA;AAEzC,EAAA,MAAM,cAAA,GAAiB,CAAC,KAAA,KAA2C;AACjE,IAAA,IAAI,KAAA,CAAM,QAAQ,OAAA,EAAS;AACzB,MAAA,IAAI,KAAA,CAAM,OAAA,IAAW,KAAA,CAAM,OAAA,IAAW,MAAM,MAAA,EAAQ;AAClD,QAAA,kBAAA,EAAmB;AAAA,MACrB,CAAA,MAAO;AACL,QAAA,eAAA,CAAgB,MAAM,QAAQ,CAAA;AAAA,MAChC;AAAA,IACF;AAAA,EACF,CAAA;AAEA,EAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,IAAA,WAAA,KAAgB,0BACf,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA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3
3
|
import IconButton from '@material-ui/core/IconButton';
|
|
4
4
|
import CopyIcon from '@material-ui/icons/FileCopy';
|
|
@@ -13,6 +13,7 @@ import { LogViewerControls } from './LogViewerControls.esm.js';
|
|
|
13
13
|
import { useStyles, HEADER_SIZE } from './styles.esm.js';
|
|
14
14
|
import { useLogViewerSearch } from './useLogViewerSearch.esm.js';
|
|
15
15
|
import { useLogViewerSelection } from './useLogViewerSelection.esm.js';
|
|
16
|
+
import Snackbar from '@material-ui/core/Snackbar';
|
|
16
17
|
|
|
17
18
|
function RealLogViewer(props) {
|
|
18
19
|
const classes = useStyles({ classes: props.classes });
|
|
@@ -21,6 +22,7 @@ function RealLogViewer(props) {
|
|
|
21
22
|
const heights = useRef({});
|
|
22
23
|
const processor = useMemo(() => new AnsiProcessor(), []);
|
|
23
24
|
const lines = processor.process(props.text);
|
|
25
|
+
const [showCopyInfo, setShowCopyInfo] = useState(false);
|
|
24
26
|
const search = useLogViewerSearch(lines);
|
|
25
27
|
const selection = useLogViewerSelection(lines);
|
|
26
28
|
const location = useLocation();
|
|
@@ -39,14 +41,28 @@ function RealLogViewer(props) {
|
|
|
39
41
|
listInstance.scrollToItem(lines.length - 1, "end");
|
|
40
42
|
}
|
|
41
43
|
}, [listInstance, search.resultLine, lines]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const hash = selection.getHash();
|
|
46
|
+
if (hash.length > 0) {
|
|
47
|
+
history.replaceState(null, "", hash);
|
|
48
|
+
}
|
|
49
|
+
}, [selection]);
|
|
42
50
|
useEffect(() => {
|
|
43
51
|
if (location.hash) {
|
|
44
|
-
|
|
45
|
-
selection.setSelection(line, false);
|
|
52
|
+
selection.selectAll(location.hash);
|
|
46
53
|
}
|
|
47
54
|
}, []);
|
|
48
55
|
const handleSelectLine = (line, event) => {
|
|
49
|
-
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
selection.setSelection(
|
|
58
|
+
line,
|
|
59
|
+
event.shiftKey,
|
|
60
|
+
event.metaKey || event.ctrlKey
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
const handleCopySelection = (line) => {
|
|
64
|
+
selection.copySelection(line);
|
|
65
|
+
setShowCopyInfo(true);
|
|
50
66
|
};
|
|
51
67
|
function setRowHeight(index, size) {
|
|
52
68
|
if (shouldTextWrap && listInstance) {
|
|
@@ -57,78 +73,90 @@ function RealLogViewer(props) {
|
|
|
57
73
|
function getRowHeight(index) {
|
|
58
74
|
return heights.current[index] || 20;
|
|
59
75
|
}
|
|
60
|
-
return /* @__PURE__ */
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
76
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
77
|
+
/* @__PURE__ */ jsx(AutoSizer, { children: ({ height, width }) => {
|
|
78
|
+
const commonProps = {
|
|
79
|
+
ref: setListInstance,
|
|
80
|
+
className: classes.log,
|
|
81
|
+
height: (height || 480) - HEADER_SIZE,
|
|
82
|
+
width: width || 640,
|
|
83
|
+
itemData: search.lines,
|
|
84
|
+
itemCount: search.lines.length
|
|
85
|
+
};
|
|
86
|
+
const renderItem = ({
|
|
87
|
+
index,
|
|
88
|
+
style,
|
|
89
|
+
data
|
|
90
|
+
}) => {
|
|
91
|
+
const line = data[index];
|
|
92
|
+
const { lineNumber } = line;
|
|
93
|
+
return /* @__PURE__ */ jsxs(
|
|
94
|
+
Box,
|
|
95
|
+
{
|
|
96
|
+
style: { ...style },
|
|
97
|
+
className: classNames(classes.line, {
|
|
98
|
+
[classes.lineSelected]: selection.isSelected(lineNumber)
|
|
99
|
+
}),
|
|
100
|
+
children: [
|
|
101
|
+
selection.shouldShowCopyButton(lineNumber) && /* @__PURE__ */ jsx(
|
|
102
|
+
IconButton,
|
|
103
|
+
{
|
|
104
|
+
"data-testid": "copy-button",
|
|
105
|
+
size: "small",
|
|
106
|
+
className: classes.lineCopyButton,
|
|
107
|
+
onClick: () => handleCopySelection(lineNumber),
|
|
108
|
+
children: /* @__PURE__ */ jsx(CopyIcon, { fontSize: "inherit" })
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ jsx(
|
|
112
|
+
"a",
|
|
113
|
+
{
|
|
114
|
+
role: "row",
|
|
115
|
+
target: "_self",
|
|
116
|
+
href: `#line-${lineNumber}`,
|
|
117
|
+
className: classes.lineNumber,
|
|
118
|
+
onClick: (event) => handleSelectLine(lineNumber, event),
|
|
119
|
+
onKeyPress: (event) => handleSelectLine(lineNumber, event),
|
|
120
|
+
children: lineNumber
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ jsx(
|
|
124
|
+
LogLine,
|
|
125
|
+
{
|
|
126
|
+
setRowHeight: shouldTextWrap ? setRowHeight : void 0,
|
|
127
|
+
line,
|
|
128
|
+
classes,
|
|
129
|
+
searchText: search.searchText,
|
|
130
|
+
highlightResultIndex: search.resultLine === lineNumber ? search.resultLineIndex : void 0
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
return /* @__PURE__ */ jsxs(Box, { style: { width, height }, className: classes.root, children: [
|
|
138
|
+
/* @__PURE__ */ jsx(Box, { className: classes.header, children: /* @__PURE__ */ jsx(LogViewerControls, { ...search }) }),
|
|
139
|
+
shouldTextWrap ? /* @__PURE__ */ jsx(
|
|
140
|
+
VariableSizeList,
|
|
141
|
+
{
|
|
142
|
+
...commonProps,
|
|
143
|
+
itemSize: getRowHeight,
|
|
144
|
+
children: renderItem
|
|
145
|
+
}
|
|
146
|
+
) : /* @__PURE__ */ jsx(FixedSizeList, { ...commonProps, itemSize: 20, children: renderItem })
|
|
147
|
+
] });
|
|
148
|
+
} }),
|
|
149
|
+
/* @__PURE__ */ jsx(
|
|
150
|
+
Snackbar,
|
|
151
|
+
{
|
|
152
|
+
open: showCopyInfo,
|
|
153
|
+
autoHideDuration: 3e3,
|
|
154
|
+
onClose: () => setShowCopyInfo(false),
|
|
155
|
+
message: "Lines copied to clipboard",
|
|
156
|
+
anchorOrigin: { vertical: "bottom", horizontal: "center" }
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
] });
|
|
132
160
|
}
|
|
133
161
|
|
|
134
162
|
export { RealLogViewer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealLogViewer.esm.js","sources":["../../../src/components/LogViewer/RealLogViewer.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 */\n\nimport Box from '@material-ui/core/Box';\nimport IconButton from '@material-ui/core/IconButton';\nimport CopyIcon from '@material-ui/icons/FileCopy';\nimport classnames from 'classnames';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport AutoSizer from 'react-virtualized-auto-sizer';\nimport { VariableSizeList, FixedSizeList } from 'react-window';\n\nimport { AnsiLine, AnsiProcessor } from './AnsiProcessor';\nimport { LogLine } from './LogLine';\nimport { LogViewerControls } from './LogViewerControls';\nimport { HEADER_SIZE, useStyles } from './styles';\nimport { useLogViewerSearch } from './useLogViewerSearch';\nimport { useLogViewerSelection } from './useLogViewerSelection';\n\nexport interface RealLogViewerProps {\n text: string;\n textWrap?: boolean;\n classes?: { root?: string };\n}\n\nexport function RealLogViewer(props: RealLogViewerProps) {\n const classes = useStyles({ classes: props.classes });\n const [listInstance, setListInstance] = useState<\n VariableSizeList<AnsiLine[]> | FixedSizeList<AnsiLine[]> | null\n >(null);\n const shouldTextWrap = props.textWrap ?? false;\n const heights = useRef<{ [key: number]: number }>({});\n\n // The processor keeps state that optimizes appending to the text\n const processor = useMemo(() => new AnsiProcessor(), []);\n const lines = processor.process(props.text);\n\n const search = useLogViewerSearch(lines);\n const selection = useLogViewerSelection(lines);\n const location = useLocation();\n\n useEffect(() => {\n if (listInstance) {\n listInstance.scrollToItem(lines.length - 1, 'end');\n }\n }, [listInstance, lines]);\n\n useEffect(() => {\n if (!listInstance) {\n return;\n }\n if (search.resultLine) {\n listInstance.scrollToItem(search.resultLine - 1, 'center');\n } else {\n listInstance.scrollToItem(lines.length - 1, 'end');\n }\n }, [listInstance, search.resultLine, lines]);\n\n useEffect(() => {\n if (location.hash) {\n // #line-6 -> 6\n const line = parseInt(location.hash.replace(/\\D/g, ''), 10);\n selection.setSelection(line, false);\n }\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleSelectLine = (\n line: number,\n event: { shiftKey: boolean; preventDefault: () => void },\n ) => {\n selection.setSelection(line, event.shiftKey);\n };\n\n function setRowHeight(index: number, size: number) {\n if (shouldTextWrap && listInstance) {\n (listInstance as VariableSizeList<AnsiLine[]>).resetAfterIndex(0);\n // lineNumber is 1-based but index is 0-based\n heights.current[index - 1] = size;\n }\n }\n\n function getRowHeight(index: number) {\n return heights.current[index] || 20;\n }\n\n return (\n <AutoSizer>\n {({ height, width }: { height?: number; width?: number }) => {\n const commonProps = {\n ref: setListInstance,\n className: classes.log,\n height: (height || 480) - HEADER_SIZE,\n width: width || 640,\n itemData: search.lines,\n itemCount: search.lines.length,\n };\n\n const renderItem = ({\n index,\n style,\n data,\n }: {\n index: number;\n style: React.CSSProperties;\n data: AnsiLine[];\n }) => {\n const line = data[index];\n const { lineNumber } = line;\n return (\n <Box\n style={{ ...style }}\n className={classnames(classes.line, {\n [classes.lineSelected]: selection.isSelected(lineNumber),\n })}\n >\n {selection.shouldShowButton(lineNumber) && (\n <IconButton\n data-testid=\"copy-button\"\n size=\"small\"\n className={classes.lineCopyButton}\n onClick={() => selection.copySelection()}\n >\n <CopyIcon fontSize=\"inherit\" />\n </IconButton>\n )}\n <a\n role=\"row\"\n target=\"_self\"\n href={`#line-${lineNumber}`}\n className={classes.lineNumber}\n onClick={event => handleSelectLine(lineNumber, event)}\n onKeyPress={event => handleSelectLine(lineNumber, event)}\n >\n {lineNumber}\n </a>\n <LogLine\n setRowHeight={shouldTextWrap ? setRowHeight : undefined}\n line={line}\n classes={classes}\n searchText={search.searchText}\n highlightResultIndex={\n search.resultLine === lineNumber\n ? search.resultLineIndex\n : undefined\n }\n />\n </Box>\n );\n };\n\n return (\n <Box style={{ width, height }} className={classes.root}>\n <Box className={classes.header}>\n <LogViewerControls {...search} />\n </Box>\n {shouldTextWrap ? (\n <VariableSizeList<AnsiLine[]>\n {...commonProps}\n itemSize={getRowHeight}\n >\n {renderItem}\n </VariableSizeList>\n ) : (\n <FixedSizeList<AnsiLine[]> {...commonProps} itemSize={20}>\n {renderItem}\n </FixedSizeList>\n )}\n </Box>\n );\n }}\n </AutoSizer>\n );\n}\n"],"names":["classnames"],"mappings":";;;;;;;;;;;;;;;;AAsCO,SAAS,cAAc,KAAA,EAA2B;AACvD,EAAA,MAAM,UAAU,SAAA,CAAU,EAAE,OAAA,EAAS,KAAA,CAAM,SAAS,CAAA;AACpD,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,SAEtC,IAAI,CAAA;AACN,EAAA,MAAM,cAAA,GAAiB,MAAM,QAAA,IAAY,KAAA;AACzC,EAAA,MAAM,OAAA,GAAU,MAAA,CAAkC,EAAE,CAAA;AAGpD,EAAA,MAAM,YAAY,OAAA,CAAQ,MAAM,IAAI,aAAA,EAAc,EAAG,EAAE,CAAA;AACvD,EAAA,MAAM,KAAA,GAAQ,SAAA,CAAU,OAAA,CAAQ,KAAA,CAAM,IAAI,CAAA;AAE1C,EAAA,MAAM,MAAA,GAAS,mBAAmB,KAAK,CAAA;AACvC,EAAA,MAAM,SAAA,GAAY,sBAAsB,KAAK,CAAA;AAC7C,EAAA,MAAM,WAAW,WAAA,EAAY;AAE7B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,YAAA,EAAc;AAChB,MAAA,YAAA,CAAa,YAAA,CAAa,KAAA,CAAM,MAAA,GAAS,CAAA,EAAG,KAAK,CAAA;AAAA,IACnD;AAAA,EACF,CAAA,EAAG,CAAC,YAAA,EAAc,KAAK,CAAC,CAAA;AAExB,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,YAAA,EAAc;AACjB,MAAA;AAAA,IACF;AACA,IAAA,IAAI,OAAO,UAAA,EAAY;AACrB,MAAA,YAAA,CAAa,YAAA,CAAa,MAAA,CAAO,UAAA,GAAa,CAAA,EAAG,Q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KAAA,KAAS,gBAAA,CAAiB,UAAA,EAAY,KAAK,CAAA;AAAA,gBAEtD,QAAA,EAAA;AAAA;AAAA,aACH;AAAA,4BACA,GAAA;AAAA,cAAC,OAAA;AAAA,cAAA;AAAA,gBACC,YAAA,EAAc,iBAAiB,YAAA,GAAe,MAAA;AAAA,gBAC9C,IAAA;AAAA,gBACA,OAAA;AAAA,gBACA,YAAY,MAAA,CAAO,UAAA;AAAA,gBACnB,oBAAA,EACE,MAAA,CAAO,UAAA,KAAe,UAAA,GAClB,OAAO,eAAA,GACP;AAAA;AAAA;AAER;AAAA;AAAA,OACF;AAAA,IAEJ,CAAA;AAEA,IAAA,uBACE,IAAA,CAAC,OAAI,KAAA,EAAO,EAAE,OAAO,MAAA,EAAO,EAAG,SAAA,EAAW,OAAA,CAAQ,IAAA,EAChD,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,GAAA,EAAA,EAAI,WAAW,OAAA,CAAQ,MAAA,EACtB,8BAAC,iBAAA,EAAA,EAAmB,GAAG,QAAQ,CAAA,EACjC,CAAA;AAAA,MACC,cAAA,mBACC,GAAA;AAAA,QAAC,gBAAA;AAAA,QAAA;AAAA,UACE,GAAG,WAAA;AAAA,UACJ,QAAA,EAAU,YAAA;AAAA,UAET,QAAA,EAAA;AAAA;AAAA,0BAGH,GAAA,CAAC,aAAA,EAAA,EAA2B,GAAG,WAAA,EAAa,QAAA,EAAU,IACnD,QAAA,EAAA,UAAA,EACH;AAAA,KAAA,EAEJ,CAAA;AAAA,EAEJ,CAAA,EACF,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"RealLogViewer.esm.js","sources":["../../../src/components/LogViewer/RealLogViewer.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 */\n\nimport Box from '@material-ui/core/Box';\nimport IconButton from '@material-ui/core/IconButton';\nimport CopyIcon from '@material-ui/icons/FileCopy';\nimport classnames from 'classnames';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport AutoSizer from 'react-virtualized-auto-sizer';\nimport { FixedSizeList, VariableSizeList } from 'react-window';\n\nimport { AnsiLine, AnsiProcessor } from './AnsiProcessor';\nimport { LogLine } from './LogLine';\nimport { LogViewerControls } from './LogViewerControls';\nimport { HEADER_SIZE, useStyles } from './styles';\nimport { useLogViewerSearch } from './useLogViewerSearch';\nimport { useLogViewerSelection } from './useLogViewerSelection';\nimport Snackbar from '@material-ui/core/Snackbar';\n\nexport interface RealLogViewerProps {\n text: string;\n textWrap?: boolean;\n classes?: { root?: string };\n}\n\nexport function RealLogViewer(props: RealLogViewerProps) {\n const classes = useStyles({ classes: props.classes });\n const [listInstance, setListInstance] = useState<\n VariableSizeList<AnsiLine[]> | FixedSizeList<AnsiLine[]> | null\n >(null);\n const shouldTextWrap = props.textWrap ?? false;\n const heights = useRef<{ [key: number]: number }>({});\n\n // The processor keeps state that optimizes appending to the text\n const processor = useMemo(() => new AnsiProcessor(), []);\n const lines = processor.process(props.text);\n const [showCopyInfo, setShowCopyInfo] = useState(false);\n\n const search = useLogViewerSearch(lines);\n const selection = useLogViewerSelection(lines);\n const location = useLocation();\n\n useEffect(() => {\n if (listInstance) {\n listInstance.scrollToItem(lines.length - 1, 'end');\n }\n }, [listInstance, lines]);\n\n useEffect(() => {\n if (!listInstance) {\n return;\n }\n if (search.resultLine) {\n listInstance.scrollToItem(search.resultLine - 1, 'center');\n } else {\n listInstance.scrollToItem(lines.length - 1, 'end');\n }\n }, [listInstance, search.resultLine, lines]);\n\n useEffect(() => {\n const hash = selection.getHash();\n if (hash.length > 0) {\n history.replaceState(null, '', hash);\n }\n }, [selection]);\n\n useEffect(() => {\n if (location.hash) {\n selection.selectAll(location.hash);\n }\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleSelectLine = (\n line: number,\n event: {\n shiftKey: boolean;\n metaKey: boolean;\n ctrlKey: boolean;\n preventDefault: () => void;\n },\n ) => {\n event.preventDefault();\n selection.setSelection(\n line,\n event.shiftKey,\n event.metaKey || event.ctrlKey,\n );\n };\n\n const handleCopySelection = (line: number) => {\n selection.copySelection(line);\n setShowCopyInfo(true);\n };\n\n function setRowHeight(index: number, size: number) {\n if (shouldTextWrap && listInstance) {\n (listInstance as VariableSizeList<AnsiLine[]>).resetAfterIndex(0);\n // lineNumber is 1-based but index is 0-based\n heights.current[index - 1] = size;\n }\n }\n\n function getRowHeight(index: number) {\n return heights.current[index] || 20;\n }\n\n return (\n <>\n <AutoSizer>\n {({ height, width }: { height?: number; width?: number }) => {\n const commonProps = {\n ref: setListInstance,\n className: classes.log,\n height: (height || 480) - HEADER_SIZE,\n width: width || 640,\n itemData: search.lines,\n itemCount: search.lines.length,\n };\n\n const renderItem = ({\n index,\n style,\n data,\n }: {\n index: number;\n style: React.CSSProperties;\n data: AnsiLine[];\n }) => {\n const line = data[index];\n const { lineNumber } = line;\n return (\n <Box\n style={{ ...style }}\n className={classnames(classes.line, {\n [classes.lineSelected]: selection.isSelected(lineNumber),\n })}\n >\n {selection.shouldShowCopyButton(lineNumber) && (\n <IconButton\n data-testid=\"copy-button\"\n size=\"small\"\n className={classes.lineCopyButton}\n onClick={() => handleCopySelection(lineNumber)}\n >\n <CopyIcon fontSize=\"inherit\" />\n </IconButton>\n )}\n <a\n role=\"row\"\n target=\"_self\"\n href={`#line-${lineNumber}`}\n className={classes.lineNumber}\n onClick={event => handleSelectLine(lineNumber, event)}\n onKeyPress={event => handleSelectLine(lineNumber, event)}\n >\n {lineNumber}\n </a>\n <LogLine\n setRowHeight={shouldTextWrap ? setRowHeight : undefined}\n line={line}\n classes={classes}\n searchText={search.searchText}\n highlightResultIndex={\n search.resultLine === lineNumber\n ? search.resultLineIndex\n : undefined\n }\n />\n </Box>\n );\n };\n\n return (\n <Box style={{ width, height }} className={classes.root}>\n <Box className={classes.header}>\n <LogViewerControls {...search} />\n </Box>\n {shouldTextWrap ? (\n <VariableSizeList<AnsiLine[]>\n {...commonProps}\n itemSize={getRowHeight}\n >\n {renderItem}\n </VariableSizeList>\n ) : (\n <FixedSizeList<AnsiLine[]> {...commonProps} itemSize={20}>\n {renderItem}\n </FixedSizeList>\n )}\n </Box>\n );\n }}\n </AutoSizer>\n <Snackbar\n open={showCopyInfo}\n autoHideDuration={3000}\n onClose={() => setShowCopyInfo(false)}\n message=\"Lines copied to clipboard\"\n anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}\n />\n </>\n );\n}\n"],"names":["classnames"],"mappings":";;;;;;;;;;;;;;;;;AAuCO,SAAS,cAAc,KAAA,EAA2B;AACvD,EAAA,MAAM,UAAU,SAAA,CAAU,EAAE,OAAA,EAAS,KAAA,CAAM,SAAS,CAAA;AACpD,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,SAEtC,IAAI,CAAA;AACN,EAAA,MAAM,cAAA,GAAiB,MAAM,QAAA,IAAY,KAAA;AACzC,EAAA,MAAM,OAAA,GAAU,MAAA,CAAkC,EAAE,CAAA;AAGpD,EAAA,MAAM,YAAY,OAAA,CAAQ,MAAM,IAAI,aAAA,EAAc,EAAG,EAAE,CAAA;AACvD,EAAA,MAAM,KAAA,GAAQ,SAAA,CAAU,OAAA,CAAQ,KAAA,CAAM,IAAI,CAAA;AAC1C,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,SAAS,KAAK,CAAA;AAEtD,EAAA,MAAM,MAAA,GAAS,mBAAmB,KAAK,CAAA;AACvC,EAAA,MAAM,SAAA,GAAY,sBAAsB,KAAK,CAAA;AAC7C,EAAA,MAAM,WAAW,WAAA,E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;AAAA;AAAA;AAER;AAAA;AAAA,SACF;AAAA,MAEJ,CAAA;AAEA,MAAA,uBACE,IAAA,CAAC,OAAI,KAAA,EAAO,EAAE,OAAO,MAAA,EAAO,EAAG,SAAA,EAAW,OAAA,CAAQ,IAAA,EAChD,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,GAAA,EAAA,EAAI,WAAW,OAAA,CAAQ,MAAA,EACtB,8BAAC,iBAAA,EAAA,EAAmB,GAAG,QAAQ,CAAA,EACjC,CAAA;AAAA,QACC,cAAA,mBACC,GAAA;AAAA,UAAC,gBAAA;AAAA,UAAA;AAAA,YACE,GAAG,WAAA;AAAA,YACJ,QAAA,EAAU,YAAA;AAAA,YAET,QAAA,EAAA;AAAA;AAAA,4BAGH,GAAA,CAAC,aAAA,EAAA,EAA2B,GAAG,WAAA,EAAa,QAAA,EAAU,IACnD,QAAA,EAAA,UAAA,EACH;AAAA,OAAA,EAEJ,CAAA;AAAA,IAEJ,CAAA,EACF,CAAA;AAAA,oBACA,GAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACC,IAAA,EAAM,YAAA;AAAA,QACN,gBAAA,EAAkB,GAAA;AAAA,QAClB,OAAA,EAAS,MAAM,eAAA,CAAgB,KAAK,CAAA;AAAA,QACpC,OAAA,EAAQ,2BAAA;AAAA,QACR,YAAA,EAAc,EAAE,QAAA,EAAU,QAAA,EAAU,YAAY,QAAA;AAAS;AAAA;AAC3D,GAAA,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -36,16 +36,21 @@ const useStyles = makeStyles(
|
|
|
36
36
|
lineCopyButton: {
|
|
37
37
|
position: "absolute",
|
|
38
38
|
paddingTop: 0,
|
|
39
|
-
paddingBottom: 0
|
|
39
|
+
paddingBottom: 0,
|
|
40
|
+
"&:hover": {
|
|
41
|
+
color: theme.palette.linkHover
|
|
42
|
+
}
|
|
40
43
|
},
|
|
41
44
|
lineNumber: {
|
|
42
45
|
display: "inline-block",
|
|
43
46
|
textAlign: "end",
|
|
44
47
|
width: 60,
|
|
48
|
+
paddingRight: theme.spacing(1),
|
|
45
49
|
marginRight: theme.spacing(1),
|
|
46
50
|
cursor: "pointer",
|
|
47
51
|
flexShrink: 0,
|
|
48
|
-
|
|
52
|
+
color: colors.blue[300],
|
|
53
|
+
borderRight: `1px solid ${colors.blue[700]}`
|
|
49
54
|
},
|
|
50
55
|
textHighlight: {
|
|
51
56
|
background: alpha(theme.palette.info.main, 0.15)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.esm.js","sources":["../../../src/components/LogViewer/styles.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 { alpha, makeStyles } from '@material-ui/core/styles';\nimport * as colors from '@material-ui/core/colors';\n\nexport const HEADER_SIZE = 40;\n\n/** @public Class keys for overriding LogViewer styles */\nexport type LogViewerClassKey =\n | 'root'\n | 'header'\n | 'log'\n | 'line'\n | 'lineSelected'\n | 'lineCopyButton'\n | 'lineNumber'\n | 'textHighlight'\n | 'textSelectedHighlight'\n | 'modifierBold'\n | 'modifierItalic'\n | 'modifierUnderline'\n | 'modifierForegroundBlack'\n | 'modifierForegroundRed'\n | 'modifierForegroundGreen'\n | 'modifierForegroundYellow'\n | 'modifierForegroundBlue'\n | 'modifierForegroundMagenta'\n | 'modifierForegroundCyan'\n | 'modifierForegroundWhite'\n | 'modifierForegroundGrey'\n | 'modifierBackgroundBlack'\n | 'modifierBackgroundRed'\n | 'modifierBackgroundGreen'\n | 'modifierBackgroundYellow'\n | 'modifierBackgroundBlue'\n | 'modifierBackgroundMagenta'\n | 'modifierBackgroundCyan'\n | 'modifierBackgroundWhite'\n | 'modifierBackgroundGrey';\n\nexport const useStyles = makeStyles(\n theme => ({\n root: {\n background: theme.palette.background.paper,\n },\n header: {\n height: HEADER_SIZE,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-end',\n },\n log: {\n fontFamily: '\"Monaco\", monospace',\n fontSize: theme.typography.pxToRem(12),\n lineHeight: '20px',\n },\n line: {\n position: 'relative',\n whiteSpace: 'pre',\n display: 'flex',\n alignItems: 'flex-start',\n\n '&:hover': {\n background: theme.palette.action.hover,\n },\n },\n lineSelected: {\n background: theme.palette.action.selected,\n\n '&:hover': {\n background: theme.palette.action.selected,\n },\n },\n lineCopyButton: {\n position: 'absolute',\n paddingTop: 0,\n paddingBottom: 0,\n },\n lineNumber: {\n display: 'inline-block',\n textAlign: 'end',\n width: 60,\n marginRight: theme.spacing(1),\n cursor: 'pointer',\n flexShrink: 0,\n
|
|
1
|
+
{"version":3,"file":"styles.esm.js","sources":["../../../src/components/LogViewer/styles.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 { alpha, makeStyles } from '@material-ui/core/styles';\nimport * as colors from '@material-ui/core/colors';\n\nexport const HEADER_SIZE = 40;\n\n/** @public Class keys for overriding LogViewer styles */\nexport type LogViewerClassKey =\n | 'root'\n | 'header'\n | 'log'\n | 'line'\n | 'lineSelected'\n | 'lineCopyButton'\n | 'lineNumber'\n | 'textHighlight'\n | 'textSelectedHighlight'\n | 'modifierBold'\n | 'modifierItalic'\n | 'modifierUnderline'\n | 'modifierForegroundBlack'\n | 'modifierForegroundRed'\n | 'modifierForegroundGreen'\n | 'modifierForegroundYellow'\n | 'modifierForegroundBlue'\n | 'modifierForegroundMagenta'\n | 'modifierForegroundCyan'\n | 'modifierForegroundWhite'\n | 'modifierForegroundGrey'\n | 'modifierBackgroundBlack'\n | 'modifierBackgroundRed'\n | 'modifierBackgroundGreen'\n | 'modifierBackgroundYellow'\n | 'modifierBackgroundBlue'\n | 'modifierBackgroundMagenta'\n | 'modifierBackgroundCyan'\n | 'modifierBackgroundWhite'\n | 'modifierBackgroundGrey';\n\nexport const useStyles = makeStyles(\n theme => ({\n root: {\n background: theme.palette.background.paper,\n },\n header: {\n height: HEADER_SIZE,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-end',\n },\n log: {\n fontFamily: '\"Monaco\", monospace',\n fontSize: theme.typography.pxToRem(12),\n lineHeight: '20px',\n },\n line: {\n position: 'relative',\n whiteSpace: 'pre',\n display: 'flex',\n alignItems: 'flex-start',\n\n '&:hover': {\n background: theme.palette.action.hover,\n },\n },\n lineSelected: {\n background: theme.palette.action.selected,\n\n '&:hover': {\n background: theme.palette.action.selected,\n },\n },\n lineCopyButton: {\n position: 'absolute',\n paddingTop: 0,\n paddingBottom: 0,\n '&:hover': {\n color: theme.palette.linkHover,\n },\n },\n lineNumber: {\n display: 'inline-block',\n textAlign: 'end',\n width: 60,\n paddingRight: theme.spacing(1),\n marginRight: theme.spacing(1),\n cursor: 'pointer',\n flexShrink: 0,\n color: colors.blue[300],\n borderRight: `1px solid ${colors.blue[700]}`,\n },\n textHighlight: {\n background: alpha(theme.palette.info.main, 0.15),\n },\n textSelectedHighlight: {\n background: alpha(theme.palette.info.main, 0.4),\n },\n modifierBold: {\n fontWeight: theme.typography.fontWeightBold,\n },\n modifierItalic: {\n fontStyle: 'italic',\n },\n modifierUnderline: {\n textDecoration: 'underline',\n },\n modifierForegroundBlack: {\n color: colors.common.black,\n },\n modifierForegroundRed: {\n color: colors.red[500],\n },\n modifierForegroundGreen: {\n color: colors.green[500],\n },\n modifierForegroundYellow: {\n color: colors.yellow[500],\n },\n modifierForegroundBlue: {\n color: colors.blue[500],\n },\n modifierForegroundMagenta: {\n color: colors.purple[500],\n },\n modifierForegroundCyan: {\n color: colors.cyan[500],\n },\n modifierForegroundWhite: {\n color: colors.common.white,\n },\n modifierForegroundGrey: {\n color: colors.grey[500],\n },\n modifierBackgroundBlack: {\n background: colors.common.black,\n },\n modifierBackgroundRed: {\n background: colors.red[500],\n },\n modifierBackgroundGreen: {\n background: colors.green[500],\n },\n modifierBackgroundYellow: {\n background: colors.yellow[500],\n },\n modifierBackgroundBlue: {\n background: colors.blue[500],\n },\n modifierBackgroundMagenta: {\n background: colors.purple[500],\n },\n modifierBackgroundCyan: {\n background: colors.cyan[500],\n },\n modifierBackgroundWhite: {\n background: colors.common.white,\n },\n modifierBackgroundGrey: {\n background: colors.grey[500],\n },\n textWrap: {\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-all',\n },\n }),\n { name: 'BackstageLogViewer' },\n);\n"],"names":[],"mappings":";;;AAmBO,MAAM,WAAA,GAAc;AAmCpB,MAAM,SAAA,GAAY,UAAA;AAAA,EACvB,CAAA,KAAA,MAAU;AAAA,IACR,IAAA,EAAM;AAAA,MACJ,UAAA,EAAY,KAAA,CAAM,OAAA,CAAQ,UAAA,CAAW;AAAA,KACvC;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,MAAA,EAAQ,WAAA;AAAA,MACR,OAAA,EAAS,MAAA;AAAA,MACT,UAAA,EAAY,QAAA;AAAA,MACZ,cAAA,EAAgB;AAAA,KAClB;AAAA,IACA,GAAA,EAAK;AAAA,MACH,UAAA,EAAY,qBAAA;AAAA,MACZ,QAAA,EAAU,KAAA,CAAM,UAAA,CAAW,OAAA,CAAQ,EAAE,CAAA;AAAA,MACrC,UAAA,EAAY;AAAA,KACd;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,QAAA,EAAU,UAAA;AAAA,MACV,U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AY,MAAA,CAAO,KAAA,CAAM,GAAG;AAAA,KAC9B;AAAA,IACA,wBAAA,EAA0B;AAAA,MACxB,UAAA,EAAY,MAAA,CAAO,MAAA,CAAO,GAAG;AAAA,KAC/B;AAAA,IACA,sBAAA,EAAwB;AAAA,MACtB,UAAA,EAAY,MAAA,CAAO,IAAA,CAAK,GAAG;AAAA,KAC7B;AAAA,IACA,yBAAA,EAA2B;AAAA,MACzB,UAAA,EAAY,MAAA,CAAO,MAAA,CAAO,GAAG;AAAA,KAC/B;AAAA,IACA,sBAAA,EAAwB;AAAA,MACtB,UAAA,EAAY,MAAA,CAAO,IAAA,CAAK,GAAG;AAAA,KAC7B;AAAA,IACA,uBAAA,EAAyB;AAAA,MACvB,UAAA,EAAY,OAAO,MAAA,CAAO;AAAA,KAC5B;AAAA,IACA,sBAAA,EAAwB;AAAA,MACtB,UAAA,EAAY,MAAA,CAAO,IAAA,CAAK,GAAG;AAAA,KAC7B;AAAA,IACA,QAAA,EAAU;AAAA,MACR,UAAA,EAAY,UAAA;AAAA,MACZ,SAAA,EAAW;AAAA;AACb,GACF,CAAA;AAAA,EACA,EAAE,MAAM,oBAAA;AACV;;;;"}
|
|
@@ -4,42 +4,162 @@ import useCopyToClipboard from 'react-use/esm/useCopyToClipboard';
|
|
|
4
4
|
|
|
5
5
|
function useLogViewerSelection(lines) {
|
|
6
6
|
const errorApi = useApi(errorApiRef);
|
|
7
|
-
const [
|
|
8
|
-
const start = sel ? Math.min(sel.start, sel.end) : void 0;
|
|
9
|
-
const end = sel ? Math.max(sel.start, sel.end) : void 0;
|
|
7
|
+
const [selections, setSelections] = useState([]);
|
|
10
8
|
const [{ error }, copyToClipboard] = useCopyToClipboard();
|
|
11
9
|
useEffect(() => {
|
|
12
10
|
if (error) {
|
|
13
11
|
errorApi.post(error);
|
|
14
12
|
}
|
|
15
13
|
}, [error, errorApi]);
|
|
14
|
+
const findClosestSelection = (allSelections, line) => {
|
|
15
|
+
if (selections.length === 0) {
|
|
16
|
+
return void 0;
|
|
17
|
+
}
|
|
18
|
+
let minDistance = Number.MAX_SAFE_INTEGER;
|
|
19
|
+
let closestSelection = void 0;
|
|
20
|
+
allSelections.forEach((s) => {
|
|
21
|
+
const distance = Math.min(
|
|
22
|
+
Math.abs(s.start - line),
|
|
23
|
+
Math.abs(s.end - line)
|
|
24
|
+
);
|
|
25
|
+
if (distance < minDistance) {
|
|
26
|
+
minDistance = distance;
|
|
27
|
+
closestSelection = s;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return closestSelection;
|
|
31
|
+
};
|
|
32
|
+
const mergeNeighbouringSelections = (allSelections, line) => {
|
|
33
|
+
const neighboringSelections = allSelections.filter(
|
|
34
|
+
(s) => s.start - 1 === line || s.end + 1 === line
|
|
35
|
+
);
|
|
36
|
+
if (neighboringSelections.length === 0) {
|
|
37
|
+
return allSelections;
|
|
38
|
+
}
|
|
39
|
+
const newSelection = {
|
|
40
|
+
start: Math.min(line, ...neighboringSelections.map((s) => s.start)),
|
|
41
|
+
end: Math.max(line, ...neighboringSelections.map((s) => s.end))
|
|
42
|
+
};
|
|
43
|
+
return [
|
|
44
|
+
...allSelections.filter(
|
|
45
|
+
(s) => !neighboringSelections.includes(s) && !(s.start === line && s.end === line)
|
|
46
|
+
),
|
|
47
|
+
newSelection
|
|
48
|
+
];
|
|
49
|
+
};
|
|
16
50
|
return {
|
|
17
|
-
|
|
18
|
-
return
|
|
51
|
+
shouldShowCopyButton(line) {
|
|
52
|
+
return selections.some((s) => s.start === line);
|
|
19
53
|
},
|
|
20
54
|
isSelected(line) {
|
|
21
|
-
if (!
|
|
55
|
+
if (!selections) {
|
|
22
56
|
return false;
|
|
23
57
|
}
|
|
24
|
-
return
|
|
58
|
+
return selections.some(
|
|
59
|
+
(s) => s.start <= line && (s.end ?? s.start) >= line
|
|
60
|
+
);
|
|
25
61
|
},
|
|
26
|
-
setSelection(line,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
(s) => s
|
|
62
|
+
setSelection(line, addRange, addNewSelection) {
|
|
63
|
+
setSelections((currentSelections) => {
|
|
64
|
+
const clickedSelection = currentSelections.find(
|
|
65
|
+
(s) => s.start <= line && s.end >= line
|
|
30
66
|
);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(s) => s?.start === line && s?.end === line ? void 0 : { start: line, end: line }
|
|
67
|
+
const otherSelections = currentSelections.filter(
|
|
68
|
+
(s) => s !== clickedSelection
|
|
34
69
|
);
|
|
70
|
+
if (!addRange && !addNewSelection) {
|
|
71
|
+
if (!clickedSelection || clickedSelection.start !== clickedSelection.end) {
|
|
72
|
+
return [{ start: line, end: line }];
|
|
73
|
+
}
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
if (addRange) {
|
|
77
|
+
if (currentSelections.length === 0) {
|
|
78
|
+
return [{ start: line, end: line }];
|
|
79
|
+
}
|
|
80
|
+
if (clickedSelection) {
|
|
81
|
+
if (clickedSelection.start === clickedSelection.end) {
|
|
82
|
+
return otherSelections;
|
|
83
|
+
}
|
|
84
|
+
return [
|
|
85
|
+
...otherSelections,
|
|
86
|
+
{ start: clickedSelection.start, end: line }
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
const closestSelection = findClosestSelection(
|
|
90
|
+
currentSelections,
|
|
91
|
+
line
|
|
92
|
+
);
|
|
93
|
+
if (!closestSelection) {
|
|
94
|
+
return currentSelections;
|
|
95
|
+
}
|
|
96
|
+
if (closestSelection.start < line) {
|
|
97
|
+
return mergeNeighbouringSelections(
|
|
98
|
+
[
|
|
99
|
+
...otherSelections.filter((s) => s !== closestSelection),
|
|
100
|
+
{ start: closestSelection.start, end: line }
|
|
101
|
+
],
|
|
102
|
+
line
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return mergeNeighbouringSelections(
|
|
106
|
+
[
|
|
107
|
+
...otherSelections.filter((s) => s !== closestSelection),
|
|
108
|
+
{ start: line, end: closestSelection.end }
|
|
109
|
+
],
|
|
110
|
+
line
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
if (addNewSelection) {
|
|
114
|
+
if (!clickedSelection) {
|
|
115
|
+
return mergeNeighbouringSelections(
|
|
116
|
+
[...currentSelections, { start: line, end: line }],
|
|
117
|
+
line
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
if (clickedSelection.start === clickedSelection.end) {
|
|
121
|
+
return otherSelections;
|
|
122
|
+
}
|
|
123
|
+
return [
|
|
124
|
+
...otherSelections,
|
|
125
|
+
...clickedSelection.start < line ? [{ start: clickedSelection.start, end: line - 1 }] : [],
|
|
126
|
+
...clickedSelection.end > line ? [{ start: line + 1, end: clickedSelection.end }] : []
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
return [];
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
copySelection(line) {
|
|
133
|
+
const selection = selections.find((s) => s.start === line);
|
|
134
|
+
if (!selection) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const copyText = lines.slice(selection.start - 1, selection.end).map((l) => l.chunks.map((c) => c.text).join("")).join("\n");
|
|
138
|
+
copyToClipboard(copyText);
|
|
139
|
+
},
|
|
140
|
+
getHash() {
|
|
141
|
+
if (selections.length === 0) {
|
|
142
|
+
return "";
|
|
35
143
|
}
|
|
144
|
+
const parts = selections.map((s) => {
|
|
145
|
+
if (s.start === s.end) {
|
|
146
|
+
return `${s.start}`;
|
|
147
|
+
}
|
|
148
|
+
return `${s.start}-${s.end}`;
|
|
149
|
+
});
|
|
150
|
+
return `#lines-${parts.join(",")}`;
|
|
36
151
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
152
|
+
selectAll(hash) {
|
|
153
|
+
const match = hash.match(/#lines-([\d,-]+)/);
|
|
154
|
+
const s = [];
|
|
155
|
+
if (match) {
|
|
156
|
+
const ranges = match[1].split(",");
|
|
157
|
+
ranges.forEach((r) => {
|
|
158
|
+
const [start, end] = r.split("-").map(Number);
|
|
159
|
+
s.push({ start, end: end ?? start });
|
|
160
|
+
});
|
|
42
161
|
}
|
|
162
|
+
setSelections(s);
|
|
43
163
|
}
|
|
44
164
|
};
|
|
45
165
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLogViewerSelection.esm.js","sources":["../../../src/components/LogViewer/useLogViewerSelection.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 */\n\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useEffect, useState } from 'react';\nimport useCopyToClipboard from 'react-use/esm/useCopyToClipboard';\nimport { AnsiLine } from './AnsiProcessor';\n\nexport function useLogViewerSelection(lines: AnsiLine[]) {\n const errorApi = useApi(errorApiRef);\n const [sel, setSelection] = useState<{ start: number; end: number }>();\n const start = sel ? Math.min(sel.start, sel.end) : undefined;\n const end = sel ? Math.max(sel.start, sel.end) : undefined;\n\n const [{ error }, copyToClipboard] = useCopyToClipboard();\n\n useEffect(() => {\n if (error) {\n errorApi.post(error);\n }\n }, [error, errorApi]);\n\n return {\n shouldShowButton(line: number) {\n return start === line || end === line;\n },\n isSelected(line: number) {\n if (!sel) {\n return false;\n }\n return start! <= line && line <= end!;\n },\n setSelection(line: number, add: boolean) {\n if (add) {\n setSelection(s =>\n s ? { start: s.start, end: line } : { start: line, end: line },\n );\n } else {\n setSelection(s =>\n s?.start === line && s?.end === line\n ? undefined\n : { start: line, end: line },\n );\n }\n },\n copySelection() {\n if (sel) {\n const copyText = lines\n .slice(Math.min(sel.start, sel.end) - 1, Math.max(sel.start, sel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GAAI,EAAE,KAAA,EAAO,IAAA,EAAM,KAAK,IAAA;AAAK,SAC/D;AAAA,MACF,CAAA,MAAO;AACL,QAAA,YAAA;AAAA,UAAa,CAAA,CAAA,KACX,CAAA,EAAG,KAAA,KAAU,IAAA,IAAQ,CAAA,EAAG,GAAA,KAAQ,IAAA,GAC5B,MAAA,GACA,EAAE,KAAA,EAAO,IAAA,EAAM,GAAA,EAAK,IAAA;AAAK,SAC/B;AAAA,MACF;AAAA,IACF,CAAA;AAAA,IACA,aAAA,GAAgB;AACd,MAAA,IAAI,GAAA,EAAK;AACP,QAAA,MAAM,QAAA,GAAW,KAAA,CACd,KAAA,CAAM,IAAA,CAAK,IAAI,GAAA,CAAI,KAAA,EAAO,GAAA,CAAI,GAAG,CAAA,GAAI,CAAA,EAAG,IAAA,CAAK,GAAA,CAAI,IAAI,KAAA,EAAO,GAAA,CAAI,GAAG,CAAC,CAAA,CACpE,GAAA,CAAI,CAAA,CAAA,KAAK,CAAA,CAAE,OAAO,GAAA,CAAI,CAAA,CAAA,KAAK,CAAA,CAAE,IAAI,EAAE,IAAA,CAAK,EAAE,CAAC,CAAA,CAC3C,KAAK,IAAI,CAAA;AACZ,QAAA,eAAA,CAAgB,QAAQ,CAAA;AACxB,QAAA,YAAA,CAAa,MAAS,CAAA;AAAA,MACxB;AAAA,IACF;AAAA,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useLogViewerSelection.esm.js","sources":["../../../src/components/LogViewer/useLogViewerSelection.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 */\n\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useEffect, useState } from 'react';\nimport useCopyToClipboard from 'react-use/esm/useCopyToClipboard';\nimport { AnsiLine } from './AnsiProcessor';\n\ntype Selection = {\n start: number;\n end: number;\n};\n\nexport function useLogViewerSelection(lines: AnsiLine[]) {\n const errorApi = useApi(errorApiRef);\n const [selections, setSelections] = useState<Selection[]>([]);\n\n const [{ error }, copyToClipboard] = useCopyToClipboard();\n\n useEffect(() => {\n if (error) {\n errorApi.post(error);\n }\n }, [error, errorApi]);\n\n const findClosestSelection = (\n allSelections: Selection[],\n line: number,\n ): Selection | undefined => {\n if (selections.length === 0) {\n return undefined;\n }\n let minDistance = Number.MAX_SAFE_INTEGER;\n let closestSelection: Selection | undefined = undefined;\n\n allSelections.forEach(s => {\n const distance = Math.min(\n Math.abs(s.start - line),\n Math.abs(s.end - line),\n );\n if (distance < minDistance) {\n minDistance = distance;\n closestSelection = s;\n }\n });\n\n return closestSelection;\n };\n\n const mergeNeighbouringSelections = (\n allSelections: Selection[],\n line: number,\n ): Selection[] => {\n // Merge selections if they're next to each other\n const neighboringSelections = allSelections.filter(\n s => s.start - 1 === line || s.end + 1 === line,\n );\n if (neighboringSelections.length === 0) {\n return allSelections;\n }\n const newSelection = {\n start: Math.min(line, ...neighboringSelections.map(s => s.start)),\n end: Math.max(line, ...neighboringSelections.map(s => s.end)),\n };\n\n return [\n ...allSelections.filter(\n s =>\n !neighboringSelections.includes(s) &&\n !(s.start === line && s.end === line),\n ),\n newSelection,\n ];\n };\n\n return {\n shouldShowCopyButton(line: number) {\n // show copy button at the beginning of each selection\n return selections.some(s => s.start === line);\n },\n isSelected(line: number) {\n if (!selections) {\n return false;\n }\n // check if line is in any selection range\n return selections.some(\n s => s.start <= line && (s.end ?? s.start) >= line,\n );\n },\n setSelection(line: number, addRange: boolean, addNewSelection: boolean) {\n setSelections(currentSelections => {\n const clickedSelection = currentSelections.find(\n s => s.start <= line && s.end >= line,\n );\n const otherSelections = currentSelections.filter(\n s => s !== clickedSelection,\n );\n\n if (!addRange && !addNewSelection) {\n // Normal click -> select only this line if nothing or multiple lines are selected\n if (\n !clickedSelection ||\n clickedSelection.start !== clickedSelection.end\n ) {\n return [{ start: line, end: line }];\n }\n // Clear selection if single line is selected\n return [];\n }\n\n if (addRange) {\n // Shift+click -> extend/reduce selection\n if (currentSelections.length === 0) {\n // No existing selection -> create new selection\n return [{ start: line, end: line }];\n }\n\n if (clickedSelection) {\n // Clicked inside an existing selection -> reduce selection\n if (clickedSelection.start === clickedSelection.end) {\n // Single line selection -> remove it\n return otherSelections;\n }\n // Reduce selection\n return [\n ...otherSelections,\n { start: clickedSelection.start, end: line },\n ];\n }\n\n // Extend the closest selection to the new line\n const closestSelection = findClosestSelection(\n currentSelections,\n line,\n );\n if (!closestSelection) {\n // Can't actually happen\n return currentSelections;\n }\n if (closestSelection.start < line) {\n // Add lines before the selection\n return mergeNeighbouringSelections(\n [\n ...otherSelections.filter(s => s !== closestSelection),\n { start: closestSelection.start, end: line },\n ],\n line,\n );\n }\n // Add lines after the selection\n return mergeNeighbouringSelections(\n [\n ...otherSelections.filter(s => s !== closestSelection),\n { start: line, end: closestSelection!.end },\n ],\n line,\n );\n }\n\n if (addNewSelection) {\n // Ctrl/Cmd+click -> add new selection\n if (!clickedSelection) {\n // Just add new selection\n return mergeNeighbouringSelections(\n [...currentSelections, { start: line, end: line }],\n line,\n );\n }\n if (clickedSelection.start === clickedSelection.end) {\n // Single line selection -> remove it\n return otherSelections;\n }\n // Multi line selection -> split it\n return [\n ...otherSelections,\n ...(clickedSelection.start < line\n ? [{ start: clickedSelection.start, end: line - 1 }]\n : []),\n ...(clickedSelection.end > line\n ? [{ start: line + 1, end: clickedSelection.end }]\n : []),\n ];\n }\n\n return [];\n });\n },\n copySelection(line: number) {\n const selection = selections.find(s => s.start === line);\n if (!selection) {\n return;\n }\n const copyText = lines\n .slice(selection.start - 1, selection.end)\n .map(l => l.chunks.map(c => c.text).join(''))\n .join('\\n');\n copyToClipboard(copyText);\n },\n getHash() {\n if (selections.length === 0) {\n return '';\n }\n const parts = selections.map(s => {\n if (s.start === s.end) {\n return `${s.start}`;\n }\n return `${s.start}-${s.end}`;\n });\n return `#lines-${parts.join(',')}`;\n },\n selectAll(hash: string) {\n const match = hash.match(/#lines-([\\d,-]+)/);\n const s: Selection[] = [];\n if (match) {\n const ranges = match[1].split(',');\n ranges.forEach(r => {\n const [start, end] = r.split('-').map(Number);\n s.push({ start, end: end ?? start });\n });\n }\n setSelections(s);\n },\n };\n}\n"],"names":[],"mappings":";;;;AA0BO,SAAS,sBAAsB,KAAA,EAAmB;AACvD,EAAA,MAAM,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,QAAA,CAAsB,EAAE,CAAA;AAE5D,EAAA,MAAM,CAAC,EAAE,KAAA,EAAM,EAAG,eAAe,IAAI,kBAAA,EAAmB;AAExD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,QAAA,CAAS,KAAK,KAAK,CAAA;AAAA,IACrB;AAAA,EACF,CAAA,EAAG,CAAC,KAAA,EAAO,QAAQ,CAAC,CAAA;AAEpB,EAAA,MAAM,oBAAA,GAAuB,CAC3B,aAAA,EACA,IAAA,KAC0B;AAC1B,IAAA,IAAI,UAAA,CAAW,WAAW,CAAA,EAAG;AAC3B,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,IAAI,cAAc,MAAA,CAAO,gBAAA;AACzB,IAAA,IAAI,gBAAA,GAA0C,MAAA;AAE9C,IAAA,aAAA,CAAc,QAAQ,CAAA,CAAA,KAAK;AACzB,MAAA,MAAM,WAAW,IAAA,CAAK,GAAA;AAAA,QACpB,IAAA,CAAK,GAAA,CAAI,CAAA,CAAE,KAAA,GAAQ,IAAI,CAAA;AAAA,QACvB,IAAA,CAAK,GAAA,CAAI,CAAA,CAAE,GAAA,GAAM,IAAI;A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CAAC,CAAA,CAAA;AAAA,IAClC,CAAA;AAAA,IACA,UAAU,IAAA,EAAc;AACtB,MAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,kBAAkB,CAAA;AAC3C,MAAA,MAAM,IAAiB,EAAC;AACxB,MAAA,IAAI,KAAA,EAAO;AACT,QAAA,MAAM,MAAA,GAAS,KAAA,CAAM,CAAC,CAAA,CAAE,MAAM,GAAG,CAAA;AACjC,QAAA,MAAA,CAAO,QAAQ,CAAA,CAAA,KAAK;AAClB,UAAA,MAAM,CAAC,OAAO,GAAG,CAAA,GAAI,EAAE,KAAA,CAAM,GAAG,CAAA,CAAE,GAAA,CAAI,MAAM,CAAA;AAC5C,UAAA,CAAA,CAAE,KAAK,EAAE,KAAA,EAAO,GAAA,EAAK,GAAA,IAAO,OAAO,CAAA;AAAA,QACrC,CAAC,CAAA;AAAA,MACH;AACA,MAAA,aAAA,CAAc,CAAC,CAAA;AAAA,IACjB;AAAA,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WarningPanel.esm.js","sources":["../../../src/components/WarningPanel/WarningPanel.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 { makeStyles, darken, lighten, Theme } from '@material-ui/core/styles';\nimport Accordion from '@material-ui/core/Accordion';\nimport AccordionSummary from '@material-ui/core/AccordionSummary';\nimport AccordionDetails from '@material-ui/core/AccordionDetails';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport ErrorOutline from '@material-ui/icons/ErrorOutline';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { ReactNode } from 'react';\nimport { MarkdownContent } from '../MarkdownContent';\n\nconst getWarningTextColor = (\n severity: NonNullable<WarningProps['severity']>,\n theme: Theme,\n) => {\n const getColor = theme.palette.type === 'light' ? darken : lighten;\n return getColor(theme.palette[severity].light, 0.6);\n};\n\nconst getWarningBackgroundColor = (\n severity: NonNullable<WarningProps['severity']>,\n theme: Theme,\n) => {\n const getBackgroundColor = theme.palette.type === 'light' ? lighten : darken;\n return getBackgroundColor(theme.palette[severity].light, 0.9);\n};\n\nconst useErrorOutlineStyles = makeStyles(theme => ({\n root: {\n marginRight: theme.spacing(1),\n fill: ({ severity }: WarningProps) =>\n getWarningTextColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n },\n}));\n\nconst ErrorOutlineStyled = ({ severity }: Pick<WarningProps, 'severity'>) => {\n const classes = useErrorOutlineStyles({ severity });\n return <ErrorOutline classes={classes} />;\n};\nconst ExpandMoreIconStyled = ({ severity }: Pick<WarningProps, 'severity'>) => {\n const classes = useErrorOutlineStyles({ severity });\n return <ExpandMoreIcon classes={classes} />;\n};\n\nexport type WarningPanelClassKey =\n | 'panel'\n | 'summary'\n | 'summaryText'\n | 'message'\n | 'details';\n\nconst useStyles = makeStyles(\n theme => ({\n panel: {\n backgroundColor: ({ severity }: WarningProps) =>\n getWarningBackgroundColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n color: ({ severity }: WarningProps) =>\n getWarningTextColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n verticalAlign: 'middle',\n },\n summary: {\n display: 'flex',\n flexDirection: 'row',\n },\n summaryText: {\n color: ({ severity }: WarningProps) =>\n getWarningTextColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n fontWeight: theme.typography.fontWeightBold,\n },\n markdownContent: {\n '& p': {\n display: 'inline',\n },\n },\n message: {\n width: '100%',\n display: 'block',\n color: ({ severity }: WarningProps) =>\n getWarningTextColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n backgroundColor: ({ severity }: WarningProps) =>\n getWarningBackgroundColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n },\n details: {\n width: '100%',\n display: 'block',\n color: theme.palette.textContrast,\n backgroundColor: theme.palette.background.default,\n border: `1px solid ${theme.palette.border}`,\n padding: theme.spacing(2.0),\n fontFamily: 'sans-serif',\n },\n }),\n { name: 'BackstageWarningPanel' },\n);\n\nexport type WarningProps = {\n title?: string;\n severity?: 'warning' | 'error' | 'info';\n titleFormat?: string;\n message?: ReactNode;\n defaultExpanded?: boolean;\n children?: ReactNode;\n};\n\nconst capitalize = (s: string) => {\n return s.charAt(0).toLocaleUpperCase('en-US') + s.slice(1);\n};\n\n/**\n * Show a user friendly error message to a user similar to\n * ErrorPanel except that the warning panel only shows the warning message to\n * the user.\n *\n * @param severity - Ability to change the severity of the alert. Default value\n * \"warning\"\n * @param title - A title for the warning. If not supplied, \"Warning\" will be\n * used.\n * @param message - Optional more detailed user-friendly message elaborating on\n * the cause of the error.\n * @param children - Objects to provide context, such as a stack trace or detailed\n * error reporting. Will be available inside an unfolded accordion.\n */\nexport function WarningPanel(props: WarningProps) {\n const {\n severity = 'warning',\n title,\n titleFormat,\n message,\n children,\n defaultExpanded,\n } = props;\n const classes = useStyles({ severity });\n\n // If no severity or title provided, the heading will read simply \"Warning\"\n const subTitle = capitalize(severity) + (title ? `: ${title}` : '');\n\n return (\n <Accordion\n defaultExpanded={defaultExpanded ?? false}\n className={classes.panel}\n role=\"alert\"\n >\n <AccordionSummary\n expandIcon={<ExpandMoreIconStyled severity={severity} />}\n className={classes.summary}\n >\n <ErrorOutlineStyled severity={severity} />\n <Typography className={classes.summaryText} variant=\"subtitle1\">\n {titleFormat === 'markdown' ? (\n <MarkdownContent\n content={subTitle}\n className={classes.markdownContent}\n />\n ) : (\n subTitle\n )}\n </Typography>\n </AccordionSummary>\n {(message || children) && (\n <AccordionDetails>\n <Grid container>\n {message && (\n <Grid item xs={12}>\n <Typography className={classes.message} variant=\"body1\">\n {message}\n </Typography>\n </Grid>\n )}\n {children && (\n <Grid item xs={12} className={classes.details}>\n {children}\n </Grid>\n )}\n </Grid>\n </AccordionDetails>\n )}\n </Accordion>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA2BA,MAAM,mBAAA,GAAsB,CAC1B,QAAA,EACA,KAAA,KACG;AACH,EAAA,MAAM,QAAA,GAAW,KAAA,CAAM,OAAA,CAAQ,IAAA,KAAS,UAAU,MAAA,GAAS,OAAA;AAC3D,EAAA,OAAO,SAAS,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAA,CAAE,OAAO,GAAG,CAAA;AACpD,CAAA;AAEA,MAAM,yBAAA,GAA4B,CAChC,QAAA,EACA,KAAA,KACG;AACH,EAAA,MAAM,kBAAA,GAAqB,KAAA,CAAM,OAAA,CAAQ,IAAA,KAAS,UAAU,OAAA,GAAU,MAAA;AACtE,EAAA,OAAO,mBAAmB,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAA,CAAE,OAAO,GAAG,CAAA;AAC9D,CAAA;AAEA,MAAM,qBAAA,GAAwB,WAAW,CAAA,KAAA,MAAU;AAAA,EACjD,IAAA,EAAM;AAAA,IACJ,WAAA,EAAa,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC5B,IAAA,EAAM,CAAC,EAAE,QAAA,EAAS,KAChB,mBAAA;AAAA,MACE,QAAA;AAAA,MACA;AAAA;AACF;AAEN,CAAA,CAAE,CAAA;AAEF,MAAM,kBAAA,GAAqB,CAAC,EAAE,QAAA,EAAS,KAAsC;AAC3E,EAAA,MAAM,OAAA,GAAU,qBAAA,CAAsB,EAAE,QAAA,EAAU,CAAA;AAClD,EAAA,uBAAO,GAAA,CAAC,gBAAa,OAAA,EAAkB,CAAA;AACzC,CAAA;AACA,MAAM,oBAAA,GAAuB,CAAC,EAAE,QAAA,EAAS,KAAsC;AA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AmB,QAAA,EAAoB,CAAA;AAAA,8BACxC,GAAA,CAAC,cAAW,SAAA,EAAW,OAAA,CAAQ,aAAa,OAAA,EAAQ,WAAA,EACjD,0BAAgB,UAAA,mBACf,GAAA;AAAA,gBAAC,eAAA;AAAA,gBAAA;AAAA,kBACC,OAAA,EAAS,QAAA;AAAA,kBACT,WAAW,OAAA,CAAQ;AAAA;AAAA,kBAGrB,QAAA,EAEJ;AAAA;AAAA;AAAA,SACF;AAAA,QAAA,CACE,WAAW,QAAA,qBACX,GAAA,CAAC,oBACC,QAAA,kBAAA,IAAA,CAAC,IAAA,EAAA,EAAK,WAAS,IAAA,EACZ,QAAA,EAAA;AAAA,UAAA,OAAA,oBACC,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,IAAI,EAAA,EACb,QAAA,kBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,SAAA,EAAW,OAAA,CAAQ,OAAA,EAAS,OAAA,EAAQ,OAAA,EAC7C,mBACH,CAAA,EACF,CAAA;AAAA,UAED,QAAA,oBACC,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,IAAI,EAAA,EAAI,SAAA,EAAW,OAAA,CAAQ,OAAA,EACnC,QAAA,EACH;AAAA,SAAA,EAEJ,CAAA,EACF;AAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"WarningPanel.esm.js","sources":["../../../src/components/WarningPanel/WarningPanel.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 { makeStyles, darken, lighten, Theme } from '@material-ui/core/styles';\nimport Accordion from '@material-ui/core/Accordion';\nimport AccordionSummary from '@material-ui/core/AccordionSummary';\nimport AccordionDetails from '@material-ui/core/AccordionDetails';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport ErrorOutline from '@material-ui/icons/ErrorOutline';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { ReactNode } from 'react';\nimport { MarkdownContent } from '../MarkdownContent';\n\nconst getWarningTextColor = (\n severity: NonNullable<WarningProps['severity']>,\n theme: Theme,\n) => {\n const getColor = theme.palette.type === 'light' ? darken : lighten;\n return getColor(theme.palette[severity].light, 0.6);\n};\n\nconst getWarningBackgroundColor = (\n severity: NonNullable<WarningProps['severity']>,\n theme: Theme,\n) => {\n const getBackgroundColor = theme.palette.type === 'light' ? lighten : darken;\n return getBackgroundColor(theme.palette[severity].light, 0.9);\n};\n\nconst useErrorOutlineStyles = makeStyles(theme => ({\n root: {\n marginRight: theme.spacing(1),\n fill: ({ severity }: WarningProps) =>\n getWarningTextColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n },\n}));\n\nconst ErrorOutlineStyled = ({ severity }: Pick<WarningProps, 'severity'>) => {\n const classes = useErrorOutlineStyles({ severity });\n return <ErrorOutline classes={classes} />;\n};\nconst ExpandMoreIconStyled = ({ severity }: Pick<WarningProps, 'severity'>) => {\n const classes = useErrorOutlineStyles({ severity });\n return <ExpandMoreIcon classes={classes} />;\n};\n\nexport type WarningPanelClassKey =\n | 'panel'\n | 'summary'\n | 'summaryText'\n | 'message'\n | 'details';\n\nconst useStyles = makeStyles(\n theme => ({\n panel: {\n backgroundColor: ({ severity }: WarningProps) =>\n getWarningBackgroundColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n color: ({ severity }: WarningProps) =>\n getWarningTextColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n verticalAlign: 'middle',\n },\n summary: {\n display: 'flex',\n flexDirection: 'row',\n },\n summaryText: {\n color: ({ severity }: WarningProps) =>\n getWarningTextColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n fontWeight: theme.typography.fontWeightBold,\n },\n markdownContent: {\n wordBreak: 'break-word',\n '& p': {\n display: 'inline',\n },\n },\n message: {\n width: '100%',\n display: 'block',\n color: ({ severity }: WarningProps) =>\n getWarningTextColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n backgroundColor: ({ severity }: WarningProps) =>\n getWarningBackgroundColor(\n severity as NonNullable<WarningProps['severity']>,\n theme,\n ),\n },\n details: {\n width: '100%',\n display: 'block',\n color: theme.palette.textContrast,\n backgroundColor: theme.palette.background.default,\n border: `1px solid ${theme.palette.border}`,\n padding: theme.spacing(2.0),\n fontFamily: 'sans-serif',\n },\n }),\n { name: 'BackstageWarningPanel' },\n);\n\nexport type WarningProps = {\n title?: string;\n severity?: 'warning' | 'error' | 'info';\n titleFormat?: string;\n message?: ReactNode;\n defaultExpanded?: boolean;\n children?: ReactNode;\n};\n\nconst capitalize = (s: string) => {\n return s.charAt(0).toLocaleUpperCase('en-US') + s.slice(1);\n};\n\n/**\n * Show a user friendly error message to a user similar to\n * ErrorPanel except that the warning panel only shows the warning message to\n * the user.\n *\n * @param severity - Ability to change the severity of the alert. Default value\n * \"warning\"\n * @param title - A title for the warning. If not supplied, \"Warning\" will be\n * used.\n * @param message - Optional more detailed user-friendly message elaborating on\n * the cause of the error.\n * @param children - Objects to provide context, such as a stack trace or detailed\n * error reporting. Will be available inside an unfolded accordion.\n */\nexport function WarningPanel(props: WarningProps) {\n const {\n severity = 'warning',\n title,\n titleFormat,\n message,\n children,\n defaultExpanded,\n } = props;\n const classes = useStyles({ severity });\n\n // If no severity or title provided, the heading will read simply \"Warning\"\n const subTitle = capitalize(severity) + (title ? `: ${title}` : '');\n\n return (\n <Accordion\n defaultExpanded={defaultExpanded ?? false}\n className={classes.panel}\n role=\"alert\"\n >\n <AccordionSummary\n expandIcon={<ExpandMoreIconStyled severity={severity} />}\n className={classes.summary}\n >\n <ErrorOutlineStyled severity={severity} />\n <Typography className={classes.summaryText} variant=\"subtitle1\">\n {titleFormat === 'markdown' ? (\n <MarkdownContent\n content={subTitle}\n className={classes.markdownContent}\n />\n ) : (\n subTitle\n )}\n </Typography>\n </AccordionSummary>\n {(message || children) && (\n <AccordionDetails>\n <Grid container>\n {message && (\n <Grid item xs={12}>\n <Typography className={classes.message} variant=\"body1\">\n {message}\n </Typography>\n </Grid>\n )}\n {children && (\n <Grid item xs={12} className={classes.details}>\n {children}\n </Grid>\n )}\n </Grid>\n </AccordionDetails>\n )}\n </Accordion>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA2BA,MAAM,mBAAA,GAAsB,CAC1B,QAAA,EACA,KAAA,KACG;AACH,EAAA,MAAM,QAAA,GAAW,KAAA,CAAM,OAAA,CAAQ,IAAA,KAAS,UAAU,MAAA,GAAS,OAAA;AAC3D,EAAA,OAAO,SAAS,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAA,CAAE,OAAO,GAAG,CAAA;AACpD,CAAA;AAEA,MAAM,yBAAA,GAA4B,CAChC,QAAA,EACA,KAAA,KACG;AACH,EAAA,MAAM,kBAAA,GAAqB,KAAA,CAAM,OAAA,CAAQ,IAAA,KAAS,UAAU,OAAA,GAAU,MAAA;AACtE,EAAA,OAAO,mBAAmB,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAA,CAAE,OAAO,GAAG,CAAA;AAC9D,CAAA;AAEA,MAAM,qBAAA,GAAwB,WAAW,CAAA,KAAA,MAAU;AAAA,EACjD,IAAA,EAAM;AAAA,IACJ,WAAA,EAAa,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC5B,IAAA,EAAM,CAAC,EAAE,QAAA,EAAS,KAChB,mBAAA;AAAA,MACE,QAAA;AAAA,MACA;AAAA;AACF;AAEN,CAAA,CAAE,CAAA;AAEF,MAAM,kBAAA,GAAqB,CAA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
106
|
title: "You do not appear to be signed in. Please try reloading the browser page."
|
|
107
|
+
},
|
|
108
|
+
logViewer: {
|
|
109
|
+
searchField: {
|
|
110
|
+
placeholder: "Search"
|
|
111
|
+
}
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
114
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation.esm.js","sources":["../src/translation.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { createTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/** @alpha */\nexport const coreComponentsTranslationRef = createTranslationRef({\n id: 'core-components',\n messages: {\n signIn: {\n title: 'Sign In',\n loginFailed: 'Login failed',\n customProvider: {\n title: 'Custom User',\n subtitle:\n 'Enter your own User ID and credentials.\\n This selection will not be stored.',\n userId: 'User ID',\n tokenInvalid: 'Token is not a valid OpenID Connect JWT Token',\n continue: 'Continue',\n idToken: 'ID Token (optional)',\n },\n guestProvider: {\n title: 'Guest',\n subtitle:\n 'Enter as a Guest User.\\n You will not have a verified identity, meaning some features might be unavailable.',\n enter: 'Enter',\n },\n },\n skipToContent: 'Skip to content',\n copyTextButton: {\n tooltipText: 'Text copied to clipboard',\n },\n simpleStepper: {\n reset: 'Reset',\n finish: 'Finish',\n next: 'Next',\n skip: 'Skip',\n back: 'Back',\n },\n errorPage: {\n subtitle: 'ERROR {{status}}: {{statusMessage}}',\n title: 'Looks like someone dropped the mic!',\n goBack: 'Go back',\n showMoreDetails: 'Show more details',\n showLessDetails: 'Show less details',\n },\n emptyState: {\n missingAnnotation: {\n title: 'Missing Annotation',\n actionTitle:\n 'Add the annotation to your component YAML as shown in the highlighted example below:',\n readMore: 'Read more',\n },\n },\n supportConfig: {\n default: {\n title: 'Support Not Configured',\n linkTitle: 'Add `app.support` config key',\n },\n },\n errorBoundary: {\n title: 'Please contact {{slackChannel}} for help.',\n },\n oauthRequestDialog: {\n title: 'Login Required',\n authRedirectTitle: 'This will trigger a http redirect to OAuth Login.',\n login: 'Log in',\n rejectAll: 'Reject All',\n message:\n 'Sign-in to allow {{appTitle}} access to {{provider}} APIs and identities.',\n },\n supportButton: {\n title: 'Support',\n close: 'Close',\n },\n table: {\n filter: {\n title: 'Filters',\n clearAll: 'Clear all',\n placeholder: 'All results',\n },\n body: {\n emptyDataSourceMessage: 'No records to display',\n },\n pagination: {\n firstTooltip: 'First Page',\n labelDisplayedRows: '{from}-{to} of {count}',\n labelRowsSelect: 'rows',\n lastTooltip: 'Last Page',\n nextTooltip: 'Next Page',\n previousTooltip: 'Previous Page',\n },\n toolbar: {\n search: 'Filter',\n },\n header: {\n actions: 'Actions',\n },\n },\n alertDisplay: {\n message_one: '({{ count }} newer message)',\n message_other: '({{ count }} newer messages)',\n },\n autoLogout: {\n stillTherePrompt: {\n title: 'Logging out due to inactivity',\n buttonText: \"Yes! Don't log me out\",\n },\n },\n dependencyGraph: {\n fullscreenTooltip: 'Toggle fullscreen',\n },\n proxiedSignInPage: {\n title:\n 'You do not appear to be signed in. Please try reloading the browser page.',\n },\n },\n});\n"],"names":[],"mappings":";;AAmBO,MAAM,+BAA+B,oBAAA,CAAqB;AAAA,EAC/D,EAAA,EAAI,iBAAA;AAAA,EACJ,QAAA,EAAU;AAAA,IACR,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO,SAAA;AAAA,MACP,WAAA,EAAa,cAAA;AAAA,MACb,cAAA,EAAgB;AAAA,QACd,KAAA,EAAO,aAAA;AAAA,QACP,QAAA,EACE,8EAAA;AAAA,QACF,MAAA,EAAQ,SAAA;AAAA,QACR,YAAA,EAAc,+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,EAAO;AAAA,MACL,MAAA,EAAQ;AAAA,QACN,KAAA,EAAO,SAAA;AAAA,QACP,QAAA,EAAU,WAAA;AAAA,QACV,WAAA,EAAa;AAAA,OACf;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,sBAAA,EAAwB;AAAA,OAC1B;AAAA,MACA,UAAA,EAAY;AAAA,QACV,YAAA,EAAc,YAAA;AAAA,QACd,kBAAA,EAAoB,wBAAA;AAAA,QACpB,eAAA,EAAiB,MAAA;AAAA,QACjB,WAAA,EAAa,WAAA;AAAA,QACb,WAAA,EAAa,WAAA;AAAA,QACb,eAAA,EAAiB;AAAA,OACnB;AAAA,MACA,OAAA,EAAS;AAAA,QACP,MAAA,EAAQ;AAAA,OACV;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,OAAA,EAAS;AAAA;AACX,KACF;AAAA,IACA,YAAA,EAAc;AAAA,MACZ,WAAA,EAAa,6BAAA;AAAA,MACb,aAAA,EAAe;AAAA,KACjB;AAAA,IACA,UAAA,EAAY;AAAA,MACV,gBAAA,EAAkB;AAAA,QAChB,KAAA,EAAO,+BAAA;AAAA,QACP,UAAA,EAAY;AAAA;AACd,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,iBAAA,EAAmB;AAAA,KACrB;AAAA,IACA,iBAAA,EAAmB;AAAA,MACjB,KAAA,EACE;AAAA;
|
|
1
|
+
{"version":3,"file":"translation.esm.js","sources":["../src/translation.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { createTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/** @alpha */\nexport const coreComponentsTranslationRef = createTranslationRef({\n id: 'core-components',\n messages: {\n signIn: {\n title: 'Sign In',\n loginFailed: 'Login failed',\n customProvider: {\n title: 'Custom User',\n subtitle:\n 'Enter your own User ID and credentials.\\n This selection will not be stored.',\n userId: 'User ID',\n tokenInvalid: 'Token is not a valid OpenID Connect JWT Token',\n continue: 'Continue',\n idToken: 'ID Token (optional)',\n },\n guestProvider: {\n title: 'Guest',\n subtitle:\n 'Enter as a Guest User.\\n You will not have a verified identity, meaning some features might be unavailable.',\n enter: 'Enter',\n },\n },\n skipToContent: 'Skip to content',\n copyTextButton: {\n tooltipText: 'Text copied to clipboard',\n },\n simpleStepper: {\n reset: 'Reset',\n finish: 'Finish',\n next: 'Next',\n skip: 'Skip',\n back: 'Back',\n },\n errorPage: {\n subtitle: 'ERROR {{status}}: {{statusMessage}}',\n title: 'Looks like someone dropped the mic!',\n goBack: 'Go back',\n showMoreDetails: 'Show more details',\n showLessDetails: 'Show less details',\n },\n emptyState: {\n missingAnnotation: {\n title: 'Missing Annotation',\n actionTitle:\n 'Add the annotation to your component YAML as shown in the highlighted example below:',\n readMore: 'Read more',\n },\n },\n supportConfig: {\n default: {\n title: 'Support Not Configured',\n linkTitle: 'Add `app.support` config key',\n },\n },\n errorBoundary: {\n title: 'Please contact {{slackChannel}} for help.',\n },\n oauthRequestDialog: {\n title: 'Login Required',\n authRedirectTitle: 'This will trigger a http redirect to OAuth Login.',\n login: 'Log in',\n rejectAll: 'Reject All',\n message:\n 'Sign-in to allow {{appTitle}} access to {{provider}} APIs and identities.',\n },\n supportButton: {\n title: 'Support',\n close: 'Close',\n },\n table: {\n filter: {\n title: 'Filters',\n clearAll: 'Clear all',\n placeholder: 'All results',\n },\n body: {\n emptyDataSourceMessage: 'No records to display',\n },\n pagination: {\n firstTooltip: 'First Page',\n labelDisplayedRows: '{from}-{to} of {count}',\n labelRowsSelect: 'rows',\n lastTooltip: 'Last Page',\n nextTooltip: 'Next Page',\n previousTooltip: 'Previous Page',\n },\n toolbar: {\n search: 'Filter',\n },\n header: {\n actions: 'Actions',\n },\n },\n alertDisplay: {\n message_one: '({{ count }} newer message)',\n message_other: '({{ count }} newer messages)',\n },\n autoLogout: {\n stillTherePrompt: {\n title: 'Logging out due to inactivity',\n buttonText: \"Yes! Don't log me out\",\n },\n },\n dependencyGraph: {\n fullscreenTooltip: 'Toggle fullscreen',\n },\n proxiedSignInPage: {\n title:\n 'You do not appear to be signed in. Please try reloading the browser page.',\n },\n logViewer: {\n searchField: {\n placeholder: 'Search',\n },\n },\n },\n});\n"],"names":[],"mappings":";;AAmBO,MAAM,+BAA+B,oBAAA,CAAqB;AAAA,EAC/D,EAAA,EAAI,iBAAA;AAAA,EACJ,QAAA,EAAU;AAAA,IACR,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO,SAAA;AAAA,MACP,WAAA,EAAa,cAAA;AAAA,MACb,cAAA,EAAgB;AAAA,QACd,KAAA,EAAO,aAAA;AAAA,QACP,QAAA,EACE,8EAAA;AAAA,QACF,MAAA,EAAQ,SAAA;AAAA,QACR,YAAA,EAAc,+CAAA;AAAA,QACd,QAAA,EAAU,UAAA;AAAA,QACV,OAAA,EAAS;AAAA,OACX;AAAA,MACA,aAAA,EAAe;AAAA,QACb,KAAA,EAAO,OAAA;AAAA,QACP,QAAA,EACE,6GAAA;AAAA,QACF,KAAA,EAAO;AAAA;AACT,KACF;AAAA,IACA,aAAA,EAAe,iBAAA;AAAA,IACf,cAAA,EAAgB;AAAA,MACd,WAAA,EAAa;AAAA,KACf;AAAA,IACA,aAAA,EAAe;AAAA,MACb,KAAA,EAAO,OAAA;AAAA,MACP,MAAA,EAAQ,QAAA;AAAA,MACR,IAAA,EAAM,MAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,IAAA,EAAM;AAAA,KACR;AAAA,IACA,SAAA,EAAW;AAAA,MACT,QAAA,EAAU,qCAAA;AAAA,MACV,KAAA,EAAO,qCAAA;AAAA,MACP,MAAA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Z,WAAA,EAAa,6BAAA;AAAA,MACb,aAAA,EAAe;AAAA,KACjB;AAAA,IACA,UAAA,EAAY;AAAA,MACV,gBAAA,EAAkB;AAAA,QAChB,KAAA,EAAO,+BAAA;AAAA,QACP,UAAA,EAAY;AAAA;AACd,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,iBAAA,EAAmB;AAAA,KACrB;AAAA,IACA,iBAAA,EAAmB;AAAA,MACjB,KAAA,EACE;AAAA,KACJ;AAAA,IACA,SAAA,EAAW;AAAA,MACT,WAAA,EAAa;AAAA,QACX,WAAA,EAAa;AAAA;AACf;AACF;AAEJ,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/core-components",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.4-next.1",
|
|
4
4
|
"description": "Core components used by Backstage plugins and apps",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library"
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
"test": "backstage-cli package test"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@backstage/config": "
|
|
70
|
-
"@backstage/core-plugin-api": "
|
|
71
|
-
"@backstage/errors": "
|
|
72
|
-
"@backstage/theme": "
|
|
73
|
-
"@backstage/version-bridge": "
|
|
69
|
+
"@backstage/config": "1.3.6",
|
|
70
|
+
"@backstage/core-plugin-api": "1.12.1-next.0",
|
|
71
|
+
"@backstage/errors": "1.2.7",
|
|
72
|
+
"@backstage/theme": "0.7.1-next.0",
|
|
73
|
+
"@backstage/version-bridge": "1.0.11",
|
|
74
74
|
"@dagrejs/dagre": "^1.1.4",
|
|
75
75
|
"@date-io/core": "^1.3.13",
|
|
76
76
|
"@material-table/core": "^3.1.0",
|
|
@@ -107,10 +107,10 @@
|
|
|
107
107
|
"zod": "^3.22.4"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@backstage/app-defaults": "
|
|
111
|
-
"@backstage/cli": "
|
|
112
|
-
"@backstage/core-app-api": "
|
|
113
|
-
"@backstage/test-utils": "
|
|
110
|
+
"@backstage/app-defaults": "1.7.3-next.0",
|
|
111
|
+
"@backstage/cli": "0.34.6-next.1",
|
|
112
|
+
"@backstage/core-app-api": "1.19.3-next.0",
|
|
113
|
+
"@backstage/test-utils": "1.7.14-next.0",
|
|
114
114
|
"@testing-library/dom": "^10.0.0",
|
|
115
115
|
"@testing-library/jest-dom": "^6.0.0",
|
|
116
116
|
"@testing-library/user-event": "^14.0.0",
|