@scm-manager/ui-components 2.27.3-20211117-144126 → 2.27.4
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/package.json +8 -7
- package/src/Autocomplete.tsx +6 -7
- package/src/BranchSelector.tsx +2 -2
- package/src/Breadcrumb.tsx +0 -1
- package/src/CardColumnGroup.tsx +6 -6
- package/src/DangerZone.tsx +0 -1
- package/src/DateFromNow.tsx +1 -2
- package/src/DateShort.tsx +1 -2
- package/src/ErrorBoundary.tsx +2 -2
- package/src/Icon.tsx +4 -4
- package/src/Logo.stories.tsx +0 -1
- package/src/OverviewPageActions.tsx +2 -2
- package/src/SplitAndReplace.tsx +2 -3
- package/src/SyntaxHighlighter.stories.tsx +1 -1
- package/src/Tooltip.tsx +1 -1
- package/src/__snapshots__/storyshots.test.ts.snap +2086 -1068
- package/src/buttons/Button.tsx +34 -33
- package/src/forms/FileInput.tsx +1 -1
- package/src/forms/FileUpload.tsx +1 -1
- package/src/forms/FilterInput.tsx +0 -1
- package/src/forms/InputField.tsx +2 -2
- package/src/forms/Select.tsx +4 -4
- package/src/forms/TriStateCheckbox.tsx +2 -2
- package/src/index.ts +3 -4
- package/src/languages.test.ts +5 -1
- package/src/languages.ts +10 -1
- package/src/layout/Footer.tsx +1 -1
- package/src/layout/Header.tsx +2 -2
- package/src/layout/index.ts +1 -2
- package/src/modals/FullscreenModal.tsx +1 -1
- package/src/modals/Modal.tsx +6 -6
- package/src/navigation/RoutingProps.ts +1 -3
- package/src/navigation/SecondaryNavigation.stories.tsx +3 -3
- package/src/navigation/SecondaryNavigation.tsx +1 -1
- package/src/popover/Popover.tsx +7 -7
- package/src/repos/DiffFile.tsx +15 -21
- package/src/repos/HealthCheckFailureDetail.tsx +2 -2
- package/src/repos/RepositoryEntry.tsx +6 -9
- package/src/repos/RepositoryFlags.tsx +2 -2
- package/src/repos/TokenizedDiffView.tsx +2 -20
- package/src/repos/annotate/Annotate.stories.tsx +1 -1
- package/src/repos/annotate/AnnotateLine.tsx +0 -1
- package/src/repos/index.ts +0 -2
- package/src/repos/refractorAdapter.ts +6 -11
- package/src/search/HighlightedFragment.tsx +4 -7
- package/src/search/TextHitField.tsx +18 -34
- package/src/styleConstants.ts +1 -2
- package/src/syntax-highlighting.module.css +1 -1
- package/src/SmallLoadingSpinner.stories.tsx +0 -32
- package/src/SmallLoadingSpinner.tsx +0 -34
- package/src/__resources__/ContentSearchHit.ts +0 -73
- package/src/layout/SubSubtitle.tsx +0 -41
- package/src/search/SyntaxHighlightedFragment.tsx +0 -130
- package/src/search/TextHitField.stories.tsx +0 -54
|
@@ -26,46 +26,35 @@ import styled from "styled-components";
|
|
|
26
26
|
// @ts-ignore we have no typings for react-diff-view
|
|
27
27
|
import { Diff, useTokenizeWorker } from "react-diff-view";
|
|
28
28
|
import { FileDiff } from "@scm-manager/ui-types";
|
|
29
|
+
import { determineLanguage } from "../languages";
|
|
29
30
|
|
|
30
31
|
// @ts-ignore no types for css modules
|
|
31
32
|
import theme from "../syntax-highlighting.module.css";
|
|
32
|
-
import { determineLanguage } from "../languages";
|
|
33
33
|
|
|
34
34
|
const DiffView = styled(Diff)`
|
|
35
35
|
/* align line numbers */
|
|
36
|
-
|
|
37
36
|
& .diff-gutter {
|
|
38
37
|
text-align: right;
|
|
39
38
|
}
|
|
40
|
-
|
|
41
39
|
/* column sizing */
|
|
42
|
-
|
|
43
40
|
> colgroup .diff-gutter-col {
|
|
44
41
|
width: 3.25rem;
|
|
45
42
|
}
|
|
46
|
-
|
|
47
43
|
/* prevent following content from moving down */
|
|
48
|
-
|
|
49
44
|
> .diff-gutter:empty:hover::after {
|
|
50
45
|
font-size: 0.7rem;
|
|
51
46
|
}
|
|
52
|
-
|
|
53
47
|
/* smaller font size for code and
|
|
54
48
|
ensure same monospace font throughout whole scmm */
|
|
55
|
-
|
|
56
49
|
& .diff-line {
|
|
57
50
|
font-size: 0.75rem;
|
|
58
51
|
font-family: "Courier New", Monaco, Menlo, "Ubuntu Mono", "source-code-pro", monospace;
|
|
59
52
|
}
|
|
60
|
-
|
|
61
53
|
/* comment padding for sidebyside view */
|
|
62
|
-
|
|
63
54
|
&.split .diff-widget-content .is-indented-line {
|
|
64
55
|
padding-left: 3.25rem;
|
|
65
56
|
}
|
|
66
|
-
|
|
67
57
|
/* comment padding for combined view */
|
|
68
|
-
|
|
69
58
|
&.unified .diff-widget-content .is-indented-line {
|
|
70
59
|
padding-left: 6.5rem;
|
|
71
60
|
}
|
|
@@ -82,17 +71,10 @@ type Props = {
|
|
|
82
71
|
className?: string;
|
|
83
72
|
};
|
|
84
73
|
|
|
85
|
-
const findSyntaxHighlightingLanguage = (file: FileDiff) => {
|
|
86
|
-
if (file.syntaxModes) {
|
|
87
|
-
return file.syntaxModes["prism"] || file.syntaxModes["codemirror"] || file.syntaxModes["ace"] || file.language;
|
|
88
|
-
}
|
|
89
|
-
return file.language;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
74
|
const TokenizedDiffView: FC<Props> = ({ file, viewType, className, children }) => {
|
|
93
75
|
const { tokens } = useTokenizeWorker(tokenize, {
|
|
94
76
|
hunks: file.hunks,
|
|
95
|
-
language: determineLanguage(
|
|
77
|
+
language: determineLanguage(file.language),
|
|
96
78
|
});
|
|
97
79
|
|
|
98
80
|
return (
|
package/src/repos/index.ts
CHANGED
|
@@ -30,7 +30,6 @@ import {
|
|
|
30
30
|
AnnotationFactoryContext,
|
|
31
31
|
DiffEventHandler,
|
|
32
32
|
DiffEventContext,
|
|
33
|
-
DiffObjectProps
|
|
34
33
|
} from "./DiffTypes";
|
|
35
34
|
|
|
36
35
|
import { FileDiff as File, FileChangeType, Hunk, Change, ChangeType } from "@scm-manager/ui-types";
|
|
@@ -65,5 +64,4 @@ export {
|
|
|
65
64
|
AnnotationFactoryContext,
|
|
66
65
|
DiffEventHandler,
|
|
67
66
|
DiffEventContext,
|
|
68
|
-
DiffObjectProps
|
|
69
67
|
};
|
|
@@ -46,15 +46,10 @@ const createAdapter = (theme: { [key: string]: string }): RefractorAdapter => {
|
|
|
46
46
|
import(
|
|
47
47
|
/* webpackChunkName: "tokenizer-refractor-[request]" */
|
|
48
48
|
`refractor/lang/${lang}`
|
|
49
|
-
)
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
.catch(e => {
|
|
55
|
-
// eslint-disable-next-line no-console
|
|
56
|
-
console.log(`failed to load refractor language ${lang}: ${e}`);
|
|
57
|
-
});
|
|
49
|
+
).then((loadedLanguage) => {
|
|
50
|
+
refractor.register(loadedLanguage.default);
|
|
51
|
+
callback();
|
|
52
|
+
});
|
|
58
53
|
}
|
|
59
54
|
};
|
|
60
55
|
|
|
@@ -63,7 +58,7 @@ const createAdapter = (theme: { [key: string]: string }): RefractorAdapter => {
|
|
|
63
58
|
const runHook = (name: string, env: RunHookEnv) => {
|
|
64
59
|
originalRunHook.apply(name, env);
|
|
65
60
|
if (env.classes) {
|
|
66
|
-
env.classes = env.classes.map(className => theme[className] || className);
|
|
61
|
+
env.classes = env.classes.map((className) => theme[className] || className);
|
|
67
62
|
}
|
|
68
63
|
};
|
|
69
64
|
// @ts-ignore hooks are not in the type definition
|
|
@@ -72,7 +67,7 @@ const createAdapter = (theme: { [key: string]: string }): RefractorAdapter => {
|
|
|
72
67
|
return {
|
|
73
68
|
isLanguageRegistered,
|
|
74
69
|
loadLanguage,
|
|
75
|
-
...refractor
|
|
70
|
+
...refractor,
|
|
76
71
|
};
|
|
77
72
|
};
|
|
78
73
|
|
|
@@ -24,9 +24,6 @@
|
|
|
24
24
|
|
|
25
25
|
import React, { FC } from "react";
|
|
26
26
|
|
|
27
|
-
const PRE_TAG = "<|[[--";
|
|
28
|
-
const POST_TAG = "--]]|>";
|
|
29
|
-
|
|
30
27
|
type Props = {
|
|
31
28
|
value: string;
|
|
32
29
|
};
|
|
@@ -36,14 +33,14 @@ const HighlightedFragment: FC<Props> = ({ value }) => {
|
|
|
36
33
|
|
|
37
34
|
const result = [];
|
|
38
35
|
while (content.length > 0) {
|
|
39
|
-
const start = content.indexOf(
|
|
40
|
-
const end = content.indexOf(
|
|
36
|
+
const start = content.indexOf("<>");
|
|
37
|
+
const end = content.indexOf("</>");
|
|
41
38
|
if (start >= 0 && end > 0) {
|
|
42
39
|
if (start > 0) {
|
|
43
40
|
result.push(content.substring(0, start));
|
|
44
41
|
}
|
|
45
|
-
result.push(<
|
|
46
|
-
content = content.substring(end +
|
|
42
|
+
result.push(<strong>{content.substring(start + 2, end)}</strong>);
|
|
43
|
+
content = content.substring(end + 3);
|
|
47
44
|
} else {
|
|
48
45
|
result.push(content);
|
|
49
46
|
break;
|
|
@@ -26,51 +26,35 @@ import React, { FC } from "react";
|
|
|
26
26
|
import { HighlightedHitField, Hit } from "@scm-manager/ui-types";
|
|
27
27
|
import HighlightedFragment from "./HighlightedFragment";
|
|
28
28
|
import { isHighlightedHitField } from "./fields";
|
|
29
|
-
import SyntaxHighlightedFragment from "./SyntaxHighlightedFragment";
|
|
30
|
-
|
|
31
|
-
type HighlightedTextFieldProps = {
|
|
32
|
-
field: HighlightedHitField;
|
|
33
|
-
syntaxHighlightingLanguage?: string;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const HighlightedTextField: FC<HighlightedTextFieldProps> = ({ field, syntaxHighlightingLanguage }) => {
|
|
37
|
-
const separator = syntaxHighlightingLanguage ? "...\n" : " ... ";
|
|
38
|
-
return (
|
|
39
|
-
<>
|
|
40
|
-
{field.fragments.map((fragment, i) => (
|
|
41
|
-
<React.Fragment key={fragment}>
|
|
42
|
-
{field.matchesContentStart ? null : separator}
|
|
43
|
-
{syntaxHighlightingLanguage ? (
|
|
44
|
-
<SyntaxHighlightedFragment value={fragment} language={syntaxHighlightingLanguage} />
|
|
45
|
-
) : (
|
|
46
|
-
<HighlightedFragment value={fragment} />
|
|
47
|
-
)}
|
|
48
|
-
{i + 1 >= field.fragments.length && !field.matchesContentEnd ? separator : null}
|
|
49
|
-
</React.Fragment>
|
|
50
|
-
))}
|
|
51
|
-
</>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
29
|
|
|
55
30
|
type Props = {
|
|
56
31
|
hit: Hit;
|
|
57
32
|
field: string;
|
|
58
33
|
truncateValueAt?: number;
|
|
59
|
-
syntaxHighlightingLanguage?: string;
|
|
60
34
|
};
|
|
61
35
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
36
|
+
type HighlightedTextFieldProps = {
|
|
37
|
+
field: HighlightedHitField;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const HighlightedTextField: FC<HighlightedTextFieldProps> = ({ field }) => (
|
|
41
|
+
<>
|
|
42
|
+
{field.fragments.map((fr, i) => (
|
|
43
|
+
<React.Fragment key={fr}>
|
|
44
|
+
{" ... "}
|
|
45
|
+
<HighlightedFragment value={fr} />
|
|
46
|
+
{i + 1 >= field.fragments.length ? " ... " : null}
|
|
47
|
+
</React.Fragment>
|
|
48
|
+
))}
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const TextHitField: FC<Props> = ({ hit, field: fieldName, children, truncateValueAt = 0 }) => {
|
|
69
53
|
const field = hit.fields[fieldName];
|
|
70
54
|
if (!field) {
|
|
71
55
|
return <>{children}</>;
|
|
72
56
|
} else if (isHighlightedHitField(field)) {
|
|
73
|
-
return <HighlightedTextField field={field}
|
|
57
|
+
return <HighlightedTextField field={field} />;
|
|
74
58
|
} else {
|
|
75
59
|
let value = field.value;
|
|
76
60
|
if (value === "") {
|
package/src/styleConstants.ts
CHANGED
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
// TODO erweitern
|
|
26
25
|
export const colors = [
|
|
27
26
|
"black",
|
|
28
27
|
"dark",
|
|
@@ -33,7 +32,7 @@ export const colors = [
|
|
|
33
32
|
"info",
|
|
34
33
|
"success",
|
|
35
34
|
"warning",
|
|
36
|
-
"danger"
|
|
35
|
+
"danger",
|
|
37
36
|
] as const;
|
|
38
37
|
export type Color = typeof colors[number];
|
|
39
38
|
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
import { storiesOf } from "@storybook/react";
|
|
25
|
-
import React from "react";
|
|
26
|
-
import SmallLoadingSpinner from "./SmallLoadingSpinner";
|
|
27
|
-
|
|
28
|
-
storiesOf("SmallLoading", module).add("Default", () => (
|
|
29
|
-
<div>
|
|
30
|
-
<SmallLoadingSpinner />
|
|
31
|
-
</div>
|
|
32
|
-
));
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
import React, { FC } from "react";
|
|
25
|
-
|
|
26
|
-
const SmallLoadingSpinner: FC = () => {
|
|
27
|
-
return (
|
|
28
|
-
<div className="loader-wrapper">
|
|
29
|
-
<div className="loader is-loading" />
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default SmallLoadingSpinner;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import { Hit } from "@scm-manager/ui-types";
|
|
26
|
-
|
|
27
|
-
export const javaHit: Hit = {
|
|
28
|
-
score: 2.5,
|
|
29
|
-
fields: {
|
|
30
|
-
content: {
|
|
31
|
-
highlighted: true,
|
|
32
|
-
fragments: [
|
|
33
|
-
"import org.slf4j.LoggerFactory;\n\nimport java.util.Date;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.concurrent.TimeUnit;\n\n/**\n * Jwt implementation of {@link <|[[--AccessTokenBuilder--]]|>}.\n * \n * @author Sebastian Sdorra\n * @since 2.0.0\n */\npublic final class <|[[--JwtAccessTokenBuilder--]]|> implements <|[[--AccessTokenBuilder--]]|> {\n\n /**\n * the logger for <|[[--JwtAccessTokenBuilder--]]|>\n */\n private static final Logger LOG = LoggerFactory.getLogger(<|[[--JwtAccessTokenBuilder.class--]]|>);\n \n private final KeyGenerator keyGenerator; \n private final SecureKeyResolver keyResolver; \n \n private String subject;\n private String issuer;\n",
|
|
34
|
-
" private final Map<String,Object> custom = Maps.newHashMap();\n \n <|[[--JwtAccessTokenBuilder--]]|>(KeyGenerator keyGenerator, SecureKeyResolver keyResolver) {\n this.keyGenerator = keyGenerator;\n this.keyResolver = keyResolver;\n }\n\n @Override\n public <|[[--JwtAccessTokenBuilder--]]|> subject(String subject) {\n",
|
|
35
|
-
' public <|[[--JwtAccessTokenBuilder--]]|> custom(String key, Object value) {\n Preconditions.checkArgument(!Strings.isNullOrEmpty(key), "null or empty value not allowed");\n Preconditions.checkArgument(value != null, "null or empty value not allowed");\n'
|
|
36
|
-
],
|
|
37
|
-
matchesContentStart: false,
|
|
38
|
-
matchesContentEnd: false
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
_links: {}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const bashHit: Hit = {
|
|
45
|
-
score: 2.5,
|
|
46
|
-
fields: {
|
|
47
|
-
content: {
|
|
48
|
-
highlighted: true,
|
|
49
|
-
fragments: [
|
|
50
|
-
'# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n#\n\n<|[[--getent--]]|> group scm >/dev/null || groupadd -r scm\n<|[[--getent--]]|> passwd scm >/dev/null || \\\n useradd -r -g scm -M \\\n -s /sbin/nologin -d /var/lib/scm \\\n -c "user for the scm-server process" scm\nexit 0\n\n'
|
|
51
|
-
],
|
|
52
|
-
matchesContentStart: false,
|
|
53
|
-
matchesContentEnd: true
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
_links: {}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const markdownHit: Hit = {
|
|
60
|
-
score: 2.5,
|
|
61
|
-
fields: {
|
|
62
|
-
content: {
|
|
63
|
-
highlighted: true,
|
|
64
|
-
fragments: [
|
|
65
|
-
"---\ntitle: SCM-Manager v2 Test <|[[--Cases--]]|>\n---\n\nDescribes the expected behaviour for SCMM v2 REST Resources using manual tests.\n\nThe following states general test <|[[--cases--]]|> per HTTP Method and en expected return code as well as exemplary curl calls.\nResource-specifics are stated \n\n## Test <|[[--Cases--]]|>\n\n### GET\n\n- Collection Resource (e.g. `/users`)\n - Without parameters -> 200\n - Parameters\n - `?pageSize=1` -> Only one embedded element, pageTotal reflects the correct number of pages, `last` link points to last page.\n - `?pageSize=1&page=1` -> `next` link points to page 0 ; `prev` link points to page 2\n - `?sortBy=admin` -> Sorted by `admin` field of embedded objects\n - `?sortBy=admin&desc=true` -> Invert sorting\n- Individual Resource (e.g. `/users/scmadmin`)\n - Exists -> 200\n",
|
|
66
|
-
"\n### DELETE\n\n- existing -> 204\n- not existing -> 204\n- without permission -> 401\n\n## Exemplary calls & Resource specific test <|[[--cases--]]|>\n\nIn order to extend those tests to other Resources, have a look at the rest docs. Note that the Content Type is specific to each resource as well.\n"
|
|
67
|
-
],
|
|
68
|
-
matchesContentStart: true,
|
|
69
|
-
matchesContentEnd: false
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
_links: {}
|
|
73
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
import React from "react";
|
|
25
|
-
import classNames from "classnames";
|
|
26
|
-
|
|
27
|
-
type Props = {
|
|
28
|
-
className?: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
class SubSubtitle extends React.Component<Props> {
|
|
32
|
-
render() {
|
|
33
|
-
const { className, children } = this.props;
|
|
34
|
-
if (children) {
|
|
35
|
-
return <h3 className={classNames("is-size-5", className)}>{children}</h3>;
|
|
36
|
-
}
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default SubSubtitle;
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import React, { FC, ReactNode, useEffect, useMemo, useState } from "react";
|
|
26
|
-
import createAdapter from "../repos/refractorAdapter";
|
|
27
|
-
// @ts-ignore no types for css modules
|
|
28
|
-
import theme from "../syntax-highlighting.module.css";
|
|
29
|
-
import SplitAndReplace, { Replacement } from "../SplitAndReplace";
|
|
30
|
-
import { AST, RefractorNode } from "refractor";
|
|
31
|
-
import { determineLanguage } from "../languages";
|
|
32
|
-
|
|
33
|
-
const PRE_TAG = "<|[[--";
|
|
34
|
-
const POST_TAG = "--]]|>";
|
|
35
|
-
const PRE_TAG_REGEX = /<\|\[\[--/g;
|
|
36
|
-
const POST_TAG_REGEX = /--]]\|>/g;
|
|
37
|
-
|
|
38
|
-
const adapter = createAdapter(theme);
|
|
39
|
-
|
|
40
|
-
function createReplacement(textToReplace: string): Replacement {
|
|
41
|
-
return {
|
|
42
|
-
textToReplace,
|
|
43
|
-
replacement: <mark>{textToReplace}</mark>,
|
|
44
|
-
replaceAll: true
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function mapWithDepth(depth: number, replacements: Replacement[]) {
|
|
49
|
-
return function mapChildrenWithDepth(child: RefractorNode, i: number) {
|
|
50
|
-
return mapChild(child, i, depth, replacements);
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function isAstElement(node: RefractorNode): node is AST.Element {
|
|
55
|
-
return (node as AST.Element).tagName !== undefined;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function mapChild(child: RefractorNode, i: number, depth: number, replacements: Replacement[]): ReactNode {
|
|
59
|
-
if (isAstElement(child)) {
|
|
60
|
-
const className =
|
|
61
|
-
child.properties && Array.isArray(child.properties.className)
|
|
62
|
-
? child.properties.className.join(" ")
|
|
63
|
-
: child.properties.className;
|
|
64
|
-
|
|
65
|
-
return React.createElement(
|
|
66
|
-
child.tagName,
|
|
67
|
-
Object.assign({ key: `fract-${depth}-${i}` }, child.properties, { className }),
|
|
68
|
-
child.children && child.children.map(mapWithDepth(depth + 1, replacements))
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<SplitAndReplace key={`fract-${depth}-${i}`} text={child.value} replacements={replacements} textWrapper={s => s} />
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
type Props = {
|
|
78
|
-
value: string;
|
|
79
|
-
language: string;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const stripAndReplace = (value: string) => {
|
|
83
|
-
const strippedValue = value.replace(PRE_TAG_REGEX, "").replace(POST_TAG_REGEX, "");
|
|
84
|
-
let content = value;
|
|
85
|
-
|
|
86
|
-
const result: string[] = [];
|
|
87
|
-
while (content.length > 0) {
|
|
88
|
-
const start = content.indexOf(PRE_TAG);
|
|
89
|
-
const end = content.indexOf(POST_TAG);
|
|
90
|
-
if (start >= 0 && end > 0) {
|
|
91
|
-
const item = content.substring(start + PRE_TAG.length, end);
|
|
92
|
-
if (!result.includes(item)) {
|
|
93
|
-
result.push(item);
|
|
94
|
-
}
|
|
95
|
-
content = content.substring(end + POST_TAG.length);
|
|
96
|
-
} else {
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
result.sort((a, b) => b.length - a.length);
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
strippedValue,
|
|
105
|
-
replacements: result.map(createReplacement)
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const SyntaxHighlightedFragment: FC<Props> = ({ value, language }) => {
|
|
110
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
111
|
-
const determinedLanguage = determineLanguage(language);
|
|
112
|
-
const { strippedValue, replacements } = useMemo(() => stripAndReplace(value), [value]);
|
|
113
|
-
|
|
114
|
-
useEffect(() => {
|
|
115
|
-
adapter.loadLanguage(determinedLanguage, () => {
|
|
116
|
-
setIsLoading(false);
|
|
117
|
-
});
|
|
118
|
-
}, [determinedLanguage]);
|
|
119
|
-
|
|
120
|
-
if (isLoading) {
|
|
121
|
-
return <SplitAndReplace text={strippedValue} replacements={replacements} textWrapper={s => s} />;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const refractorNodes = adapter.highlight(strippedValue, determinedLanguage);
|
|
125
|
-
const highlightedFragment = refractorNodes.map(mapWithDepth(0, replacements));
|
|
126
|
-
|
|
127
|
-
return <>{highlightedFragment}</>;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export default SyntaxHighlightedFragment;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
import React from "react";
|
|
25
|
-
import { storiesOf } from "@storybook/react";
|
|
26
|
-
import { bashHit, javaHit, markdownHit } from "../__resources__/ContentSearchHit";
|
|
27
|
-
import TextHitField from "./TextHitField";
|
|
28
|
-
|
|
29
|
-
storiesOf("TextHitField", module)
|
|
30
|
-
.add("Default", () => (
|
|
31
|
-
<pre>
|
|
32
|
-
<TextHitField hit={javaHit} field={"content"} />
|
|
33
|
-
</pre>
|
|
34
|
-
))
|
|
35
|
-
.add("Java SyntaxHighlighting", () => (
|
|
36
|
-
<pre>
|
|
37
|
-
<TextHitField hit={javaHit} field={"content"} syntaxHighlightingLanguage="java" />
|
|
38
|
-
</pre>
|
|
39
|
-
))
|
|
40
|
-
.add("Bash SyntaxHighlighting", () => (
|
|
41
|
-
<pre>
|
|
42
|
-
<TextHitField hit={bashHit} field={"content"} syntaxHighlightingLanguage="bash" />
|
|
43
|
-
</pre>
|
|
44
|
-
))
|
|
45
|
-
.add("Markdown SyntaxHighlighting", () => (
|
|
46
|
-
<pre>
|
|
47
|
-
<TextHitField hit={markdownHit} field={"content"} syntaxHighlightingLanguage="markdown" />
|
|
48
|
-
</pre>
|
|
49
|
-
))
|
|
50
|
-
.add("Unknown SyntaxHighlighting", () => (
|
|
51
|
-
<pre>
|
|
52
|
-
<TextHitField hit={bashHit} field={"content"} syntaxHighlightingLanguage="__unknown__" />
|
|
53
|
-
</pre>
|
|
54
|
-
));
|