@orchestrator-ui/orchestrator-ui-components 1.8.0 → 1.9.0
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/.turbo/turbo-build.log +4 -4
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +7 -7
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +1039 -906
- package/package.json +1 -1
- package/src/components/WfoPageTemplate/WfoSidebar/WfoMenuLink.tsx +50 -0
- package/src/components/WfoPageTemplate/WfoSidebar/WfoSidebar.tsx +106 -44
- package/src/components/WfoPageTemplate/WfoSidebar/index.ts +1 -0
- package/src/components/WfoPageTemplate/WfoSidebar/styles.ts +62 -1
package/package.json
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useTranslations } from 'next-intl';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
|
|
6
|
+
import { useWithOrchestratorTheme } from '@/hooks';
|
|
7
|
+
|
|
8
|
+
import { getMenuItemStyles } from './styles';
|
|
9
|
+
|
|
10
|
+
type WfoMenuItemLinkProps = {
|
|
11
|
+
path: string;
|
|
12
|
+
translationString: string;
|
|
13
|
+
isSelected: boolean;
|
|
14
|
+
isSubItem?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const WfoMenuItemLink: FC<WfoMenuItemLinkProps> = ({
|
|
18
|
+
path,
|
|
19
|
+
translationString,
|
|
20
|
+
isSelected,
|
|
21
|
+
isSubItem,
|
|
22
|
+
}) => {
|
|
23
|
+
const {
|
|
24
|
+
menuItemStyle,
|
|
25
|
+
selectedMenuItem,
|
|
26
|
+
selectedSubMenuItem,
|
|
27
|
+
subMenuItemStyle,
|
|
28
|
+
} = useWithOrchestratorTheme(getMenuItemStyles);
|
|
29
|
+
|
|
30
|
+
const getMenuItemStyle = () => {
|
|
31
|
+
if (isSubItem) {
|
|
32
|
+
return isSelected ? selectedSubMenuItem : subMenuItemStyle;
|
|
33
|
+
} else {
|
|
34
|
+
return isSelected ? selectedMenuItem : menuItemStyle;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const t = useTranslations('main');
|
|
39
|
+
|
|
40
|
+
// This is a workaround to use the translation string as the link text if it's not found in the translation file.
|
|
41
|
+
const linkText =
|
|
42
|
+
t(translationString) === `main.${translationString}`
|
|
43
|
+
? translationString
|
|
44
|
+
: t(translationString);
|
|
45
|
+
return (
|
|
46
|
+
<Link css={getMenuItemStyle()} href={path}>
|
|
47
|
+
{linkText}
|
|
48
|
+
</Link>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
PATH_WORKFLOWS,
|
|
26
26
|
} from '../paths';
|
|
27
27
|
import { WfoCopyright } from './WfoCopyright';
|
|
28
|
+
import { WfoMenuItemLink } from './WfoMenuLink';
|
|
28
29
|
|
|
29
30
|
export const renderEmptyElementWhenNotAllowedByPolicy = (isAllowed: boolean) =>
|
|
30
31
|
isAllowed ? undefined : () => <></>;
|
|
@@ -46,6 +47,7 @@ export type WfoSidebarProps = {
|
|
|
46
47
|
export const WfoSidebar: FC<WfoSidebarProps> = ({ overrideMenuItems }) => {
|
|
47
48
|
const t = useTranslations('main');
|
|
48
49
|
const router = useRouter();
|
|
50
|
+
|
|
49
51
|
const [isSideNavOpenOnMobile, setIsSideNavOpenOnMobile] = useState(false);
|
|
50
52
|
const { isAllowed } = usePolicy();
|
|
51
53
|
|
|
@@ -53,90 +55,144 @@ export const WfoSidebar: FC<WfoSidebarProps> = ({ overrideMenuItems }) => {
|
|
|
53
55
|
setIsSideNavOpenOnMobile((openState) => !openState);
|
|
54
56
|
};
|
|
55
57
|
|
|
58
|
+
// Note: href is used to determine if the user has access to the page in
|
|
59
|
+
// defaultMenuItemsFilteredByPolicy so we need to keep it in the item although we don't use it in the render.
|
|
56
60
|
const defaultMenuItems: EuiSideNavItemType<object>[] = [
|
|
57
61
|
{
|
|
58
62
|
name: t('start'),
|
|
59
63
|
id: '2',
|
|
60
64
|
isSelected: router.pathname === PATH_START,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
href: PATH_START,
|
|
66
|
+
renderItem: () => (
|
|
67
|
+
<WfoMenuItemLink
|
|
68
|
+
path={PATH_START}
|
|
69
|
+
translationString="start"
|
|
70
|
+
isSelected={router.pathname === PATH_START}
|
|
71
|
+
/>
|
|
72
|
+
),
|
|
65
73
|
},
|
|
66
74
|
{
|
|
67
75
|
name: t('workflows'),
|
|
68
76
|
id: '3',
|
|
69
77
|
isSelected: router.pathname === PATH_WORKFLOWS,
|
|
70
78
|
href: PATH_WORKFLOWS,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
renderItem: () => (
|
|
80
|
+
<WfoMenuItemLink
|
|
81
|
+
path={PATH_WORKFLOWS}
|
|
82
|
+
translationString="workflows"
|
|
83
|
+
isSelected={router.pathname === PATH_WORKFLOWS}
|
|
84
|
+
/>
|
|
85
|
+
),
|
|
75
86
|
},
|
|
76
87
|
{
|
|
77
88
|
name: t('subscriptions'),
|
|
78
89
|
id: '4',
|
|
79
90
|
isSelected: router.pathname === PATH_SUBSCRIPTIONS,
|
|
80
91
|
href: PATH_SUBSCRIPTIONS,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
renderItem: () => (
|
|
93
|
+
<WfoMenuItemLink
|
|
94
|
+
path={PATH_SUBSCRIPTIONS}
|
|
95
|
+
translationString="subscriptions"
|
|
96
|
+
isSelected={router.pathname === PATH_SUBSCRIPTIONS}
|
|
97
|
+
/>
|
|
98
|
+
),
|
|
85
99
|
},
|
|
86
100
|
{
|
|
87
101
|
name: t('metadata'),
|
|
88
102
|
id: '5',
|
|
89
103
|
href: PATH_METADATA,
|
|
90
|
-
|
|
91
|
-
router.
|
|
92
|
-
|
|
104
|
+
isSelected:
|
|
105
|
+
router.pathname.substring(0, PATH_METADATA.length) ===
|
|
106
|
+
PATH_METADATA,
|
|
107
|
+
renderItem: () => (
|
|
108
|
+
<WfoMenuItemLink
|
|
109
|
+
path={PATH_METADATA_PRODUCTS}
|
|
110
|
+
translationString="metadata"
|
|
111
|
+
isSelected={
|
|
112
|
+
router.pathname.substring(0, PATH_METADATA.length) ===
|
|
113
|
+
PATH_METADATA
|
|
114
|
+
}
|
|
115
|
+
/>
|
|
116
|
+
),
|
|
93
117
|
items: [
|
|
94
118
|
{
|
|
95
119
|
name: t('metadataProducts'),
|
|
96
120
|
id: '5.1',
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
121
|
+
href: PATH_METADATA_PRODUCTS,
|
|
122
|
+
renderItem: () => (
|
|
123
|
+
<WfoMenuItemLink
|
|
124
|
+
path={PATH_METADATA_PRODUCTS}
|
|
125
|
+
translationString="metadataProducts"
|
|
126
|
+
isSelected={
|
|
127
|
+
router.pathname === PATH_METADATA_PRODUCTS
|
|
128
|
+
}
|
|
129
|
+
isSubItem={true}
|
|
130
|
+
/>
|
|
131
|
+
),
|
|
102
132
|
},
|
|
103
133
|
{
|
|
104
134
|
name: t('metadataProductblocks'),
|
|
105
135
|
id: '5.2',
|
|
106
136
|
isSelected:
|
|
107
137
|
router.pathname === PATH_METADATA_PRODUCT_BLOCKS,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
138
|
+
href: PATH_METADATA_PRODUCT_BLOCKS,
|
|
139
|
+
renderItem: () => (
|
|
140
|
+
<WfoMenuItemLink
|
|
141
|
+
path={PATH_METADATA_PRODUCT_BLOCKS}
|
|
142
|
+
translationString="metadataProductblocks"
|
|
143
|
+
isSelected={
|
|
144
|
+
router.pathname === PATH_METADATA_PRODUCT_BLOCKS
|
|
145
|
+
}
|
|
146
|
+
isSubItem={true}
|
|
147
|
+
/>
|
|
148
|
+
),
|
|
112
149
|
},
|
|
113
150
|
{
|
|
114
151
|
name: t('metadataResourceTypes'),
|
|
115
152
|
id: '5.3',
|
|
153
|
+
href: PATH_METADATA_RESOURCE_TYPES,
|
|
116
154
|
isSelected:
|
|
117
155
|
router.pathname === PATH_METADATA_RESOURCE_TYPES,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
156
|
+
renderItem: () => (
|
|
157
|
+
<WfoMenuItemLink
|
|
158
|
+
path={PATH_METADATA_RESOURCE_TYPES}
|
|
159
|
+
translationString="metadataResourceTypes"
|
|
160
|
+
isSelected={
|
|
161
|
+
router.pathname === PATH_METADATA_RESOURCE_TYPES
|
|
162
|
+
}
|
|
163
|
+
isSubItem={true}
|
|
164
|
+
/>
|
|
165
|
+
),
|
|
122
166
|
},
|
|
123
167
|
{
|
|
124
168
|
name: t('metadataWorkflows'),
|
|
125
169
|
id: '5.4',
|
|
126
170
|
isSelected: router.pathname === PATH_METADATA_WORKFLOWS,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
171
|
+
href: PATH_METADATA_WORKFLOWS,
|
|
172
|
+
renderItem: () => (
|
|
173
|
+
<WfoMenuItemLink
|
|
174
|
+
path={PATH_METADATA_WORKFLOWS}
|
|
175
|
+
translationString="metadataWorkflows"
|
|
176
|
+
isSelected={
|
|
177
|
+
router.pathname === PATH_METADATA_WORKFLOWS
|
|
178
|
+
}
|
|
179
|
+
isSubItem={true}
|
|
180
|
+
/>
|
|
181
|
+
),
|
|
131
182
|
},
|
|
132
183
|
{
|
|
133
184
|
name: t('metadataTasks'),
|
|
134
185
|
id: '5.5',
|
|
135
186
|
isSelected: router.pathname === PATH_METADATA_TASKS,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
187
|
+
href: PATH_METADATA_TASKS,
|
|
188
|
+
renderItem: () => (
|
|
189
|
+
<WfoMenuItemLink
|
|
190
|
+
path={PATH_METADATA_TASKS}
|
|
191
|
+
translationString="metadataTasks"
|
|
192
|
+
isSelected={router.pathname === PATH_METADATA_TASKS}
|
|
193
|
+
isSubItem={true}
|
|
194
|
+
/>
|
|
195
|
+
),
|
|
140
196
|
},
|
|
141
197
|
],
|
|
142
198
|
},
|
|
@@ -144,21 +200,27 @@ export const WfoSidebar: FC<WfoSidebarProps> = ({ overrideMenuItems }) => {
|
|
|
144
200
|
name: t('tasks'),
|
|
145
201
|
isSelected: router.pathname === PATH_TASKS,
|
|
146
202
|
id: '6',
|
|
147
|
-
onClick: (e) => {
|
|
148
|
-
e.preventDefault();
|
|
149
|
-
router.push(PATH_TASKS);
|
|
150
|
-
},
|
|
151
203
|
href: PATH_TASKS,
|
|
204
|
+
renderItem: () => (
|
|
205
|
+
<WfoMenuItemLink
|
|
206
|
+
path={PATH_TASKS}
|
|
207
|
+
translationString="tasks"
|
|
208
|
+
isSelected={router.pathname === PATH_TASKS}
|
|
209
|
+
/>
|
|
210
|
+
),
|
|
152
211
|
},
|
|
153
212
|
{
|
|
154
213
|
name: t('settings'),
|
|
155
214
|
isSelected: router.pathname === PATH_SETTINGS,
|
|
156
215
|
id: '7',
|
|
157
|
-
onClick: (e) => {
|
|
158
|
-
e.preventDefault();
|
|
159
|
-
router.push(PATH_SETTINGS);
|
|
160
|
-
},
|
|
161
216
|
href: PATH_SETTINGS,
|
|
217
|
+
renderItem: () => (
|
|
218
|
+
<WfoMenuItemLink
|
|
219
|
+
path={PATH_SETTINGS}
|
|
220
|
+
translationString="settings"
|
|
221
|
+
isSelected={router.pathname === PATH_SETTINGS}
|
|
222
|
+
/>
|
|
223
|
+
),
|
|
162
224
|
},
|
|
163
225
|
];
|
|
164
226
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EuiThemeComputed } from '@elastic/eui';
|
|
2
|
-
import { css } from '@emotion/react';
|
|
2
|
+
import { CSSObject, css } from '@emotion/react';
|
|
3
3
|
|
|
4
4
|
export const getCopyrightStyles = (theme: EuiThemeComputed) => {
|
|
5
5
|
const copyrightStyle = css({
|
|
@@ -15,3 +15,64 @@ export const getCopyrightStyles = (theme: EuiThemeComputed) => {
|
|
|
15
15
|
copyrightStyle,
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
+
|
|
19
|
+
export const getMenuItemStyles = (theme: EuiThemeComputed) => {
|
|
20
|
+
const baseStyles: CSSObject = {
|
|
21
|
+
lineHeight: `${theme.base * 1.25}px`,
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
':hover': {
|
|
25
|
+
textDecoration: 'underline',
|
|
26
|
+
},
|
|
27
|
+
color: theme.colors.text,
|
|
28
|
+
padding: `${theme.base * 0.5}px ${theme.base * 0.75}px`,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const baseSubMenuStyles: CSSObject = {
|
|
32
|
+
...baseStyles,
|
|
33
|
+
':after': {
|
|
34
|
+
content: "''",
|
|
35
|
+
top: '16px',
|
|
36
|
+
left: 0,
|
|
37
|
+
width: '4px',
|
|
38
|
+
height: '1px',
|
|
39
|
+
backgroundColor: '#d3dae6',
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
},
|
|
42
|
+
padding: '8px 12px',
|
|
43
|
+
':last-child': {
|
|
44
|
+
top: '-4px',
|
|
45
|
+
position: 'relative',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const menuItemStyle = css({
|
|
50
|
+
...baseStyles,
|
|
51
|
+
color: theme.colors.title,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const selectedMenuItem = css({
|
|
55
|
+
...baseStyles,
|
|
56
|
+
height: `${theme.base * 2.25}px`,
|
|
57
|
+
backgroundColor: theme.colors.lightShade,
|
|
58
|
+
borderRadius: theme.border.radius.medium,
|
|
59
|
+
fontWeight: theme.font.weight.semiBold,
|
|
60
|
+
color: theme.colors.primaryText,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const selectedSubMenuItem = css({
|
|
64
|
+
...baseSubMenuStyles,
|
|
65
|
+
fontWeight: theme.font.weight.semiBold,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const subMenuItemStyle = css({
|
|
69
|
+
...baseSubMenuStyles,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
menuItemStyle,
|
|
74
|
+
selectedMenuItem,
|
|
75
|
+
selectedSubMenuItem,
|
|
76
|
+
subMenuItemStyle,
|
|
77
|
+
};
|
|
78
|
+
};
|