@oneuptime/common 7.0.4699 → 7.0.4717
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/Server/Services/StatusPageService.ts +1 -1
- package/UI/Components/Banner/Banner.tsx +4 -1
- package/UI/Components/Button/Button.tsx +9 -9
- package/UI/Components/Card/Card.tsx +2 -2
- package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +2 -2
- package/UI/Components/Date/StartAndEndDate.tsx +8 -3
- package/UI/Components/HeaderAlert/HeaderAlert.tsx +9 -1
- package/UI/Components/HeaderAlert/HeaderModelAlert.tsx +2 -1
- package/UI/Components/Modal/Modal.tsx +16 -14
- package/UI/Components/Modal/ModalFooter.tsx +1 -1
- package/UI/Components/Page/Page.tsx +3 -3
- package/UI/Components/SideMenu/SideMenu.tsx +289 -13
- package/UI/Components/SideMenu/SideMenuSection.tsx +2 -2
- package/UI/Components/Table/Table.tsx +48 -25
- package/UI/Components/Table/TableBody.tsx +52 -0
- package/UI/Components/Table/TableRow.tsx +221 -0
- package/build/dist/Server/Services/StatusPageService.js +2 -1
- package/build/dist/Server/Services/StatusPageService.js.map +1 -1
- package/build/dist/UI/Components/Banner/Banner.js +1 -1
- package/build/dist/UI/Components/Banner/Banner.js.map +1 -1
- package/build/dist/UI/Components/Button/Button.js +9 -9
- package/build/dist/UI/Components/Card/Card.js +2 -2
- package/build/dist/UI/Components/Card/Card.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +2 -2
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
- package/build/dist/UI/Components/Date/StartAndEndDate.js +8 -8
- package/build/dist/UI/Components/Date/StartAndEndDate.js.map +1 -1
- package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js +2 -1
- package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js.map +1 -1
- package/build/dist/UI/Components/HeaderAlert/HeaderModelAlert.js +1 -1
- package/build/dist/UI/Components/HeaderAlert/HeaderModelAlert.js.map +1 -1
- package/build/dist/UI/Components/Modal/Modal.js +14 -14
- package/build/dist/UI/Components/Modal/Modal.js.map +1 -1
- package/build/dist/UI/Components/Modal/ModalFooter.js +1 -1
- package/build/dist/UI/Components/Modal/ModalFooter.js.map +1 -1
- package/build/dist/UI/Components/Page/Page.js +3 -3
- package/build/dist/UI/Components/Page/Page.js.map +1 -1
- package/build/dist/UI/Components/SideMenu/SideMenu.js +125 -11
- package/build/dist/UI/Components/SideMenu/SideMenu.js.map +1 -1
- package/build/dist/UI/Components/SideMenu/SideMenuSection.js +2 -2
- package/build/dist/UI/Components/SideMenu/SideMenuSection.js.map +1 -1
- package/build/dist/UI/Components/Table/Table.js +29 -15
- package/build/dist/UI/Components/Table/Table.js.map +1 -1
- package/build/dist/UI/Components/Table/TableBody.js +19 -1
- package/build/dist/UI/Components/Table/TableBody.js.map +1 -1
- package/build/dist/UI/Components/Table/TableRow.js +68 -0
- package/build/dist/UI/Components/Table/TableRow.js.map +1 -1
- package/package.json +1 -1
|
@@ -157,7 +157,7 @@ export class Service extends DatabaseService<StatusPage> {
|
|
|
157
157
|
if (!createBy.data.subscriberEmailNotificationFooterText) {
|
|
158
158
|
createBy.data.subscriberEmailNotificationFooterText =
|
|
159
159
|
"This is an automated email sent to you because you are subscribed to " +
|
|
160
|
-
createBy.data.name;
|
|
160
|
+
(createBy.data?.pageTitle || createBy.data?.name || "Status Page");
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
return {
|
|
@@ -9,6 +9,7 @@ export interface ComponentProps {
|
|
|
9
9
|
description: string;
|
|
10
10
|
link?: URL | Route | undefined;
|
|
11
11
|
openInNewTab?: boolean | undefined;
|
|
12
|
+
hideOnMobile?: boolean | undefined;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
const Banner: FunctionComponent<ComponentProps> = (
|
|
@@ -32,7 +33,9 @@ const Banner: FunctionComponent<ComponentProps> = (
|
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
return (
|
|
35
|
-
<div
|
|
36
|
+
<div
|
|
37
|
+
className={`flex border-gray-200 rounded-xl border-2 py-2.5 px-6 sm:px-3.5${props.hideOnMobile ? " hidden md:flex" : ""}`}
|
|
38
|
+
>
|
|
36
39
|
<p className="text-sm text-gray-400 hover:text-gray-500">
|
|
37
40
|
{props.link && (
|
|
38
41
|
<Link to={props.link} openInNewTab={props.openInNewTab}>
|
|
@@ -107,7 +107,7 @@ const Button: FunctionComponent<ComponentProps> = ({
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
let buttonStyleCssClass: string = `inline-flex w-full justify-center rounded-md border border-gray-300 bg-white text-base font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2
|
|
110
|
+
let buttonStyleCssClass: string = `inline-flex w-full justify-center rounded-md border border-gray-300 bg-white text-base font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 md:mt-0 md:ml-3 md:w-auto md:text-sm`;
|
|
111
111
|
let loadingIconClassName: string = `w-5 h-5 mr-3 -ml-1 mr-1 animate-spin`;
|
|
112
112
|
let iconClassName: string = `w-5 h-5`;
|
|
113
113
|
|
|
@@ -139,20 +139,20 @@ const Button: FunctionComponent<ComponentProps> = ({
|
|
|
139
139
|
if (buttonStyle === ButtonStyleType.DANGER) {
|
|
140
140
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-transparent bg-red-600 text-base font-medium text-white shadow-sm ${
|
|
141
141
|
disabled ? "hover:bg-red-700" : ""
|
|
142
|
-
} focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2
|
|
142
|
+
} focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 md:ml-3 md:w-auto md:text-sm`;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
if (buttonStyle === ButtonStyleType.DANGER_OUTLINE) {
|
|
146
146
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-red-700 bg-white text-base font-medium text-red-700 shadow-sm ${
|
|
147
147
|
disabled ? "hover:bg-red-50" : ""
|
|
148
|
-
} focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2
|
|
148
|
+
} focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 md:mt-0 md:ml-3 md:w-auto md:text-sm`;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
if (buttonStyle === ButtonStyleType.PRIMARY) {
|
|
152
152
|
loadingIconClassName += ` text-indigo-100`;
|
|
153
153
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-transparent bg-indigo-600 text-base font-medium text-white shadow-sm ${
|
|
154
154
|
disabled ? "hover:bg-indigo-700" : ""
|
|
155
|
-
} focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2
|
|
155
|
+
} focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 md:ml-3 md:w-auto md:text-sm`;
|
|
156
156
|
|
|
157
157
|
if (disabled) {
|
|
158
158
|
buttonStyleCssClass += ` bg-indigo-300`;
|
|
@@ -188,7 +188,7 @@ const Button: FunctionComponent<ComponentProps> = ({
|
|
|
188
188
|
buttonStyle === ButtonStyleType.HOVER_SUCCESS_OUTLINE ||
|
|
189
189
|
buttonStyle === ButtonStyleType.HOVER_PRIMARY_OUTLINE
|
|
190
190
|
) {
|
|
191
|
-
buttonStyleCssClass = `flex btn-outline-secondary background-very-light-Gray500-on-hover
|
|
191
|
+
buttonStyleCssClass = `flex btn-outline-secondary background-very-light-Gray500-on-hover md:text-sm ml-1`;
|
|
192
192
|
|
|
193
193
|
if (buttonStyle === ButtonStyleType.HOVER_DANGER_OUTLINE) {
|
|
194
194
|
buttonStyleCssClass += ` hover:text-red-500`;
|
|
@@ -206,25 +206,25 @@ const Button: FunctionComponent<ComponentProps> = ({
|
|
|
206
206
|
if (buttonStyle === ButtonStyleType.SUCCESS) {
|
|
207
207
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-transparent bg-green-600 text-base font-medium text-white shadow-sm ${
|
|
208
208
|
disabled ? "hover:bg-green-700" : ""
|
|
209
|
-
} focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2
|
|
209
|
+
} focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2 md:ml-3 md:w-auto md:text-sm`;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
if (buttonStyle === ButtonStyleType.SUCCESS_OUTLINE) {
|
|
213
213
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-green-700 bg-white text-base font-medium text-green-700 shadow-sm ${
|
|
214
214
|
disabled ? "hover:bg-green-50" : ""
|
|
215
|
-
} focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2
|
|
215
|
+
} focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2 md:mt-0 md:ml-3 md:w-auto md:text-sm`;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
if (buttonStyle === ButtonStyleType.WARNING) {
|
|
219
219
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-transparent bg-yellow-600 text-base font-medium text-white shadow-sm ${
|
|
220
220
|
disabled ? "hover:bg-yellow-700" : ""
|
|
221
|
-
} focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2
|
|
221
|
+
} focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2 md:ml-3 md:w-auto md:text-sm`;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
if (buttonStyle === ButtonStyleType.WARNING_OUTLINE) {
|
|
225
225
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-yellow-700 bg-white text-base font-medium text-yellow-700 shadow-sm ${
|
|
226
226
|
disabled ? "hover:bg-yellow-50" : ""
|
|
227
|
-
} focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2
|
|
227
|
+
} focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2 md:mt-0 md:ml-3 md:w-auto md:text-sm`;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
buttonStyleCssClass += ` ` + buttonSize;
|
|
@@ -32,7 +32,7 @@ const Card: FunctionComponent<ComponentProps> = (
|
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<React.Fragment>
|
|
35
|
-
<div data-testid="card" className={props.className}>
|
|
35
|
+
<div data-testid="card" className={`mb-4 ${props.className || ""}`}>
|
|
36
36
|
<div className="shadow md:rounded-md">
|
|
37
37
|
<div className="bg-white py-6 px-4 md:p-6">
|
|
38
38
|
<div className="flex flex-col md:flex-row md:justify-between">
|
|
@@ -49,7 +49,7 @@ const Card: FunctionComponent<ComponentProps> = (
|
|
|
49
49
|
{props.description && (
|
|
50
50
|
<p
|
|
51
51
|
data-testid="card-description"
|
|
52
|
-
className="mt-1 text-sm text-gray-500 w-full"
|
|
52
|
+
className="mt-1 text-sm text-gray-500 w-full hidden md:block"
|
|
53
53
|
>
|
|
54
54
|
{props.description}
|
|
55
55
|
</p>
|
|
@@ -29,7 +29,7 @@ const ChartGroup: FunctionComponent<ComponentProps> = (
|
|
|
29
29
|
const syncId: string = Text.generateRandomText(10);
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
|
-
<div className="lg:grid grid-cols-1 gap-5">
|
|
32
|
+
<div className="lg:grid grid-cols-1 gap-5 space-y-5 lg:space-y-0">
|
|
33
33
|
{props.charts.map((chart: Chart, index: number) => {
|
|
34
34
|
switch (chart.type) {
|
|
35
35
|
case ChartType.LINE:
|
|
@@ -48,7 +48,7 @@ const ChartGroup: FunctionComponent<ComponentProps> = (
|
|
|
48
48
|
{chart.description && (
|
|
49
49
|
<p
|
|
50
50
|
data-testid="card-description"
|
|
51
|
-
className="mt-1 text-sm text-gray-500 w-full"
|
|
51
|
+
className="mt-1 text-sm text-gray-500 w-full hidden md:block"
|
|
52
52
|
>
|
|
53
53
|
{chart.description}
|
|
54
54
|
</p>
|
|
@@ -126,8 +126,8 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
126
126
|
) {
|
|
127
127
|
return (
|
|
128
128
|
<div>
|
|
129
|
-
<div className="flex space-x-3 mt-1">
|
|
130
|
-
<div className="w-1/2">
|
|
129
|
+
<div className="flex flex-col md:flex-row md:space-x-3 space-y-3 md:space-y-0 mt-1">
|
|
130
|
+
<div className="w-full md:w-1/2">
|
|
131
131
|
<div className="text-xs text-gray-500">From:</div>
|
|
132
132
|
<div>
|
|
133
133
|
<Input
|
|
@@ -161,7 +161,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
161
161
|
/>
|
|
162
162
|
</div>
|
|
163
163
|
</div>
|
|
164
|
-
<div className="w-1/2">
|
|
164
|
+
<div className="w-full md:w-1/2">
|
|
165
165
|
<div className="text-xs text-gray-500">To:</div>
|
|
166
166
|
<div>
|
|
167
167
|
<Input
|
|
@@ -240,6 +240,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
240
240
|
);
|
|
241
241
|
}}
|
|
242
242
|
title="3 hours"
|
|
243
|
+
className="hidden md:block"
|
|
243
244
|
/>
|
|
244
245
|
)}
|
|
245
246
|
|
|
@@ -295,6 +296,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
295
296
|
props.onValueChanged?.(new InBetween<Date>(startDate, endDate));
|
|
296
297
|
}}
|
|
297
298
|
title="2 weeks"
|
|
299
|
+
className="hidden md:block"
|
|
298
300
|
/>
|
|
299
301
|
|
|
300
302
|
<Button
|
|
@@ -313,6 +315,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
313
315
|
props.onValueChanged?.(new InBetween<Date>(startDate, endDate));
|
|
314
316
|
}}
|
|
315
317
|
title="3 weeks"
|
|
318
|
+
className="hidden md:block"
|
|
316
319
|
/>
|
|
317
320
|
|
|
318
321
|
<Button
|
|
@@ -331,6 +334,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
331
334
|
props.onValueChanged?.(new InBetween<Date>(startDate, endDate));
|
|
332
335
|
}}
|
|
333
336
|
title="1 month"
|
|
337
|
+
className="hidden md:block"
|
|
334
338
|
/>
|
|
335
339
|
|
|
336
340
|
<Button
|
|
@@ -349,6 +353,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
349
353
|
props.onValueChanged?.(new InBetween<Date>(startDate, endDate));
|
|
350
354
|
}}
|
|
351
355
|
title="3 months"
|
|
356
|
+
className="hidden md:block"
|
|
352
357
|
/>
|
|
353
358
|
</div>
|
|
354
359
|
)}
|
|
@@ -20,6 +20,7 @@ export interface ComponentProps {
|
|
|
20
20
|
alertType: HeaderAlertType;
|
|
21
21
|
tooltip?: string | undefined;
|
|
22
22
|
colorSwatch?: ColorSwatch | undefined;
|
|
23
|
+
suffix?: string | undefined;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
const HeaderAlert: (props: ComponentProps) => ReactElement = (
|
|
@@ -82,9 +83,16 @@ const HeaderAlert: (props: ComponentProps) => ReactElement = (
|
|
|
82
83
|
/>
|
|
83
84
|
</div>
|
|
84
85
|
<div className="ml-1 flex-1 md:flex md:justify-between">
|
|
85
|
-
<p className={`text-sm font-semibold ${textColor}
|
|
86
|
+
<p className={`text-sm font-semibold ${textColor}`}>
|
|
86
87
|
{props.title}
|
|
87
88
|
</p>
|
|
89
|
+
{props.suffix && (
|
|
90
|
+
<span
|
|
91
|
+
className={`ml-1 ${textColor} text-sm font-semibold hidden md:block`}
|
|
92
|
+
>
|
|
93
|
+
{props.suffix}
|
|
94
|
+
</span>
|
|
95
|
+
)}
|
|
88
96
|
</div>
|
|
89
97
|
</div>
|
|
90
98
|
</div>
|
|
@@ -82,7 +82,8 @@ const HeaderModelAlert: <TBaseModel extends BaseModel>(
|
|
|
82
82
|
|
|
83
83
|
return (
|
|
84
84
|
<HeaderAlert
|
|
85
|
-
title={`${count}
|
|
85
|
+
title={`${count}`}
|
|
86
|
+
suffix={`${count > 1 ? props.pluralName : props.singularName}`}
|
|
86
87
|
icon={props.icon}
|
|
87
88
|
onClick={props.onClick}
|
|
88
89
|
className={props.className}
|
|
@@ -60,21 +60,21 @@ const Modal: FunctionComponent<ComponentProps> = (
|
|
|
60
60
|
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"></div>
|
|
61
61
|
|
|
62
62
|
<div className="fixed inset-0 z-20 overflow-y-auto">
|
|
63
|
-
<div className="flex min-h-screen items-end justify-center p-
|
|
63
|
+
<div className="flex min-h-screen items-end justify-center p-0 text-center md:items-center md:p-4">
|
|
64
64
|
<div
|
|
65
|
-
className={`relative transform
|
|
65
|
+
className={`relative transform bg-white text-left shadow-xl transition-all w-full h-full md:h-auto md:w-auto md:rounded-lg md:my-8 ${
|
|
66
66
|
props.modalWidth && props.modalWidth === ModalWidth.Large
|
|
67
|
-
? "
|
|
67
|
+
? "md:max-w-7xl"
|
|
68
68
|
: ""
|
|
69
69
|
} ${
|
|
70
70
|
props.modalWidth && props.modalWidth === ModalWidth.Medium
|
|
71
|
-
? "
|
|
71
|
+
? "md:max-w-3xl"
|
|
72
72
|
: ""
|
|
73
|
-
} ${!props.modalWidth ? "
|
|
73
|
+
} ${!props.modalWidth ? "md:max-w-lg" : ""} `}
|
|
74
74
|
data-testid="modal"
|
|
75
75
|
>
|
|
76
76
|
{props.onClose && (
|
|
77
|
-
<div className="absolute top-0 right-0
|
|
77
|
+
<div className="absolute top-0 right-0 z-10 pt-4 pr-4 md:hidden lg:block">
|
|
78
78
|
<Button
|
|
79
79
|
buttonStyle={ButtonStyleType.ICON}
|
|
80
80
|
icon={IconProp.Close}
|
|
@@ -85,10 +85,10 @@ const Modal: FunctionComponent<ComponentProps> = (
|
|
|
85
85
|
/>
|
|
86
86
|
</div>
|
|
87
87
|
)}
|
|
88
|
-
<div className="
|
|
88
|
+
<div className="p-4 md:p-6">
|
|
89
89
|
{props.icon && (
|
|
90
90
|
<div
|
|
91
|
-
className={`mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full ${iconBgColor}
|
|
91
|
+
className={`mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full ${iconBgColor} md:mx-0 md:h-10 md:w-10`}
|
|
92
92
|
data-testid="icon"
|
|
93
93
|
>
|
|
94
94
|
<Icon
|
|
@@ -104,13 +104,13 @@ const Modal: FunctionComponent<ComponentProps> = (
|
|
|
104
104
|
/>
|
|
105
105
|
</div>
|
|
106
106
|
)}
|
|
107
|
-
<div className="
|
|
108
|
-
<div className="flex justify-between">
|
|
109
|
-
<div>
|
|
107
|
+
<div className="text-left md:mt-0 md:ml-4 md:mr-4">
|
|
108
|
+
<div className="flex flex-col md:flex-row md:justify-between">
|
|
109
|
+
<div className="flex-1">
|
|
110
110
|
<h3
|
|
111
111
|
data-testid="modal-title"
|
|
112
112
|
className={`text-lg font-medium leading-6 text-gray-900 ${
|
|
113
|
-
props.icon ? "ml-10
|
|
113
|
+
props.icon ? "mt-4 md:ml-10 md:-mt-8 md:mb-5" : ""
|
|
114
114
|
}`}
|
|
115
115
|
id="modal-title"
|
|
116
116
|
>
|
|
@@ -119,14 +119,16 @@ const Modal: FunctionComponent<ComponentProps> = (
|
|
|
119
119
|
{props.description && (
|
|
120
120
|
<h3
|
|
121
121
|
data-testid="modal-description"
|
|
122
|
-
className="text-sm leading-6 text-gray-500"
|
|
122
|
+
className="text-sm leading-6 text-gray-500 mt-2"
|
|
123
123
|
>
|
|
124
124
|
{props.description}
|
|
125
125
|
</h3>
|
|
126
126
|
)}
|
|
127
127
|
</div>
|
|
128
128
|
{props.rightElement && (
|
|
129
|
-
<div data-testid="right-element">
|
|
129
|
+
<div data-testid="right-element" className="mt-4 md:mt-0">
|
|
130
|
+
{props.rightElement}
|
|
131
|
+
</div>
|
|
130
132
|
)}
|
|
131
133
|
</div>
|
|
132
134
|
<div className="mt-2">
|
|
@@ -18,7 +18,7 @@ const ModalFooter: FunctionComponent<ComponentProps> = (
|
|
|
18
18
|
props: ComponentProps,
|
|
19
19
|
): ReactElement => {
|
|
20
20
|
return (
|
|
21
|
-
<div className="bg-gray-50 px-4 py-3
|
|
21
|
+
<div className="bg-gray-50 px-4 py-3 flex flex-row gap-3 md:flex-row-reverse md:px-6">
|
|
22
22
|
{props.onSubmit ? (
|
|
23
23
|
<Button
|
|
24
24
|
buttonStyle={
|
|
@@ -52,7 +52,7 @@ const Page: FunctionComponent<ComponentProps> = (
|
|
|
52
52
|
</div>
|
|
53
53
|
)}
|
|
54
54
|
{props.title && (
|
|
55
|
-
<div className="mt-2 md:flex md:items-center md:justify-between">
|
|
55
|
+
<div className="mt-2 md:flex md:items-center md:justify-between hidden md:block">
|
|
56
56
|
<div className="min-w-0">
|
|
57
57
|
<h2 className="text-xl leading-7 text-gray-900 sm:truncate sm:text-2xl sm:tracking-tight">
|
|
58
58
|
{props.title}
|
|
@@ -69,12 +69,12 @@ const Page: FunctionComponent<ComponentProps> = (
|
|
|
69
69
|
{props.sideMenu}
|
|
70
70
|
|
|
71
71
|
{!props.isLoading && (
|
|
72
|
-
<div className="space-y-6
|
|
72
|
+
<div className="space-y-6 md:px-6 lg:col-span-10 md:col-span-9 lg:px-0">
|
|
73
73
|
{props.children}
|
|
74
74
|
</div>
|
|
75
75
|
)}
|
|
76
76
|
{props.isLoading && (
|
|
77
|
-
<div className="col-span-10">
|
|
77
|
+
<div className="lg:col-span-10 md:col-span-9">
|
|
78
78
|
<PageLoader isVisible={true} />
|
|
79
79
|
</div>
|
|
80
80
|
)}
|
|
@@ -1,24 +1,300 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
FunctionComponent,
|
|
3
|
+
ReactElement,
|
|
4
|
+
useState,
|
|
5
|
+
useEffect,
|
|
6
|
+
} from "react";
|
|
7
|
+
import Button, { ButtonStyleType } from "../Button/Button";
|
|
8
|
+
import IconProp from "../../../Types/Icon/IconProp";
|
|
9
|
+
import useComponentOutsideClick from "../../Types/UseComponentOutsideClick";
|
|
10
|
+
import Navigation from "../../Utils/Navigation";
|
|
11
|
+
import SideMenuItem from "./SideMenuItem";
|
|
12
|
+
import SideMenuSection from "./SideMenuSection";
|
|
13
|
+
import CountModelSideMenuItem from "./CountModelSideMenuItem";
|
|
14
|
+
import Link from "../../../Types/Link";
|
|
15
|
+
import { BadgeType } from "../Badge/Badge";
|
|
16
|
+
import BaseModel from "../../../Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
|
|
17
|
+
import Query from "../../../Types/BaseDatabase/Query";
|
|
18
|
+
import { RequestOptions } from "../../Utils/ModelAPI/ModelAPI";
|
|
19
|
+
|
|
20
|
+
export interface SideMenuItemProps {
|
|
21
|
+
link: Link;
|
|
22
|
+
showAlert?: boolean;
|
|
23
|
+
showWarning?: boolean;
|
|
24
|
+
badge?: number;
|
|
25
|
+
badgeType?: BadgeType;
|
|
26
|
+
icon?: IconProp;
|
|
27
|
+
className?: string;
|
|
28
|
+
subItemLink?: Link | undefined;
|
|
29
|
+
subItemIcon?: IconProp;
|
|
30
|
+
// For CountModelSideMenuItem support
|
|
31
|
+
modelType?: { new (): BaseModel };
|
|
32
|
+
countQuery?: Query<any>;
|
|
33
|
+
requestOptions?: RequestOptions;
|
|
34
|
+
onCountFetchInit?: () => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface SideMenuSectionProps {
|
|
38
|
+
title: string;
|
|
39
|
+
items: SideMenuItemProps[];
|
|
40
|
+
}
|
|
2
41
|
|
|
3
42
|
export interface ComponentProps {
|
|
4
|
-
|
|
43
|
+
sections?: SideMenuSectionProps[];
|
|
44
|
+
items?: SideMenuItemProps[];
|
|
45
|
+
className?: string;
|
|
46
|
+
// Keep children support for backward compatibility
|
|
47
|
+
children?: ReactElement | Array<ReactElement>;
|
|
5
48
|
}
|
|
6
49
|
|
|
7
50
|
const SideMenu: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
51
|
+
const [isMobile, setIsMobile] = useState<boolean>(false);
|
|
52
|
+
const [isMobileMenuVisible, setIsMobileMenuVisible] =
|
|
53
|
+
useState<boolean>(false);
|
|
54
|
+
|
|
55
|
+
// Use the existing outside click hook for mobile menu
|
|
56
|
+
const {
|
|
57
|
+
ref: mobileMenuRef,
|
|
58
|
+
isComponentVisible: isMobileMenuOpen,
|
|
59
|
+
setIsComponentVisible: setIsMobileMenuOpen,
|
|
60
|
+
} = useComponentOutsideClick(false);
|
|
61
|
+
|
|
62
|
+
// Sync local state with hook state
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
setIsMobileMenuVisible(isMobileMenuOpen);
|
|
65
|
+
}, [isMobileMenuOpen]);
|
|
66
|
+
|
|
67
|
+
// Check if we're on mobile
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const checkMobile: () => void = (): void => {
|
|
70
|
+
setIsMobile(window.innerWidth < 768); // md breakpoint
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
checkMobile();
|
|
74
|
+
window.addEventListener("resize", checkMobile);
|
|
75
|
+
|
|
76
|
+
return () => {
|
|
77
|
+
window.removeEventListener("resize", checkMobile);
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
// Close mobile menu when clicking on a menu item
|
|
82
|
+
const handleMenuItemClick: () => void = (): void => {
|
|
83
|
+
if (isMobile && isMobileMenuVisible) {
|
|
84
|
+
setIsMobileMenuOpen(false);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Function to find the active menu item and section - much simpler now!
|
|
89
|
+
const findActiveMenuItem: () => {
|
|
90
|
+
sectionTitle?: string;
|
|
91
|
+
itemTitle?: string;
|
|
92
|
+
} = (): {
|
|
93
|
+
sectionTitle?: string;
|
|
94
|
+
itemTitle?: string;
|
|
95
|
+
} => {
|
|
96
|
+
// Check sections first
|
|
97
|
+
if (props.sections) {
|
|
98
|
+
for (const section of props.sections) {
|
|
99
|
+
for (const item of section.items) {
|
|
100
|
+
if (Navigation.isOnThisPage(item.link.to)) {
|
|
101
|
+
return {
|
|
102
|
+
sectionTitle: section.title,
|
|
103
|
+
itemTitle: item.link.title,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Check direct items
|
|
111
|
+
if (props.items) {
|
|
112
|
+
for (const item of props.items) {
|
|
113
|
+
if (Navigation.isOnThisPage(item.link.to)) {
|
|
114
|
+
return {
|
|
115
|
+
itemTitle: item.link.title,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return {};
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const activeItem: {
|
|
125
|
+
sectionTitle?: string;
|
|
126
|
+
itemTitle?: string;
|
|
127
|
+
} = findActiveMenuItem();
|
|
128
|
+
const displayText: string =
|
|
129
|
+
activeItem.sectionTitle && activeItem.itemTitle
|
|
130
|
+
? `${activeItem.sectionTitle} - ${activeItem.itemTitle}`
|
|
131
|
+
: activeItem.itemTitle || "Navigation";
|
|
132
|
+
|
|
133
|
+
// Re-run active item detection when location changes
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
// This will trigger a re-render when navigation changes
|
|
136
|
+
// The activeItem will be recalculated
|
|
137
|
+
}, [Navigation.getCurrentPath().toString()]);
|
|
138
|
+
|
|
139
|
+
// Render function for the menu content
|
|
140
|
+
const renderMenuContent: () => ReactElement[] = (): ReactElement[] => {
|
|
141
|
+
const content: ReactElement[] = [];
|
|
142
|
+
|
|
143
|
+
// Render sections
|
|
144
|
+
if (props.sections) {
|
|
145
|
+
props.sections.forEach(
|
|
146
|
+
(section: SideMenuSectionProps, sectionIndex: number) => {
|
|
147
|
+
content.push(
|
|
148
|
+
<SideMenuSection
|
|
149
|
+
key={`section-${sectionIndex}`}
|
|
150
|
+
title={section.title}
|
|
151
|
+
>
|
|
152
|
+
{section.items.map(
|
|
153
|
+
(item: SideMenuItemProps, itemIndex: number) => {
|
|
154
|
+
// If item has modelType, render CountModelSideMenuItem
|
|
155
|
+
if (item.modelType && item.countQuery) {
|
|
156
|
+
return (
|
|
157
|
+
<CountModelSideMenuItem
|
|
158
|
+
key={`section-${sectionIndex}-count-item-${itemIndex}`}
|
|
159
|
+
link={item.link}
|
|
160
|
+
badgeType={item.badgeType}
|
|
161
|
+
modelType={item.modelType as any}
|
|
162
|
+
countQuery={item.countQuery as any}
|
|
163
|
+
requestOptions={item.requestOptions}
|
|
164
|
+
icon={item.icon}
|
|
165
|
+
className={item.className}
|
|
166
|
+
onCountFetchInit={item.onCountFetchInit}
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Otherwise render regular SideMenuItem
|
|
172
|
+
return (
|
|
173
|
+
<SideMenuItem
|
|
174
|
+
key={`section-${sectionIndex}-item-${itemIndex}`}
|
|
175
|
+
link={item.link}
|
|
176
|
+
showAlert={item.showAlert}
|
|
177
|
+
showWarning={item.showWarning}
|
|
178
|
+
badge={item.badge}
|
|
179
|
+
badgeType={item.badgeType}
|
|
180
|
+
icon={item.icon}
|
|
181
|
+
className={item.className}
|
|
182
|
+
subItemLink={item.subItemLink}
|
|
183
|
+
subItemIcon={item.subItemIcon}
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
186
|
+
},
|
|
187
|
+
)}
|
|
188
|
+
</SideMenuSection>,
|
|
189
|
+
);
|
|
190
|
+
},
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Render direct items
|
|
195
|
+
if (props.items) {
|
|
196
|
+
props.items.forEach((item: SideMenuItemProps, itemIndex: number) => {
|
|
197
|
+
// If item has modelType, render CountModelSideMenuItem
|
|
198
|
+
if (item.modelType && item.countQuery) {
|
|
199
|
+
content.push(
|
|
200
|
+
<CountModelSideMenuItem
|
|
201
|
+
key={`count-item-${itemIndex}`}
|
|
202
|
+
link={item.link}
|
|
203
|
+
badgeType={item.badgeType}
|
|
204
|
+
modelType={item.modelType as any}
|
|
205
|
+
countQuery={item.countQuery as any}
|
|
206
|
+
requestOptions={item.requestOptions}
|
|
207
|
+
icon={item.icon}
|
|
208
|
+
className={item.className}
|
|
209
|
+
onCountFetchInit={item.onCountFetchInit}
|
|
210
|
+
/>,
|
|
211
|
+
);
|
|
212
|
+
} else {
|
|
213
|
+
// Otherwise render regular SideMenuItem
|
|
214
|
+
content.push(
|
|
215
|
+
<SideMenuItem
|
|
216
|
+
key={`item-${itemIndex}`}
|
|
217
|
+
link={item.link}
|
|
218
|
+
showAlert={item.showAlert}
|
|
219
|
+
showWarning={item.showWarning}
|
|
220
|
+
badge={item.badge}
|
|
221
|
+
badgeType={item.badgeType}
|
|
222
|
+
icon={item.icon}
|
|
223
|
+
className={item.className}
|
|
224
|
+
subItemLink={item.subItemLink}
|
|
225
|
+
subItemIcon={item.subItemIcon}
|
|
226
|
+
/>,
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Support legacy children prop for backward compatibility
|
|
233
|
+
if (props.children) {
|
|
234
|
+
const children: Array<ReactElement> = Array.isArray(props.children)
|
|
235
|
+
? props.children
|
|
236
|
+
: [props.children];
|
|
237
|
+
|
|
238
|
+
children.forEach((child: ReactElement, index: number) => {
|
|
239
|
+
content.push(React.cloneElement(child, { key: `child-${index}` }));
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return content;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// Mobile view
|
|
247
|
+
if (isMobile) {
|
|
248
|
+
return (
|
|
249
|
+
<div className="md:hidden mb-6">
|
|
250
|
+
{/* Mobile toggle button */}
|
|
251
|
+
<div className="flex items-center justify-between w-full mb-4 px-4 py-3 bg-white rounded-lg border border-gray-200">
|
|
252
|
+
<div className="flex-1 mr-3">
|
|
253
|
+
<h3 className="text-base font-medium text-gray-900 truncate">
|
|
254
|
+
{displayText}
|
|
255
|
+
</h3>
|
|
256
|
+
</div>
|
|
257
|
+
<Button
|
|
258
|
+
buttonStyle={ButtonStyleType.OUTLINE}
|
|
259
|
+
onClick={() => {
|
|
260
|
+
setIsMobileMenuOpen(!isMobileMenuVisible);
|
|
261
|
+
}}
|
|
262
|
+
className="p-2 flex-shrink-0"
|
|
263
|
+
icon={isMobileMenuVisible ? IconProp.Close : IconProp.Bars3}
|
|
264
|
+
dataTestId="mobile-sidemenu-toggle"
|
|
265
|
+
tooltip={
|
|
266
|
+
isMobileMenuVisible
|
|
267
|
+
? "Close navigation menu"
|
|
268
|
+
: "Open navigation menu"
|
|
269
|
+
}
|
|
270
|
+
/>
|
|
271
|
+
</div>
|
|
272
|
+
|
|
273
|
+
{/* Mobile collapsible menu */}
|
|
274
|
+
{isMobileMenuVisible && (
|
|
275
|
+
<div
|
|
276
|
+
ref={mobileMenuRef}
|
|
277
|
+
className="bg-white rounded-lg border border-gray-200 py-4 px-4 mb-6 transition-all duration-200 ease-in-out"
|
|
278
|
+
role="navigation"
|
|
279
|
+
aria-label="Main navigation"
|
|
280
|
+
>
|
|
281
|
+
<nav className="space-y-3" onClick={handleMenuItemClick}>
|
|
282
|
+
{renderMenuContent()}
|
|
283
|
+
</nav>
|
|
284
|
+
</div>
|
|
285
|
+
)}
|
|
286
|
+
</div>
|
|
287
|
+
);
|
|
13
288
|
}
|
|
14
289
|
|
|
290
|
+
// Desktop view
|
|
15
291
|
return (
|
|
16
|
-
<aside
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</nav>
|
|
292
|
+
<aside
|
|
293
|
+
className={`hidden md:block py-6 px-2 sm:px-6 lg:col-span-2 md:col-span-3 lg:py-0 lg:px-0 mb-10 ${props.className || ""}`}
|
|
294
|
+
role="navigation"
|
|
295
|
+
aria-label="Main navigation"
|
|
296
|
+
>
|
|
297
|
+
<nav className="space-y-3">{renderMenuContent()}</nav>
|
|
22
298
|
</aside>
|
|
23
299
|
);
|
|
24
300
|
};
|