@redocly/theme 0.25.1-beta.4 → 0.25.2
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/lib/components/Catalog/Catalog.js +1 -4
- package/lib/components/Catalog/useCatalog.js +3 -4
- package/lib/components/CodeBlock/CodeBlockControls.js +1 -1
- package/lib/components/CopyButton/CopyButton.js +2 -7
- package/lib/components/EditPageButton/EditPageButton.js +1 -4
- package/lib/components/Feedback/Comment.js +4 -10
- package/lib/components/Feedback/Feedback.js +1 -1
- package/lib/components/Feedback/Mood.js +15 -18
- package/lib/components/Feedback/Rating.js +12 -12
- package/lib/components/Feedback/Reasons.js +4 -9
- package/lib/components/Feedback/ReportDialog.js +16 -3
- package/lib/components/Feedback/Sentiment.js +13 -15
- package/lib/components/Feedback/Thumbs.js +2 -8
- package/lib/components/Feedback/types.d.ts +1 -1
- package/lib/components/Feedback/useReportDialog.js +6 -8
- package/lib/components/Filter/Filter.js +6 -6
- package/lib/components/Filter/FilterContent.js +2 -6
- package/lib/components/Filter/FilterPopover.js +2 -6
- package/lib/components/Footer/FooterCopyright.js +2 -5
- package/lib/components/LastUpdated/LastUpdated.js +1 -1
- package/lib/components/Menu/hooks/use-mobile-menu-items.js +1 -4
- package/lib/components/Menu/hooks/use-mobile-menu-levels.js +2 -6
- package/lib/components/Menu/utils.d.ts +2 -1
- package/lib/components/Profile/LoginLink.js +2 -5
- package/lib/components/Profile/MobileUserProfile.js +1 -4
- package/lib/components/Profile/UserProfile.js +3 -7
- package/lib/components/Scorecard/Card.d.ts +1 -3
- package/lib/components/Scorecard/Card.js +2 -4
- package/lib/components/Scorecard/Gauge.d.ts +2 -5
- package/lib/components/Scorecard/Gauge.js +2 -6
- package/lib/components/Scorecard/StatusByLevelWidget.d.ts +0 -1
- package/lib/components/Scorecard/StatusByLevelWidget.js +2 -5
- package/lib/components/Search/CancelSearch.js +1 -4
- package/lib/components/Search/RecentSearches.js +1 -4
- package/lib/components/Search/SearchDialog.js +4 -10
- package/lib/components/Search/SearchTrigger.js +1 -4
- package/lib/components/Search/SuggestedPages.js +1 -4
- package/lib/components/Sidebar/DrilldownMenu.js +2 -5
- package/lib/components/Sidebar/VersionPicker.js +2 -6
- package/lib/components/TableOfContent/TableOfContent.js +1 -4
- package/lib/config.d.ts +0 -6
- package/lib/config.js +0 -1
- package/lib/layouts/Forbidden.js +2 -6
- package/lib/layouts/NotFound.js +2 -6
- package/lib/layouts/OIDCForbidden.js +1 -4
- package/lib/mocks/hooks/index.d.ts +3 -2
- package/lib/mocks/hooks/index.js +3 -4
- package/lib/types/portal/src/shared/types/feedback.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/Catalog/Catalog.tsx +1 -4
- package/src/components/Catalog/useCatalog.ts +3 -6
- package/src/components/CodeBlock/CodeBlockControls.tsx +0 -1
- package/src/components/CopyButton/CopyButton.tsx +3 -8
- package/src/components/EditPageButton/EditPageButton.tsx +2 -5
- package/src/components/Feedback/Comment.tsx +14 -14
- package/src/components/Feedback/Feedback.tsx +2 -2
- package/src/components/Feedback/Mood.tsx +25 -20
- package/src/components/Feedback/Rating.tsx +15 -14
- package/src/components/Feedback/Reasons.tsx +6 -11
- package/src/components/Feedback/ReportDialog.tsx +6 -2
- package/src/components/Feedback/Sentiment.tsx +15 -17
- package/src/components/Feedback/Thumbs.tsx +2 -9
- package/src/components/Feedback/types.ts +1 -1
- package/src/components/Feedback/useReportDialog.ts +6 -8
- package/src/components/Filter/Filter.tsx +9 -6
- package/src/components/Filter/FilterContent.tsx +2 -6
- package/src/components/Filter/FilterPopover.tsx +2 -6
- package/src/components/Footer/FooterCopyright.tsx +2 -5
- package/src/components/LastUpdated/LastUpdated.tsx +1 -1
- package/src/components/Menu/hooks/use-mobile-menu-items.ts +1 -5
- package/src/components/Menu/hooks/use-mobile-menu-levels.ts +2 -7
- package/src/components/Menu/utils.ts +2 -1
- package/src/components/Profile/LoginLink.tsx +2 -5
- package/src/components/Profile/MobileUserProfile.tsx +1 -4
- package/src/components/Profile/UserProfile.tsx +5 -8
- package/src/components/Scorecard/Card.tsx +2 -4
- package/src/components/Scorecard/Gauge.tsx +7 -16
- package/src/components/Scorecard/StatusByLevelWidget.tsx +2 -6
- package/src/components/Search/CancelSearch.tsx +2 -5
- package/src/components/Search/RecentSearches.tsx +2 -5
- package/src/components/Search/SearchDialog.tsx +8 -15
- package/src/components/Search/SearchTrigger.tsx +3 -5
- package/src/components/Search/SuggestedPages.tsx +2 -6
- package/src/components/Sidebar/DrilldownMenu.tsx +2 -5
- package/src/components/Sidebar/VersionPicker.tsx +3 -7
- package/src/components/TableOfContent/TableOfContent.tsx +2 -5
- package/src/config.ts +0 -1
- package/src/layouts/Forbidden.tsx +4 -13
- package/src/layouts/NotFound.tsx +4 -13
- package/src/layouts/OIDCForbidden.tsx +2 -6
- package/src/mocks/hooks/index.ts +7 -6
- package/src/types/portal/src/shared/types/feedback.ts +1 -0
|
@@ -10,12 +10,6 @@ export const Comment = ({ settings, onSubmit, onCancel, className }: CommentProp
|
|
|
10
10
|
const [text, setText] = React.useState('');
|
|
11
11
|
const [submitValue, setSubmitValue] = React.useState('');
|
|
12
12
|
const { translate } = useTranslate();
|
|
13
|
-
const translationKeys = {
|
|
14
|
-
submitText: 'theme.feedback.settings.comment.submitText',
|
|
15
|
-
label: 'theme.feedback.settings.comment.label',
|
|
16
|
-
send: 'theme.feedback.settings.comment.send',
|
|
17
|
-
cancel: 'theme.feedback.settings.comment.cancel',
|
|
18
|
-
};
|
|
19
13
|
|
|
20
14
|
const send = () => {
|
|
21
15
|
if (!text) return;
|
|
@@ -29,9 +23,9 @@ export const Comment = ({ settings, onSubmit, onCancel, className }: CommentProp
|
|
|
29
23
|
if (submitValue) {
|
|
30
24
|
return (
|
|
31
25
|
<Wrapper className={className}>
|
|
32
|
-
<Label data-translation-key=
|
|
26
|
+
<Label data-translation-key="theme.feedback.settings.comment.submitText">
|
|
33
27
|
{translate(
|
|
34
|
-
|
|
28
|
+
'theme.feedback.settings.comment.submitText',
|
|
35
29
|
submitText || 'Thank you for helping improve our documentation!',
|
|
36
30
|
)}
|
|
37
31
|
</Label>
|
|
@@ -41,17 +35,23 @@ export const Comment = ({ settings, onSubmit, onCancel, className }: CommentProp
|
|
|
41
35
|
|
|
42
36
|
return (
|
|
43
37
|
<Wrapper data-component-name="Feedback/Comment" className={className}>
|
|
44
|
-
<Label data-translation-key=
|
|
45
|
-
{translate(
|
|
38
|
+
<Label data-translation-key="theme.feedback.settings.comment.label">
|
|
39
|
+
{translate(
|
|
40
|
+
'theme.feedback.settings.comment.label',
|
|
41
|
+
label || 'Please share your feedback with us.',
|
|
42
|
+
)}
|
|
46
43
|
</Label>
|
|
47
44
|
<TextArea rows={3} onChange={handleTextAreaChange} />
|
|
48
45
|
<ButtonsContainer>
|
|
49
|
-
<SendButton data-translation-key=
|
|
50
|
-
{translate(
|
|
46
|
+
<SendButton data-translation-key="theme.feedback.settings.comment.send" onClick={send}>
|
|
47
|
+
{translate('theme.feedback.settings.comment.send', 'Send')}
|
|
51
48
|
</SendButton>
|
|
52
49
|
{onCancel && (
|
|
53
|
-
<CancelButton
|
|
54
|
-
|
|
50
|
+
<CancelButton
|
|
51
|
+
data-translation-key="theme.feedback.settings.comment.cancel"
|
|
52
|
+
onClick={onCancel}
|
|
53
|
+
>
|
|
54
|
+
{translate('theme.feedback.settings.comment.cancel', 'Cancel')}
|
|
55
55
|
</CancelButton>
|
|
56
56
|
)}
|
|
57
57
|
</ButtonsContainer>
|
|
@@ -15,6 +15,8 @@ export const Feedback = (props: FeedbackProps & { path?: string }) => {
|
|
|
15
15
|
const feedbackConf = { ...themeFeedbackConf, ...props };
|
|
16
16
|
|
|
17
17
|
const renderFeedbackComponent = () => {
|
|
18
|
+
const { type, settings, path } = feedbackConf;
|
|
19
|
+
|
|
18
20
|
switch (type) {
|
|
19
21
|
case 'rating':
|
|
20
22
|
return (
|
|
@@ -70,8 +72,6 @@ export const Feedback = (props: FeedbackProps & { path?: string }) => {
|
|
|
70
72
|
}
|
|
71
73
|
};
|
|
72
74
|
|
|
73
|
-
const { type, settings, path } = feedbackConf;
|
|
74
|
-
|
|
75
75
|
return <React.Fragment key={pathname}>{renderFeedbackComponent()}</React.Fragment>;
|
|
76
76
|
};
|
|
77
77
|
|
|
@@ -15,16 +15,10 @@ export enum MOOD_STATES {
|
|
|
15
15
|
export const Mood = ({ settings, onSubmit, className }: MoodProps): JSX.Element => {
|
|
16
16
|
const { label, submitText, comment: commentSettings, reasons: reasonsSettings } = settings || {};
|
|
17
17
|
const [score, setScore] = React.useState('');
|
|
18
|
+
const [isSubmitted, setIsSubmitted] = React.useState(false);
|
|
18
19
|
const [comment, setComment] = React.useState('');
|
|
19
20
|
const [reasons, setReasons] = React.useState([] as ReasonsProps['settings']['items']);
|
|
20
21
|
const { translate } = useTranslate();
|
|
21
|
-
const translationKeys = {
|
|
22
|
-
submitText: 'theme.feedback.settings.submitText',
|
|
23
|
-
label: 'theme.feedback.settings.label',
|
|
24
|
-
satisfiedLabel: 'theme.feedback.settings.comment.satisfiedLabel',
|
|
25
|
-
neutralLabel: 'theme.feedback.settings.comment.neutralLabel',
|
|
26
|
-
dissatisfiedLabel: 'theme.feedback.settings.comment.dissatisfiedLabel',
|
|
27
|
-
};
|
|
28
22
|
|
|
29
23
|
if (score && reasonsSettings?.enable && !reasons.length) {
|
|
30
24
|
const { label: reasonsLabel, items, multi } = reasonsSettings;
|
|
@@ -42,21 +36,24 @@ export const Mood = ({ settings, onSubmit, className }: MoodProps): JSX.Element
|
|
|
42
36
|
switch (score) {
|
|
43
37
|
case MOOD_STATES.SATISFIED:
|
|
44
38
|
return translate(
|
|
45
|
-
|
|
39
|
+
'theme.feedback.settings.comment.satisfiedLabel',
|
|
46
40
|
commentSettings.satisfiedLabel || 'What was most helpful?',
|
|
47
41
|
);
|
|
48
42
|
case MOOD_STATES.NEUTRAL:
|
|
49
43
|
return translate(
|
|
50
|
-
|
|
44
|
+
'theme.feedback.settings.comment.neutralLabel',
|
|
51
45
|
commentSettings.neutralLabel || 'What can we improve?',
|
|
52
46
|
);
|
|
53
47
|
case MOOD_STATES.DISSATISFIED:
|
|
54
48
|
return translate(
|
|
55
|
-
|
|
49
|
+
'theme.feedback.settings.comment.dissatisfiedLabel',
|
|
56
50
|
commentSettings.dissatisfiedLabel || 'What can we improve?',
|
|
57
51
|
);
|
|
58
52
|
default:
|
|
59
|
-
return translate(
|
|
53
|
+
return translate(
|
|
54
|
+
'theme.feedback.settings.comment.satisfiedLabel',
|
|
55
|
+
'What can we improve?',
|
|
56
|
+
);
|
|
60
57
|
}
|
|
61
58
|
};
|
|
62
59
|
return (
|
|
@@ -68,15 +65,23 @@ export const Mood = ({ settings, onSubmit, className }: MoodProps): JSX.Element
|
|
|
68
65
|
}
|
|
69
66
|
|
|
70
67
|
if (score) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
if (!isSubmitted) {
|
|
69
|
+
onSubmit({
|
|
70
|
+
score,
|
|
71
|
+
comment,
|
|
72
|
+
reasons,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
setIsSubmitted(true);
|
|
76
|
+
}
|
|
77
|
+
|
|
76
78
|
return (
|
|
77
79
|
<Wrapper>
|
|
78
|
-
<Label data-translation-key=
|
|
79
|
-
{translate(
|
|
80
|
+
<Label data-translation-key="theme.feedback.settings.submitText">
|
|
81
|
+
{translate(
|
|
82
|
+
'theme.feedback.settings.submitText',
|
|
83
|
+
submitText || 'Thank you for your feedback!',
|
|
84
|
+
)}
|
|
80
85
|
</Label>
|
|
81
86
|
</Wrapper>
|
|
82
87
|
);
|
|
@@ -84,8 +89,8 @@ export const Mood = ({ settings, onSubmit, className }: MoodProps): JSX.Element
|
|
|
84
89
|
|
|
85
90
|
return (
|
|
86
91
|
<Wrapper data-component-name="Feedback/Mood" className={className}>
|
|
87
|
-
<Label data-translation-key=
|
|
88
|
-
{translate(
|
|
92
|
+
<Label data-translation-key="theme.feedback.settings.label">
|
|
93
|
+
{translate('theme.feedback.settings.label', label || 'Was this page helpful?')}
|
|
89
94
|
</Label>
|
|
90
95
|
<Vote
|
|
91
96
|
onClick={() => {
|
|
@@ -18,14 +18,11 @@ export const Rating = ({ settings, onSubmit, className }: RatingProps): JSX.Elem
|
|
|
18
18
|
comment: commentSettings,
|
|
19
19
|
reasons: reasonsSettings,
|
|
20
20
|
} = settings || {};
|
|
21
|
+
const [isSubmitted, setIsSubmitted] = React.useState(false);
|
|
21
22
|
const [score, setScore] = React.useState(0);
|
|
22
23
|
const [comment, setComment] = React.useState('');
|
|
23
24
|
const [reasons, setReasons] = React.useState([] as ReasonsProps['settings']['items']);
|
|
24
25
|
const { translate } = useTranslate();
|
|
25
|
-
const translationKeys = {
|
|
26
|
-
submitText: 'theme.feedback.settings.submitText',
|
|
27
|
-
label: 'theme.feedback.settings.label',
|
|
28
|
-
};
|
|
29
26
|
const maxRating = max || 5;
|
|
30
27
|
|
|
31
28
|
if (score && reasonsSettings?.enable && !reasons.length) {
|
|
@@ -49,17 +46,21 @@ export const Rating = ({ settings, onSubmit, className }: RatingProps): JSX.Elem
|
|
|
49
46
|
}
|
|
50
47
|
|
|
51
48
|
if (score) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
if (!isSubmitted) {
|
|
50
|
+
onSubmit({
|
|
51
|
+
score,
|
|
52
|
+
comment,
|
|
53
|
+
reasons,
|
|
54
|
+
max: maxRating,
|
|
55
|
+
});
|
|
56
|
+
setIsSubmitted(true);
|
|
57
|
+
}
|
|
58
|
+
|
|
58
59
|
return (
|
|
59
60
|
<Wrapper>
|
|
60
|
-
<Label data-translation-key=
|
|
61
|
+
<Label data-translation-key="theme.feedback.settings.submitText">
|
|
61
62
|
{translate(
|
|
62
|
-
|
|
63
|
+
'theme.feedback.settings.submitText',
|
|
63
64
|
submitText || 'Thank you for helping improve our documentation!',
|
|
64
65
|
)}
|
|
65
66
|
</Label>
|
|
@@ -69,8 +70,8 @@ export const Rating = ({ settings, onSubmit, className }: RatingProps): JSX.Elem
|
|
|
69
70
|
|
|
70
71
|
return (
|
|
71
72
|
<Wrapper data-component-name="Feedback/Rating" className={className}>
|
|
72
|
-
<Label data-translation-key=
|
|
73
|
-
{translate(
|
|
73
|
+
<Label data-translation-key="theme.feedback.settings.label">
|
|
74
|
+
{translate('theme.feedback.settings.label', label || 'How helpful was this page?')}
|
|
74
75
|
</Label>
|
|
75
76
|
<Stars max={maxRating} onSubmit={setScore} />
|
|
76
77
|
</Wrapper>
|
|
@@ -9,11 +9,6 @@ export const Reasons = ({ settings, onSubmit, className }: ReasonsProps): JSX.El
|
|
|
9
9
|
const { label, multi, buttonText, items = [] } = settings;
|
|
10
10
|
const [checkedState, setCheckedState] = React.useState(new Array(items.length).fill(false));
|
|
11
11
|
const { translate } = useTranslate();
|
|
12
|
-
const translationKeys = {
|
|
13
|
-
label: 'theme.feedback.settings.reasons.label',
|
|
14
|
-
items: 'theme.feedback.settings.reasons.items',
|
|
15
|
-
send: 'theme.feedback.settings.reasons.send',
|
|
16
|
-
};
|
|
17
12
|
|
|
18
13
|
if (!items.length) {
|
|
19
14
|
return <></>;
|
|
@@ -36,12 +31,12 @@ export const Reasons = ({ settings, onSubmit, className }: ReasonsProps): JSX.El
|
|
|
36
31
|
return (
|
|
37
32
|
<Wrapper
|
|
38
33
|
data-component-name="Feedback/Reasons"
|
|
39
|
-
data-translation-key=
|
|
34
|
+
data-translation-key="theme.feedback.settings.reasons.label"
|
|
40
35
|
className={className}
|
|
41
36
|
>
|
|
42
37
|
<Label>
|
|
43
38
|
{translate(
|
|
44
|
-
|
|
39
|
+
'theme.feedback.settings.reasons.label',
|
|
45
40
|
label || 'Which statement describes your thoughts about this page?',
|
|
46
41
|
)}
|
|
47
42
|
</Label>
|
|
@@ -55,16 +50,16 @@ export const Reasons = ({ settings, onSubmit, className }: ReasonsProps): JSX.El
|
|
|
55
50
|
onChange={() => handleOptionChange(idx)}
|
|
56
51
|
/>
|
|
57
52
|
<label
|
|
58
|
-
data-translation-key={
|
|
53
|
+
data-translation-key={`theme.feedback.settings.reasons.items.${idx + 1}`}
|
|
59
54
|
id={reason}
|
|
60
55
|
onClick={() => handleOptionChange(idx)}
|
|
61
56
|
>
|
|
62
|
-
{translate(
|
|
57
|
+
{translate(`theme.feedback.settings.reasons.items.${idx + 1}`, reason)}
|
|
63
58
|
</label>
|
|
64
59
|
</OptionWrapper>
|
|
65
60
|
))}
|
|
66
|
-
<SendButton data-translation-key=
|
|
67
|
-
{translate(
|
|
61
|
+
<SendButton data-translation-key="theme.feedback.settings.reasons.send" onClick={submitForm}>
|
|
62
|
+
{translate('theme.feedback.settings.reasons.send', buttonText || 'Send')}
|
|
68
63
|
</SendButton>
|
|
69
64
|
</Wrapper>
|
|
70
65
|
);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
3
4
|
|
|
5
|
+
import { telemetry } from '@portal/telemetry';
|
|
4
6
|
import { Comment } from '@theme/components/Feedback/Comment';
|
|
5
7
|
import type { ReportDialogProps } from '@theme/components/Feedback';
|
|
6
8
|
|
|
@@ -12,13 +14,15 @@ export const ReportDialog = ({
|
|
|
12
14
|
submitFeedback,
|
|
13
15
|
}: ReportDialogProps): JSX.Element => {
|
|
14
16
|
const { label } = settings;
|
|
17
|
+
const { pathname } = useLocation();
|
|
15
18
|
|
|
16
19
|
return (
|
|
17
20
|
<Wrapper className="modal">
|
|
18
21
|
<Comment
|
|
19
22
|
settings={{ label }}
|
|
20
|
-
onSubmit={(value) => {
|
|
21
|
-
submitFeedback({ type: 'problem', values: value, path:
|
|
23
|
+
onSubmit={async (value) => {
|
|
24
|
+
await submitFeedback({ type: 'problem', values: value, location, path: pathname });
|
|
25
|
+
telemetry.send('code_snippet_reported', {});
|
|
22
26
|
onSubmit();
|
|
23
27
|
}}
|
|
24
28
|
onCancel={onCancel}
|
|
@@ -8,16 +8,11 @@ import { useTranslate } from '@portal/hooks';
|
|
|
8
8
|
|
|
9
9
|
export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JSX.Element => {
|
|
10
10
|
const { label, submitText, comment: commentSettings, reasons: reasonsSettings } = settings || {};
|
|
11
|
+
const [isSubmitted, setIsSubmitted] = React.useState(false);
|
|
11
12
|
const [score, setScore] = React.useState(0);
|
|
12
13
|
const [comment, setComment] = React.useState('');
|
|
13
14
|
const [reasons, setReasons] = React.useState([] as ReasonsProps['settings']['items']);
|
|
14
15
|
const { translate } = useTranslate();
|
|
15
|
-
const translationKeys = {
|
|
16
|
-
submitText: 'theme.feedback.settings.submitText',
|
|
17
|
-
label: 'theme.feedback.settings.label',
|
|
18
|
-
likeLabel: 'theme.feedback.settings.comment.likeLabel',
|
|
19
|
-
dislikeLabel: 'theme.feedback.settings.comment.dislikeLabel',
|
|
20
|
-
};
|
|
21
16
|
|
|
22
17
|
if (score && reasonsSettings?.enable && !reasons.length) {
|
|
23
18
|
const { label: reasonsLabel, items, multi } = reasonsSettings;
|
|
@@ -34,11 +29,11 @@ export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
34
29
|
const commentLabel =
|
|
35
30
|
score === 1
|
|
36
31
|
? translate(
|
|
37
|
-
|
|
32
|
+
'theme.feedback.settings.comment.likeLabel',
|
|
38
33
|
commentSettings.likeLabel || 'What was most helpful?',
|
|
39
34
|
)
|
|
40
35
|
: translate(
|
|
41
|
-
|
|
36
|
+
'theme.feedback.settings.comment.dislikeLabel',
|
|
42
37
|
commentSettings.dislikeLabel || 'What can we improve?',
|
|
43
38
|
);
|
|
44
39
|
return (
|
|
@@ -47,16 +42,19 @@ export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
47
42
|
}
|
|
48
43
|
|
|
49
44
|
if (score) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
if (!isSubmitted) {
|
|
46
|
+
onSubmit({
|
|
47
|
+
score,
|
|
48
|
+
comment,
|
|
49
|
+
reasons,
|
|
50
|
+
});
|
|
51
|
+
setIsSubmitted(true);
|
|
52
|
+
}
|
|
55
53
|
return (
|
|
56
54
|
<Wrapper>
|
|
57
|
-
<Label data-translation-key=
|
|
55
|
+
<Label data-translation-key="theme.feedback.settings.submitText">
|
|
58
56
|
{translate(
|
|
59
|
-
|
|
57
|
+
'theme.feedback.settings.submitText',
|
|
60
58
|
submitText || 'Thank you for helping improve our documentation!',
|
|
61
59
|
)}
|
|
62
60
|
</Label>
|
|
@@ -66,8 +64,8 @@ export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
66
64
|
|
|
67
65
|
return (
|
|
68
66
|
<Wrapper data-component-name="Feedback/Sentiment" className={className}>
|
|
69
|
-
<Label data-translation-key=
|
|
70
|
-
{translate(
|
|
67
|
+
<Label data-translation-key="theme.feedback.settings.label">
|
|
68
|
+
{translate('theme.feedback.settings.label', label || 'Was this page helpful?')}
|
|
71
69
|
</Label>
|
|
72
70
|
<Vote
|
|
73
71
|
onClick={() => {
|
|
@@ -5,10 +5,6 @@ import { useTranslate } from '@portal/hooks';
|
|
|
5
5
|
|
|
6
6
|
export const ThumbUp = ({ text }: { text?: string }) => {
|
|
7
7
|
const { translate } = useTranslate();
|
|
8
|
-
const translationKeys = {
|
|
9
|
-
thumbUp: 'theme.feedback.sentiment.thumbUp',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
8
|
return (
|
|
13
9
|
<Wrapper style={{ alignItems: 'normal' }}>
|
|
14
10
|
<Icon>
|
|
@@ -50,16 +46,13 @@ export const ThumbUp = ({ text }: { text?: string }) => {
|
|
|
50
46
|
</g>
|
|
51
47
|
</svg>
|
|
52
48
|
</Icon>
|
|
53
|
-
<span>{translate(
|
|
49
|
+
<span>{translate('theme.feedback.sentiment.thumbUp', text || 'Yes')}</span>
|
|
54
50
|
</Wrapper>
|
|
55
51
|
);
|
|
56
52
|
};
|
|
57
53
|
|
|
58
54
|
export const ThumbDown = ({ text }: { text?: string }) => {
|
|
59
55
|
const { translate } = useTranslate();
|
|
60
|
-
const translationKeys = {
|
|
61
|
-
thumbDown: 'theme.feedback.sentiment.thumbDown',
|
|
62
|
-
};
|
|
63
56
|
return (
|
|
64
57
|
<Wrapper style={{ alignItems: 'end' }}>
|
|
65
58
|
<Icon>
|
|
@@ -100,7 +93,7 @@ export const ThumbDown = ({ text }: { text?: string }) => {
|
|
|
100
93
|
</g>
|
|
101
94
|
</svg>
|
|
102
95
|
</Icon>
|
|
103
|
-
<span>{translate(
|
|
96
|
+
<span>{translate('theme.feedback.sentiment.thumbDown', text || 'No')}</span>
|
|
104
97
|
</Wrapper>
|
|
105
98
|
);
|
|
106
99
|
};
|
|
@@ -90,6 +90,6 @@ export type ReportDialogProps = {
|
|
|
90
90
|
settings: {
|
|
91
91
|
label?: string;
|
|
92
92
|
};
|
|
93
|
-
submitFeedback: ({ type, values, path }: SubmitFeedbackParams) => Promise<void>;
|
|
93
|
+
submitFeedback: ({ type, values, path, location }: SubmitFeedbackParams) => Promise<void>;
|
|
94
94
|
className?: string;
|
|
95
95
|
};
|
|
@@ -3,6 +3,7 @@ import { useState } from 'react';
|
|
|
3
3
|
import type { ReportDialogProps } from '@theme/components/Feedback/types';
|
|
4
4
|
import { useTranslate } from '@portal/hooks';
|
|
5
5
|
import { useThemeConfig } from '@theme/hooks';
|
|
6
|
+
import { useSubmitFeedback } from '@portal/Feedback/useSubmitFeedback';
|
|
6
7
|
|
|
7
8
|
export interface ReportButtonProps {
|
|
8
9
|
onClick: () => void;
|
|
@@ -20,11 +21,7 @@ export function useReportDialog(): Record<string, ReportComponentsProps> {
|
|
|
20
21
|
const [isReportDialogShown, setIsReportDialogShown] = useState(false);
|
|
21
22
|
const isReportButtonShown = report?.hide === false; // TODO: report temporary disabled by default
|
|
22
23
|
const { translate } = useTranslate();
|
|
23
|
-
const
|
|
24
|
-
buttonText: 'theme.codeSnippet.report.buttonText',
|
|
25
|
-
tooltipText: 'theme.codeSnippet.report.tooltipText',
|
|
26
|
-
label: 'theme.codeSnippet.report.label',
|
|
27
|
-
};
|
|
24
|
+
const { submitFeedback } = useSubmitFeedback();
|
|
28
25
|
|
|
29
26
|
const showReportDialog = () => {
|
|
30
27
|
setIsReportDialogShown(true);
|
|
@@ -34,16 +31,17 @@ export function useReportDialog(): Record<string, ReportComponentsProps> {
|
|
|
34
31
|
};
|
|
35
32
|
const reportButtonProps: ReportButtonProps = {
|
|
36
33
|
onClick: showReportDialog,
|
|
37
|
-
buttonText: translate(
|
|
38
|
-
tooltip: translate(
|
|
34
|
+
buttonText: translate('theme.codeSnippet.report.buttonText', 'Report'),
|
|
35
|
+
tooltip: translate('theme.codeSnippet.report.tooltipText', 'Report a problem'),
|
|
39
36
|
visible: isReportButtonShown,
|
|
40
37
|
};
|
|
41
38
|
const reportDialogProps: Partial<ReportDialogProps> = {
|
|
42
39
|
settings: {
|
|
43
|
-
label: translate(
|
|
40
|
+
label: translate('theme.codeSnippet.report.label', 'What is wrong with this code?'),
|
|
44
41
|
},
|
|
45
42
|
onSubmit: hideReportDialog,
|
|
46
43
|
onCancel: hideReportDialog,
|
|
44
|
+
submitFeedback,
|
|
47
45
|
};
|
|
48
46
|
|
|
49
47
|
return {
|
|
@@ -16,10 +16,6 @@ export function Filter({
|
|
|
16
16
|
filterValuesCasing?: NonNullable<ThemeConfig['catalog']>[string]['filterValuesCasing'];
|
|
17
17
|
}) {
|
|
18
18
|
const { translate } = useTranslate();
|
|
19
|
-
const translationKeys = {
|
|
20
|
-
selectAll: 'theme.catalog.filters.select.all',
|
|
21
|
-
clear: 'theme.catalog.filters.clear',
|
|
22
|
-
};
|
|
23
19
|
|
|
24
20
|
if (!filter.parentUsed) return null;
|
|
25
21
|
|
|
@@ -34,7 +30,9 @@ export function Filter({
|
|
|
34
30
|
value: '',
|
|
35
31
|
element: (
|
|
36
32
|
<FilterOption key="all" onClick={() => filter.selectOption('')}>
|
|
37
|
-
<FilterOptionLabel>
|
|
33
|
+
<FilterOptionLabel>
|
|
34
|
+
{translate('theme.catalog.filters.select.all', 'All')}
|
|
35
|
+
</FilterOptionLabel>
|
|
38
36
|
<FilterOptionCount>{defaultOptionCount}</FilterOptionCount>
|
|
39
37
|
</FilterOption>
|
|
40
38
|
),
|
|
@@ -111,7 +109,7 @@ export function Filter({
|
|
|
111
109
|
</>
|
|
112
110
|
) : (
|
|
113
111
|
filter.filteredOptions.map((value: any) => {
|
|
114
|
-
const id = 'filter--' + filter.property + '--' + value.value;
|
|
112
|
+
const id = 'filter--' + filter.property + '--' + slug(value.value);
|
|
115
113
|
return (
|
|
116
114
|
<FilterOption key={id} role="link" onClick={() => filter.toggleOption(value.value)}>
|
|
117
115
|
<CheckboxIcon checked={filter.selectedOptions.has(value.value)} />
|
|
@@ -212,6 +210,11 @@ const StyledSelect = styled(Select)`
|
|
|
212
210
|
}
|
|
213
211
|
`;
|
|
214
212
|
|
|
213
|
+
// TODO: import from portal
|
|
214
|
+
function slug(str: string): string {
|
|
215
|
+
return str.replace(/\s/g, '-').toLowerCase();
|
|
216
|
+
}
|
|
217
|
+
|
|
215
218
|
const DatePickerWrapper = styled.div`
|
|
216
219
|
color: var(--filter-date-picker-color);
|
|
217
220
|
display: flex;
|
|
@@ -26,10 +26,6 @@ export function FilterContent({
|
|
|
26
26
|
filterValuesCasing,
|
|
27
27
|
}: FilterContentProps) {
|
|
28
28
|
const { translate } = useTranslate();
|
|
29
|
-
const translationKeys = {
|
|
30
|
-
placeholder: 'theme.catalog.filters.placeholder',
|
|
31
|
-
clearAll: 'theme.catalog.filters.clearAll',
|
|
32
|
-
};
|
|
33
29
|
|
|
34
30
|
const hasActiveFilters = filters.some((filter) => {
|
|
35
31
|
if (filterTerm) return true;
|
|
@@ -49,7 +45,7 @@ export function FilterContent({
|
|
|
49
45
|
<FilterContentWrapper isMobile={isMobile}>
|
|
50
46
|
<FilterControls>
|
|
51
47
|
<StyledInput
|
|
52
|
-
placeholder={translate(
|
|
48
|
+
placeholder={translate('theme.catalog.filters.placeholder', 'Type to filter...')}
|
|
53
49
|
value={filterTerm}
|
|
54
50
|
onChange={(e) => setFilterTerm(e.target.value)}
|
|
55
51
|
/>
|
|
@@ -66,7 +62,7 @@ export function FilterContent({
|
|
|
66
62
|
{hasActiveFilters && (
|
|
67
63
|
<ActionsContainer>
|
|
68
64
|
<ClearAllButton size="default" variant="outlined" onClick={handleClearAll}>
|
|
69
|
-
{translate(
|
|
65
|
+
{translate('theme.catalog.filters.clearAll', 'Clear all filters')}
|
|
70
66
|
</ClearAllButton>
|
|
71
67
|
</ActionsContainer>
|
|
72
68
|
)}
|
|
@@ -34,10 +34,6 @@ export function FilterPopover({
|
|
|
34
34
|
})
|
|
35
35
|
.filter(Boolean) as ResolvedFilter[];
|
|
36
36
|
|
|
37
|
-
const translationKeys = {
|
|
38
|
-
placeholder: 'theme.catalog.filters.placeholder',
|
|
39
|
-
done: 'theme.catalog.filters.done',
|
|
40
|
-
};
|
|
41
37
|
const { translate } = useTranslate();
|
|
42
38
|
|
|
43
39
|
return (
|
|
@@ -45,7 +41,7 @@ export function FilterPopover({
|
|
|
45
41
|
<FilterPopoverHeader>
|
|
46
42
|
<FilterPopoverHeaderLabel>Add Filter</FilterPopoverHeaderLabel>
|
|
47
43
|
<FilterPopoverHeaderButton onClick={() => setIsAddingFilter(false)}>
|
|
48
|
-
{translate(
|
|
44
|
+
{translate('theme.catalog.filters.done', 'Done')}
|
|
49
45
|
</FilterPopoverHeaderButton>
|
|
50
46
|
</FilterPopoverHeader>
|
|
51
47
|
<FilterContent
|
|
@@ -57,7 +53,7 @@ export function FilterPopover({
|
|
|
57
53
|
/>
|
|
58
54
|
<FilterControls>
|
|
59
55
|
<StyledInput
|
|
60
|
-
placeholder={translate(
|
|
56
|
+
placeholder={translate('theme.catalog.filters.placeholder', 'Type to filter...')}
|
|
61
57
|
value={filterTerm}
|
|
62
58
|
onChange={(e) => setFilterTerm(e.target.value)}
|
|
63
59
|
/>
|
|
@@ -16,16 +16,13 @@ export function FooterCopyright({
|
|
|
16
16
|
const { translate } = useTranslate();
|
|
17
17
|
const { changeLanguage } = useI18n();
|
|
18
18
|
|
|
19
|
-
const translationKeys = {
|
|
20
|
-
copyrightText: 'theme.footer.copyrightText',
|
|
21
|
-
};
|
|
22
19
|
return copyrightText ? (
|
|
23
20
|
<Wrapper
|
|
24
21
|
className={className}
|
|
25
22
|
data-component-name="Footer/FooterCopyright"
|
|
26
|
-
data-translation-key=
|
|
23
|
+
data-translation-key="theme.footer.copyrightText"
|
|
27
24
|
>
|
|
28
|
-
<Label>{translate(
|
|
25
|
+
<Label>{translate('theme.footer.copyrightText', copyrightText)}</Label>
|
|
29
26
|
<LanguagePicker onChangeLanguage={changeLanguage} placement="top" alignment="end" />
|
|
30
27
|
</Wrapper>
|
|
31
28
|
) : null;
|
|
@@ -40,7 +40,7 @@ export function LastUpdated(props: LastUpdatedProps): JSX.Element | null {
|
|
|
40
40
|
|
|
41
41
|
const text =
|
|
42
42
|
format === 'timeago'
|
|
43
|
-
? translate(translationKey, 'Last updated '
|
|
43
|
+
? translate(translationKey, 'Last updated') + ' '
|
|
44
44
|
: translate(translationKey, 'Last updated on');
|
|
45
45
|
|
|
46
46
|
return (
|
|
@@ -13,10 +13,6 @@ const MENU_SEPARATOR: ResolvedNavItem = {
|
|
|
13
13
|
separatorLine: true,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
const TRANSLATION_KEYS = {
|
|
17
|
-
products: 'theme.mobileMenu.products',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
16
|
export const useMobileMenuItems = (menuType: MenuType) => {
|
|
21
17
|
const { versions = [] } = usePageVersions() || {};
|
|
22
18
|
const { defaultLocale, currentLocale, locales } = useI18nConfig();
|
|
@@ -71,7 +67,7 @@ export const useMobileMenuItems = (menuType: MenuType) => {
|
|
|
71
67
|
if (productMenuItems.length) {
|
|
72
68
|
menuItems.push({
|
|
73
69
|
type: 'separator',
|
|
74
|
-
label: translate(
|
|
70
|
+
label: translate('theme.mobileMenu.products', 'Products'),
|
|
75
71
|
});
|
|
76
72
|
|
|
77
73
|
menuItems.push(...productMenuItems);
|
|
@@ -7,11 +7,6 @@ import { MenuType } from '@theme/components/Menu/constants';
|
|
|
7
7
|
import { useThemeConfig } from '@theme/hooks';
|
|
8
8
|
import type { ResolvedNavItem } from '@theme/types/portal';
|
|
9
9
|
|
|
10
|
-
const TRANSLATION_KEYS = {
|
|
11
|
-
mainMenu: 'theme.mobileMenu.mainMenu',
|
|
12
|
-
previous: 'theme.mobileMenu.previous',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
10
|
export const useMobileMenuLevels = () => {
|
|
16
11
|
const { versions = [] } = usePageVersions() || {};
|
|
17
12
|
const activeVersion = versions.find((version) => version?.active);
|
|
@@ -29,7 +24,7 @@ export const useMobileMenuLevels = () => {
|
|
|
29
24
|
const menuLevels = useMemo(() => {
|
|
30
25
|
const menuLevels = [
|
|
31
26
|
{
|
|
32
|
-
label: translate(
|
|
27
|
+
label: translate('theme.mobileMenu.mainMenu', 'Main Menu'),
|
|
33
28
|
type: MenuType.MAIN_MENU,
|
|
34
29
|
},
|
|
35
30
|
];
|
|
@@ -43,7 +38,7 @@ export const useMobileMenuLevels = () => {
|
|
|
43
38
|
|
|
44
39
|
if (sidebarItems.length || activeVersion) {
|
|
45
40
|
menuLevels.push({
|
|
46
|
-
label: translate(
|
|
41
|
+
label: translate('theme.mobileMenu.previous', 'Previous'),
|
|
47
42
|
type: MenuType.PAGE,
|
|
48
43
|
});
|
|
49
44
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Location } from 'react-router-dom';
|
|
2
|
+
import type { TFunction } from '@redocly/portal-types';
|
|
2
3
|
|
|
3
4
|
import type { ItemState } from '@theme/components/Sidebar/types';
|
|
4
|
-
import type { Locale, ResolvedNavItem,
|
|
5
|
+
import type { Locale, ResolvedNavItem, Version } from '@theme/types/portal';
|
|
5
6
|
import { getPathnameForLocale } from '@portal/utils';
|
|
6
7
|
import { withPathPrefix } from '@theme/utils/urls';
|
|
7
8
|
|