@jsb188/mday-web 1.1.11 → 1.1.12
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 +15 -13
- package/src/modules/Grids.filters.ts +36 -0
- package/src/modules/Grids.tsx +115 -347
- package/src/schemas/organization.ts +128 -0
- package/src/utils/email.ts +117 -0
- package/src/utils/log-web.helpers.ts +99 -0
- package/src/utils/log-web.icons.ts +184 -0
- package/src/utils/log-web.ts +58 -458
- package/src/utils/operation-pages.ts +154 -0
- package/src/utils/route-helpers.ts +193 -258
- package/src/utils/workflow-web.ts +16 -40
- package/tests/log-web.test.ts +134 -0
- package/tests/route-helpers.test.ts +17 -0
- package/src/modules/AgentDocs.tsx +0 -800
- package/src/modules/DocAccessSettings.tsx +0 -963
- package/src/utils/account-web.ts +0 -64
package/src/modules/Grids.tsx
CHANGED
|
@@ -5,23 +5,14 @@ import { useDataTables } from '@jsb188/graphql/hooks/use-dataTable-qry';
|
|
|
5
5
|
import { useSheets } from '@jsb188/graphql/hooks/use-sheet-qry';
|
|
6
6
|
import type { DataTableGQL } from '@jsb188/mday/types/dataTable.d.ts';
|
|
7
7
|
import type { GridItemSortEnum, SheetGQL } from '@jsb188/mday/types/sheet.d.ts';
|
|
8
|
-
import {
|
|
9
|
-
ContentGate,
|
|
10
|
-
type SetFloatingMessage,
|
|
11
|
-
} from '@jsb188/react-web/modules/layout/MainLayout';
|
|
12
|
-
import type { ToolbarItemObj } from '@jsb188/react-web/modules/Toolbar';
|
|
13
|
-
import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
|
|
14
|
-
import { TileItem, TileSection } from '@jsb188/react-web/ui/TileUI';
|
|
15
|
-
import { useOpenModalPopUp, usePopOver } from '@jsb188/react/states';
|
|
8
|
+
import { useOpenModalPopUp, usePopOverActions, usePopOverDefinition, usePopOverEvent } from '@jsb188/react/states';
|
|
16
9
|
import type { POListIfaceItem } from '@jsb188/react/types/PopOver.d';
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
type MouseEvent,
|
|
24
|
-
} from 'react';
|
|
10
|
+
import { ContentGate } from '@jsb188/react-web/modules/layout/MainLayout';
|
|
11
|
+
import { ModalTileGrid } from '@jsb188/react-web/modules/layout/TabbedModalLayout';
|
|
12
|
+
import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
|
|
13
|
+
import { SimpleLabel } from '@jsb188/react-web/ui/Button';
|
|
14
|
+
import { TileItem } from '@jsb188/react-web/ui/TileUI';
|
|
15
|
+
import { type MouseEvent, memo, useCallback, useEffect, useId, useMemo, useRef } from 'react';
|
|
25
16
|
import { mapRenderableItems } from '../utils/list-web.ts';
|
|
26
17
|
|
|
27
18
|
const FILE_CONSTANTS = {
|
|
@@ -31,19 +22,11 @@ const FILE_CONSTANTS = {
|
|
|
31
22
|
sectionDataTables: 'dataTables',
|
|
32
23
|
sectionSheets: 'sheets',
|
|
33
24
|
sheetIconName: COMMON_ICON_NAMES.sheet,
|
|
34
|
-
sortParamName: 's',
|
|
35
|
-
sortTitle: '2',
|
|
36
|
-
sortUpdatedDate: '1',
|
|
37
25
|
tileContextMenuIdPrefix: 'grids_tile_context_menu:',
|
|
38
26
|
} as const;
|
|
39
27
|
|
|
40
|
-
const GRIDS_SORT_OPTIONS = [
|
|
41
|
-
FILE_CONSTANTS.sortUpdatedDate,
|
|
42
|
-
FILE_CONSTANTS.sortTitle,
|
|
43
|
-
] as const;
|
|
44
|
-
|
|
45
28
|
export type GridsSectionMode = 'all' | 'sheets' | 'dataTables';
|
|
46
|
-
export
|
|
29
|
+
export { GRIDS_FILTER_SCHEMA, useGridsToolbarState } from './Grids.filters.ts';
|
|
47
30
|
|
|
48
31
|
type GridItem = {
|
|
49
32
|
id: string;
|
|
@@ -52,6 +35,9 @@ type GridItem = {
|
|
|
52
35
|
title: string;
|
|
53
36
|
description: string;
|
|
54
37
|
iconName: string;
|
|
38
|
+
// Ownership is independent of the nullable headline; owned tables have no delete action of their own
|
|
39
|
+
ownerNoteId?: string | null;
|
|
40
|
+
ownerNoteHeadline?: string | null;
|
|
55
41
|
to: string;
|
|
56
42
|
};
|
|
57
43
|
|
|
@@ -71,14 +57,15 @@ type GridsSectionVisibility = {
|
|
|
71
57
|
};
|
|
72
58
|
|
|
73
59
|
type GridsTileSectionProps = {
|
|
74
|
-
|
|
75
|
-
|
|
60
|
+
contextMenuOwnerId: string;
|
|
61
|
+
createDescription?: string;
|
|
62
|
+
createTitle?: string;
|
|
76
63
|
items: GridItem[];
|
|
77
64
|
mocked: boolean;
|
|
78
65
|
sectionId: string;
|
|
79
66
|
showCreateTile: boolean;
|
|
80
67
|
title: string;
|
|
81
|
-
onCreate
|
|
68
|
+
onCreate?: () => void;
|
|
82
69
|
};
|
|
83
70
|
|
|
84
71
|
interface GridsModuleProps {
|
|
@@ -86,7 +73,6 @@ interface GridsModuleProps {
|
|
|
86
73
|
notReadyClassName?: string;
|
|
87
74
|
organizationId: string;
|
|
88
75
|
sections?: GridsSectionMode;
|
|
89
|
-
setFloatingMessage?: SetFloatingMessage;
|
|
90
76
|
showCreateTiles?: boolean;
|
|
91
77
|
sort: GridItemSortEnum;
|
|
92
78
|
}
|
|
@@ -94,51 +80,13 @@ interface GridsModuleProps {
|
|
|
94
80
|
/*
|
|
95
81
|
* Return which grids sections should be visible for one module mode.
|
|
96
82
|
*/
|
|
97
|
-
function getGridsSectionVisibility(
|
|
98
|
-
sections: GridsSectionMode,
|
|
99
|
-
): GridsSectionVisibility {
|
|
83
|
+
function getGridsSectionVisibility(sections: GridsSectionMode): GridsSectionVisibility {
|
|
100
84
|
return {
|
|
101
85
|
showDataTables: sections !== FILE_CONSTANTS.sectionSheets,
|
|
102
86
|
showSheets: sections !== FILE_CONSTANTS.sectionDataTables,
|
|
103
87
|
};
|
|
104
88
|
}
|
|
105
89
|
|
|
106
|
-
/*
|
|
107
|
-
* Return one stable reset-only signal value for all visible grids list queries.
|
|
108
|
-
*/
|
|
109
|
-
function getGridsResetOnlyTime(
|
|
110
|
-
sheetsResetOnlyTime: string,
|
|
111
|
-
dataTablesResetOnlyTime: string,
|
|
112
|
-
) {
|
|
113
|
-
return [sheetsResetOnlyTime, dataTablesResetOnlyTime]
|
|
114
|
-
.filter(Boolean)
|
|
115
|
-
.join('|');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/*
|
|
119
|
-
* Show the app refresh prompt when grids queries receive a RESET_ONLY emit.
|
|
120
|
-
*/
|
|
121
|
-
function useGridsResetOnlyFloatingMessage(
|
|
122
|
-
resetOnlyTime: string,
|
|
123
|
-
setFloatingMessage?: SetFloatingMessage,
|
|
124
|
-
) {
|
|
125
|
-
const lastUpdateTime = useRef(resetOnlyTime);
|
|
126
|
-
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
if (!resetOnlyTime || !setFloatingMessage) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (resetOnlyTime !== lastUpdateTime.current) {
|
|
133
|
-
setFloatingMessage({
|
|
134
|
-
type: 'REFRESH',
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
lastUpdateTime.current = resetOnlyTime;
|
|
139
|
-
}, [resetOnlyTime, setFloatingMessage]);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
90
|
/*
|
|
143
91
|
* Keep the last fully loaded grids data available during replacement fetches.
|
|
144
92
|
*/
|
|
@@ -168,11 +116,7 @@ function useLastGridsReadyData(p: {
|
|
|
168
116
|
/*
|
|
169
117
|
* Return query variables for one grids data source when its section is visible.
|
|
170
118
|
*/
|
|
171
|
-
function getGridsQueryVariables(
|
|
172
|
-
visible: boolean,
|
|
173
|
-
organizationId: string,
|
|
174
|
-
sort: GridItemSortEnum,
|
|
175
|
-
) {
|
|
119
|
+
function getGridsQueryVariables(visible: boolean, organizationId: string, sort: GridItemSortEnum) {
|
|
176
120
|
return visible
|
|
177
121
|
? {
|
|
178
122
|
organizationId,
|
|
@@ -181,20 +125,6 @@ function getGridsQueryVariables(
|
|
|
181
125
|
: null;
|
|
182
126
|
}
|
|
183
127
|
|
|
184
|
-
/*
|
|
185
|
-
* Return the best display title for one sheet.
|
|
186
|
-
*/
|
|
187
|
-
function getSheetTitle(sheet: SheetGQL) {
|
|
188
|
-
return sheet.title || i18n.t('app.untitled_sheet');
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/*
|
|
192
|
-
* Return the best display title for one dataTable.
|
|
193
|
-
*/
|
|
194
|
-
function getDataTableTitle(dataTable: DataTableGQL) {
|
|
195
|
-
return dataTable.title || i18n.t('sheet.untitled_data_table');
|
|
196
|
-
}
|
|
197
|
-
|
|
198
128
|
/*
|
|
199
129
|
* Convert one sheet record into a grids tile item.
|
|
200
130
|
*/
|
|
@@ -206,7 +136,7 @@ function mapSheetToGridItem(sheet: SheetGQL): GridItem | null {
|
|
|
206
136
|
return {
|
|
207
137
|
id: sheet.id,
|
|
208
138
|
__typename: 'Sheet',
|
|
209
|
-
title:
|
|
139
|
+
title: sheet.title || i18n.t('app.untitled_sheet'),
|
|
210
140
|
description: sheet.description || sheet.name || '',
|
|
211
141
|
iconName: FILE_CONSTANTS.sheetIconName,
|
|
212
142
|
to: `/app/s/${sheet.id}`,
|
|
@@ -225,132 +155,13 @@ function mapDataTableToGridItem(dataTable: DataTableGQL): GridItem | null {
|
|
|
225
155
|
return {
|
|
226
156
|
id: dataTable.id,
|
|
227
157
|
__typename: 'DataTable',
|
|
228
|
-
title:
|
|
229
|
-
description: dataTable.description ||
|
|
158
|
+
title: dataTable.title || i18n.t('sheet.untitled_data_table'),
|
|
159
|
+
description: dataTable.description || '',
|
|
230
160
|
iconName: FILE_CONSTANTS.dataTableIconName,
|
|
161
|
+
ownerNoteId: dataTable.ownerNote?.id,
|
|
162
|
+
ownerNoteHeadline: dataTable.ownerNote?.headline,
|
|
231
163
|
to: `/app/d/${dataTable.id}`,
|
|
232
|
-
__deleted: Boolean(dataTable.__deleted || dataTable.
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/*
|
|
237
|
-
* Return the current grids sort value from search params.
|
|
238
|
-
*/
|
|
239
|
-
export function getGridsSortValue(
|
|
240
|
-
searchParams: URLSearchParams,
|
|
241
|
-
sortParamName: string = FILE_CONSTANTS.sortParamName,
|
|
242
|
-
): GridsSortValue {
|
|
243
|
-
const sortValue = searchParams.get(sortParamName);
|
|
244
|
-
|
|
245
|
-
return GRIDS_SORT_OPTIONS.includes(sortValue as GridsSortValue)
|
|
246
|
-
? (sortValue as GridsSortValue)
|
|
247
|
-
: FILE_CONSTANTS.sortUpdatedDate;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/*
|
|
251
|
-
* Return the toolbar label for the selected grids sort option.
|
|
252
|
-
*/
|
|
253
|
-
function getGridsSortText(sortValue: GridsSortValue) {
|
|
254
|
-
return i18n.t(
|
|
255
|
-
sortValue === FILE_CONSTANTS.sortTitle
|
|
256
|
-
? 'app.grids_sort_title'
|
|
257
|
-
: 'app.grids_sort_updated_date',
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/*
|
|
262
|
-
* Return the GraphQL sort value for the current grids URL sort value.
|
|
263
|
-
*/
|
|
264
|
-
export function getGridsSortQueryValue(
|
|
265
|
-
sortValue: GridsSortValue,
|
|
266
|
-
): GridItemSortEnum {
|
|
267
|
-
return sortValue === FILE_CONSTANTS.sortTitle
|
|
268
|
-
? 'TITLE_ASC'
|
|
269
|
-
: 'UPDATED_AT_DESC';
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/*
|
|
273
|
-
* Build a grids path with the selected sort search param.
|
|
274
|
-
*/
|
|
275
|
-
function createGridsSortPath(
|
|
276
|
-
pathname: string,
|
|
277
|
-
searchParams: URLSearchParams,
|
|
278
|
-
sortValue: GridsSortValue,
|
|
279
|
-
sortParamName: string,
|
|
280
|
-
) {
|
|
281
|
-
const nextSearchParams = new URLSearchParams(searchParams);
|
|
282
|
-
nextSearchParams.set(sortParamName, sortValue);
|
|
283
|
-
|
|
284
|
-
return `${pathname}?${nextSearchParams.toString()}`;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/*
|
|
288
|
-
* Return the app toolbar options for a grids surface.
|
|
289
|
-
*/
|
|
290
|
-
export function getGridsToolbarOptions(
|
|
291
|
-
pathname: string,
|
|
292
|
-
searchParams: URLSearchParams,
|
|
293
|
-
sortValue: GridsSortValue,
|
|
294
|
-
sortParamName: string = FILE_CONSTANTS.sortParamName,
|
|
295
|
-
): ToolbarItemObj[] {
|
|
296
|
-
return [
|
|
297
|
-
{
|
|
298
|
-
id: 'grids_sort',
|
|
299
|
-
text: getGridsSortText(sortValue),
|
|
300
|
-
hasValue: true,
|
|
301
|
-
hideClearIcon: true,
|
|
302
|
-
popOverClassName: 'min_w_200',
|
|
303
|
-
initialState: sortValue,
|
|
304
|
-
disablePopOverButton: true,
|
|
305
|
-
options: [
|
|
306
|
-
{
|
|
307
|
-
__type: 'LIST_SUBTITLE',
|
|
308
|
-
text: i18n.t('form.sort_by'),
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
__type: 'SINGLE_OPTION_LIST_ITEM',
|
|
312
|
-
value: FILE_CONSTANTS.sortUpdatedDate,
|
|
313
|
-
text: i18n.t('app.grids_sort_updated_date'),
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
__type: 'SINGLE_OPTION_LIST_ITEM',
|
|
317
|
-
value: FILE_CONSTANTS.sortTitle,
|
|
318
|
-
text: i18n.t('app.grids_sort_title'),
|
|
319
|
-
},
|
|
320
|
-
],
|
|
321
|
-
getItemTo: (nextSortValue) =>
|
|
322
|
-
createGridsSortPath(
|
|
323
|
-
pathname,
|
|
324
|
-
searchParams,
|
|
325
|
-
nextSortValue === FILE_CONSTANTS.sortTitle
|
|
326
|
-
? FILE_CONSTANTS.sortTitle
|
|
327
|
-
: FILE_CONSTANTS.sortUpdatedDate,
|
|
328
|
-
sortParamName,
|
|
329
|
-
),
|
|
330
|
-
},
|
|
331
|
-
];
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/*
|
|
335
|
-
* Return sort state and toolbar items for a grids surface.
|
|
336
|
-
*/
|
|
337
|
-
export function getGridsToolbarState(p: {
|
|
338
|
-
pathname: string;
|
|
339
|
-
searchParams: URLSearchParams;
|
|
340
|
-
sortParamName?: string;
|
|
341
|
-
}) {
|
|
342
|
-
const { pathname, searchParams, sortParamName } = p;
|
|
343
|
-
const sortValue = getGridsSortValue(searchParams, sortParamName);
|
|
344
|
-
|
|
345
|
-
return {
|
|
346
|
-
sortQueryValue: getGridsSortQueryValue(sortValue),
|
|
347
|
-
sortValue,
|
|
348
|
-
toolbarOptions: getGridsToolbarOptions(
|
|
349
|
-
pathname,
|
|
350
|
-
searchParams,
|
|
351
|
-
sortValue,
|
|
352
|
-
sortParamName,
|
|
353
|
-
),
|
|
164
|
+
__deleted: Boolean(dataTable.__deleted || dataTable.archivedAt),
|
|
354
165
|
};
|
|
355
166
|
}
|
|
356
167
|
|
|
@@ -376,10 +187,7 @@ function getGridsTileContextMenuRect(e: MouseEvent<Element>) {
|
|
|
376
187
|
* Build an absolute URL for a grids tile route action.
|
|
377
188
|
*/
|
|
378
189
|
function getGridsTileRouteUrl(to: string) {
|
|
379
|
-
return new URL(
|
|
380
|
-
to,
|
|
381
|
-
globalThis.location?.origin || 'http://localhost',
|
|
382
|
-
).toString();
|
|
190
|
+
return new URL(to, globalThis.location?.origin || 'http://localhost').toString();
|
|
383
191
|
}
|
|
384
192
|
|
|
385
193
|
/*
|
|
@@ -396,17 +204,16 @@ function getGridsTileDeleteModalProps(item: GridItem, organizationId: string) {
|
|
|
396
204
|
return {
|
|
397
205
|
itemTitle: item.title,
|
|
398
206
|
organizationId,
|
|
399
|
-
...(item.__typename === 'Sheet'
|
|
400
|
-
? { sheetId: item.id }
|
|
401
|
-
: { dataTableId: item.id }),
|
|
207
|
+
...(item.__typename === 'Sheet' ? { sheetId: item.id } : { dataTableId: item.id }),
|
|
402
208
|
};
|
|
403
209
|
}
|
|
404
210
|
|
|
405
211
|
/*
|
|
406
|
-
* Return the popover menu options for one grids tile.
|
|
212
|
+
* Return the popover menu options for one grids tile. A data table an AI note owns has no
|
|
213
|
+
* delete option: the server refuses it (20243) while the note owns it.
|
|
407
214
|
*/
|
|
408
215
|
function getGridsTileContextOptions(item: GridItem): POListIfaceItem[] {
|
|
409
|
-
|
|
216
|
+
const options: POListIfaceItem[] = [
|
|
410
217
|
{
|
|
411
218
|
__type: 'LIST_ITEM',
|
|
412
219
|
iconName: COMMON_ICON_NAMES.open_external_link,
|
|
@@ -416,38 +223,62 @@ function getGridsTileContextOptions(item: GridItem): POListIfaceItem[] {
|
|
|
416
223
|
item,
|
|
417
224
|
} satisfies GridsTileContextMenuValue,
|
|
418
225
|
},
|
|
419
|
-
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
if (!item.ownerNoteId) {
|
|
229
|
+
options.push({
|
|
420
230
|
__type: 'LIST_ITEM',
|
|
421
231
|
iconName: COMMON_ICON_NAMES.delete,
|
|
422
|
-
text: i18n.t(
|
|
423
|
-
item.__typename === 'Sheet'
|
|
424
|
-
? 'sheet.delete_sheet'
|
|
425
|
-
: 'sheet.delete_data_table',
|
|
426
|
-
),
|
|
232
|
+
text: i18n.t(item.__typename === 'Sheet' ? 'sheet.delete_sheet' : 'sheet.delete_data_table'),
|
|
427
233
|
className: 'cl_err_hv',
|
|
428
234
|
value: {
|
|
429
235
|
action: 'DELETE_GRID_ITEM',
|
|
430
236
|
item,
|
|
431
237
|
} satisfies GridsTileContextMenuValue,
|
|
432
|
-
}
|
|
433
|
-
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return options;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/*
|
|
245
|
+
* Return a tile description; a data table an AI note owns shows an owner badge before the note headline.
|
|
246
|
+
*/
|
|
247
|
+
function getGridsTileDescription(item: GridItem) {
|
|
248
|
+
if (!item.ownerNoteId) {
|
|
249
|
+
return item.description;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return (
|
|
253
|
+
<span className="h_item gap_6 min_w_0">
|
|
254
|
+
<SimpleLabel
|
|
255
|
+
preset="outline"
|
|
256
|
+
color="alt"
|
|
257
|
+
text={i18n.t('sheet.data_table_owner_badge')}
|
|
258
|
+
/>
|
|
259
|
+
<span className="ellip">{item.ownerNoteHeadline?.trim() || i18n.t('agent_note.agent_note')}</span>
|
|
260
|
+
</span>
|
|
261
|
+
);
|
|
434
262
|
}
|
|
435
263
|
|
|
436
264
|
/*
|
|
437
265
|
* Return the popover id for one grids tile context menu.
|
|
438
266
|
*/
|
|
439
|
-
function getGridsTileContextMenuId(sectionId: string, item: GridItem) {
|
|
440
|
-
return `${FILE_CONSTANTS.tileContextMenuIdPrefix}${sectionId}:${item.__typename}:${item.id}`;
|
|
267
|
+
function getGridsTileContextMenuId(contextMenuOwnerId: string, sectionId: string, item: GridItem) {
|
|
268
|
+
return `${FILE_CONSTANTS.tileContextMenuIdPrefix}${contextMenuOwnerId}:${sectionId}:${item.__typename}:${item.id}`;
|
|
441
269
|
}
|
|
442
270
|
|
|
443
271
|
/*
|
|
444
272
|
* Render one mapped grids tile item with a right-click menu.
|
|
445
273
|
*/
|
|
446
|
-
const GridsTileItem = memo((p: { item: GridItem; sectionId: string }) => {
|
|
447
|
-
const { item, sectionId } = p;
|
|
448
|
-
const
|
|
449
|
-
const
|
|
274
|
+
const GridsTileItem = memo((p: { contextMenuOwnerId: string; item: GridItem; sectionId: string }) => {
|
|
275
|
+
const { contextMenuOwnerId, item, sectionId } = p;
|
|
276
|
+
const popOver = usePopOverDefinition();
|
|
277
|
+
const { openPopOver } = usePopOverActions();
|
|
278
|
+
const popOverId = getGridsTileContextMenuId(contextMenuOwnerId, sectionId, item);
|
|
450
279
|
const active = popOver?.id === popOverId;
|
|
280
|
+
// Sheet and data table routes have no server loader, so their intent prefetch stays route-JS only.
|
|
281
|
+
const prefetch = !active ? 'intent' : 'none';
|
|
451
282
|
|
|
452
283
|
/*
|
|
453
284
|
* Open the grid item context menu at the pointer location.
|
|
@@ -485,7 +316,8 @@ const GridsTileItem = memo((p: { item: GridItem; sectionId: string }) => {
|
|
|
485
316
|
active={active}
|
|
486
317
|
iconName={item.iconName}
|
|
487
318
|
title={item.title}
|
|
488
|
-
description={item
|
|
319
|
+
description={getGridsTileDescription(item)}
|
|
320
|
+
prefetch={prefetch}
|
|
489
321
|
to={item.to}
|
|
490
322
|
onContextMenu={onContextMenu}
|
|
491
323
|
/>
|
|
@@ -499,16 +331,15 @@ GridsTileItem.displayName = 'GridsTileItem';
|
|
|
499
331
|
*/
|
|
500
332
|
const GridsTileSection = memo((p: GridsTileSectionProps) => {
|
|
501
333
|
return (
|
|
502
|
-
<
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
{!p.showCreateTile ? null : (
|
|
334
|
+
<ModalTileGrid
|
|
335
|
+
className="mb_md"
|
|
336
|
+
loading={p.mocked}
|
|
337
|
+
title={p.title}
|
|
338
|
+
items={p.items}
|
|
339
|
+
ItemComponent={GridsTileItem}
|
|
340
|
+
itemProps={{ contextMenuOwnerId: p.contextMenuOwnerId, sectionId: p.sectionId }}
|
|
341
|
+
>
|
|
342
|
+
{!p.showCreateTile || !p.onCreate ? null : (
|
|
512
343
|
<TileItem
|
|
513
344
|
iconName={FILE_CONSTANTS.gridCreateIconName}
|
|
514
345
|
title={p.createTitle}
|
|
@@ -516,7 +347,7 @@ const GridsTileSection = memo((p: GridsTileSectionProps) => {
|
|
|
516
347
|
onClick={p.onCreate}
|
|
517
348
|
/>
|
|
518
349
|
)}
|
|
519
|
-
</
|
|
350
|
+
</ModalTileGrid>
|
|
520
351
|
);
|
|
521
352
|
});
|
|
522
353
|
|
|
@@ -526,16 +357,14 @@ GridsTileSection.displayName = 'GridsTileSection';
|
|
|
526
357
|
* Render the grids sheets section.
|
|
527
358
|
*/
|
|
528
359
|
function GridsSheetsSection(p: {
|
|
360
|
+
contextMenuOwnerId: string;
|
|
529
361
|
organizationId: string;
|
|
530
362
|
sheets?: SheetGQL[] | null;
|
|
531
363
|
showCreateTile: boolean;
|
|
532
364
|
}) {
|
|
533
|
-
const { organizationId, sheets, showCreateTile } = p;
|
|
365
|
+
const { contextMenuOwnerId, organizationId, sheets, showCreateTile } = p;
|
|
534
366
|
const openModalPopUp = useOpenModalPopUp();
|
|
535
|
-
const sheetItems = useMemo(
|
|
536
|
-
() => mapRenderableItems(sheets, mapSheetToGridItem),
|
|
537
|
-
[sheets],
|
|
538
|
-
);
|
|
367
|
+
const sheetItems = useMemo(() => mapRenderableItems(sheets, mapSheetToGridItem), [sheets]);
|
|
539
368
|
|
|
540
369
|
/*
|
|
541
370
|
* Open the sheet creation flow.
|
|
@@ -552,6 +381,7 @@ function GridsSheetsSection(p: {
|
|
|
552
381
|
|
|
553
382
|
return (
|
|
554
383
|
<GridsTileSection
|
|
384
|
+
contextMenuOwnerId={contextMenuOwnerId}
|
|
555
385
|
createDescription={i18n.t('sheet.create_sheet_description')}
|
|
556
386
|
createTitle={i18n.t('sheet.create_sheet')}
|
|
557
387
|
items={sheetItems}
|
|
@@ -565,43 +395,21 @@ function GridsSheetsSection(p: {
|
|
|
565
395
|
}
|
|
566
396
|
|
|
567
397
|
/*
|
|
568
|
-
* Render the grids data tables section.
|
|
398
|
+
* Render the grids data tables section. Tables are created by agents (and workflows), so this
|
|
399
|
+
* section has no create tile.
|
|
569
400
|
*/
|
|
570
|
-
function GridsDataTablesSection(p: {
|
|
571
|
-
dataTables
|
|
572
|
-
|
|
573
|
-
showCreateTile: boolean;
|
|
574
|
-
}) {
|
|
575
|
-
const { dataTables, organizationId, showCreateTile } = p;
|
|
576
|
-
const openModalPopUp = useOpenModalPopUp();
|
|
577
|
-
const dataTableItems = useMemo(
|
|
578
|
-
() => mapRenderableItems(dataTables, mapDataTableToGridItem),
|
|
579
|
-
[dataTables],
|
|
580
|
-
);
|
|
581
|
-
|
|
582
|
-
/*
|
|
583
|
-
* Open the data table creation flow.
|
|
584
|
-
*/
|
|
585
|
-
const openCreateDataTable = useCallback(() => {
|
|
586
|
-
openModalPopUp({
|
|
587
|
-
name: 'CREATE_DATASET',
|
|
588
|
-
preset: 'CREATE_DATASET',
|
|
589
|
-
props: {
|
|
590
|
-
organizationId,
|
|
591
|
-
},
|
|
592
|
-
});
|
|
593
|
-
}, [openModalPopUp, organizationId]);
|
|
401
|
+
function GridsDataTablesSection(p: { contextMenuOwnerId: string; dataTables?: DataTableGQL[] | null }) {
|
|
402
|
+
const { contextMenuOwnerId, dataTables } = p;
|
|
403
|
+
const dataTableItems = useMemo(() => mapRenderableItems(dataTables, mapDataTableToGridItem), [dataTables]);
|
|
594
404
|
|
|
595
405
|
return (
|
|
596
406
|
<GridsTileSection
|
|
597
|
-
|
|
598
|
-
createTitle={i18n.t('sheet.create_data_table')}
|
|
407
|
+
contextMenuOwnerId={contextMenuOwnerId}
|
|
599
408
|
items={dataTableItems}
|
|
600
409
|
mocked={!dataTables}
|
|
601
410
|
sectionId={FILE_CONSTANTS.sectionDataTables}
|
|
602
|
-
showCreateTile={
|
|
411
|
+
showCreateTile={false}
|
|
603
412
|
title={i18n.t('sheet.data_tables')}
|
|
604
|
-
onCreate={openCreateDataTable}
|
|
605
413
|
/>
|
|
606
414
|
);
|
|
607
415
|
}
|
|
@@ -631,26 +439,11 @@ function getGridsDisplayData(p: {
|
|
|
631
439
|
showingLastGridsReadyData: boolean;
|
|
632
440
|
showSheets: boolean;
|
|
633
441
|
}) {
|
|
634
|
-
const {
|
|
635
|
-
dataTables,
|
|
636
|
-
lastGridsReadyData,
|
|
637
|
-
sheets,
|
|
638
|
-
showDataTables,
|
|
639
|
-
showingLastGridsReadyData,
|
|
640
|
-
showSheets,
|
|
641
|
-
} = p;
|
|
442
|
+
const { dataTables, lastGridsReadyData, sheets, showDataTables, showingLastGridsReadyData, showSheets } = p;
|
|
642
443
|
|
|
643
444
|
return {
|
|
644
|
-
displayDataTables: showDataTables
|
|
645
|
-
|
|
646
|
-
? lastGridsReadyData?.dataTables
|
|
647
|
-
: dataTables
|
|
648
|
-
: null,
|
|
649
|
-
displaySheets: showSheets
|
|
650
|
-
? showingLastGridsReadyData
|
|
651
|
-
? lastGridsReadyData?.sheets
|
|
652
|
-
: sheets
|
|
653
|
-
: null,
|
|
445
|
+
displayDataTables: showDataTables ? (showingLastGridsReadyData ? lastGridsReadyData?.dataTables : dataTables) : null,
|
|
446
|
+
displaySheets: showSheets ? (showingLastGridsReadyData ? lastGridsReadyData?.sheets : sheets) : null,
|
|
654
447
|
};
|
|
655
448
|
}
|
|
656
449
|
|
|
@@ -658,16 +451,13 @@ function getGridsDisplayData(p: {
|
|
|
658
451
|
* Fetch grids data and render each visible grids section.
|
|
659
452
|
*/
|
|
660
453
|
export function GridsModule(p: GridsModuleProps) {
|
|
661
|
-
const {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
sort,
|
|
669
|
-
} = p;
|
|
670
|
-
const { popOver, closePopOver } = usePopOver();
|
|
454
|
+
const { contentClassName, notReadyClassName, organizationId, sections = 'all', showCreateTiles = true, sort } = p;
|
|
455
|
+
const contextMenuOwnerId = useId().replaceAll(':', '_');
|
|
456
|
+
const contextMenuIdPrefix = `${FILE_CONSTANTS.tileContextMenuIdPrefix}${contextMenuOwnerId}:`;
|
|
457
|
+
const popOver = usePopOverDefinition();
|
|
458
|
+
const { acknowledgePopOverEvent, closePopOver } = usePopOverActions();
|
|
459
|
+
const activeGridsPopOverId = popOver?.id?.startsWith(contextMenuIdPrefix) ? popOver.id : null;
|
|
460
|
+
const popOverEvent = usePopOverEvent({ popOverId: activeGridsPopOverId });
|
|
671
461
|
const openModalPopUp = useOpenModalPopUp();
|
|
672
462
|
const { showDataTables, showSheets } = getGridsSectionVisibility(sections);
|
|
673
463
|
const popOverHandlersRef = useRef({
|
|
@@ -687,20 +477,10 @@ export function GridsModule(p: GridsModuleProps) {
|
|
|
687
477
|
error: dataTablesError,
|
|
688
478
|
loading: dataTablesLoading,
|
|
689
479
|
refetch: refetchDataTables,
|
|
690
|
-
resetOnlyTime: dataTablesResetOnlyTime,
|
|
691
480
|
} = useDataTables(dataTablesQueryVariables);
|
|
692
|
-
const {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
loading: sheetsLoading,
|
|
696
|
-
refetch: refetchSheets,
|
|
697
|
-
resetOnlyTime: sheetsResetOnlyTime,
|
|
698
|
-
} = useSheets(sheetsQueryVariables);
|
|
699
|
-
const error =
|
|
700
|
-
(showSheets && sheetsError) || (showDataTables && dataTablesError);
|
|
701
|
-
const gridsLoading = Boolean(
|
|
702
|
-
(showSheets && sheetsLoading) || (showDataTables && dataTablesLoading),
|
|
703
|
-
);
|
|
481
|
+
const { sheets, error: sheetsError, loading: sheetsLoading, refetch: refetchSheets } = useSheets(sheetsQueryVariables);
|
|
482
|
+
const error = (showSheets && sheetsError) || (showDataTables && dataTablesError);
|
|
483
|
+
const gridsLoading = Boolean((showSheets && sheetsLoading) || (showDataTables && dataTablesLoading));
|
|
704
484
|
const lastGridsReadyData = useLastGridsReadyData({
|
|
705
485
|
dataTables,
|
|
706
486
|
sheets,
|
|
@@ -713,8 +493,7 @@ export function GridsModule(p: GridsModuleProps) {
|
|
|
713
493
|
showDataTables,
|
|
714
494
|
showSheets,
|
|
715
495
|
});
|
|
716
|
-
const showingLastGridsReadyData =
|
|
717
|
-
gridsLoading && visibleDataMissing && !!lastGridsReadyData;
|
|
496
|
+
const showingLastGridsReadyData = gridsLoading && visibleDataMissing && !!lastGridsReadyData;
|
|
718
497
|
const { displayDataTables, displaySheets } = getGridsDisplayData({
|
|
719
498
|
dataTables,
|
|
720
499
|
lastGridsReadyData,
|
|
@@ -729,18 +508,11 @@ export function GridsModule(p: GridsModuleProps) {
|
|
|
729
508
|
showDataTables,
|
|
730
509
|
showSheets,
|
|
731
510
|
});
|
|
732
|
-
const gridsResetOnlyTime = getGridsResetOnlyTime(
|
|
733
|
-
showSheets ? sheetsResetOnlyTime : '',
|
|
734
|
-
showDataTables ? dataTablesResetOnlyTime : '',
|
|
735
|
-
);
|
|
736
|
-
|
|
737
511
|
popOverHandlersRef.current = {
|
|
738
512
|
closePopOver,
|
|
739
513
|
openModalPopUp,
|
|
740
514
|
};
|
|
741
515
|
|
|
742
|
-
useGridsResetOnlyFloatingMessage(gridsResetOnlyTime, setFloatingMessage);
|
|
743
|
-
|
|
744
516
|
/*
|
|
745
517
|
* Close the grids popover when the module unmounts.
|
|
746
518
|
*/
|
|
@@ -751,31 +523,27 @@ export function GridsModule(p: GridsModuleProps) {
|
|
|
751
523
|
}, []);
|
|
752
524
|
|
|
753
525
|
/*
|
|
754
|
-
* Handle
|
|
526
|
+
* Handle item events scoped to the currently open grids context menu.
|
|
755
527
|
*/
|
|
756
528
|
useEffect(() => {
|
|
757
|
-
|
|
529
|
+
if (!popOverEvent) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
const { action, id, value } = popOverEvent;
|
|
758
534
|
const contextValue = value as GridsTileContextMenuValue | null;
|
|
759
535
|
|
|
760
|
-
if (
|
|
761
|
-
action !== 'ITEM' ||
|
|
762
|
-
typeof id !== 'string' ||
|
|
763
|
-
!id.startsWith(FILE_CONSTANTS.tileContextMenuIdPrefix) ||
|
|
764
|
-
!contextValue
|
|
765
|
-
) {
|
|
536
|
+
if (action !== 'ITEM' || typeof id !== 'string' || !id.startsWith(contextMenuIdPrefix) || !contextValue) {
|
|
766
537
|
return;
|
|
767
538
|
}
|
|
768
539
|
|
|
540
|
+
acknowledgePopOverEvent(popOverEvent.eventId);
|
|
769
541
|
const { item } = contextValue;
|
|
770
542
|
popOverHandlersRef.current.closePopOver();
|
|
771
543
|
|
|
772
544
|
switch (contextValue.action) {
|
|
773
545
|
case 'OPEN_GRID_ITEM_NEW_TAB':
|
|
774
|
-
globalThis.window?.open(
|
|
775
|
-
getGridsTileRouteUrl(item.to),
|
|
776
|
-
'_blank',
|
|
777
|
-
'noopener,noreferrer',
|
|
778
|
-
);
|
|
546
|
+
globalThis.window?.open(getGridsTileRouteUrl(item.to), '_blank', 'noopener,noreferrer');
|
|
779
547
|
return;
|
|
780
548
|
case 'DELETE_GRID_ITEM':
|
|
781
549
|
break;
|
|
@@ -790,7 +558,7 @@ export function GridsModule(p: GridsModuleProps) {
|
|
|
790
558
|
preset: deleteModalName,
|
|
791
559
|
props: getGridsTileDeleteModalProps(item, organizationId),
|
|
792
560
|
});
|
|
793
|
-
}, [organizationId,
|
|
561
|
+
}, [acknowledgePopOverEvent, contextMenuIdPrefix, organizationId, popOverEvent]);
|
|
794
562
|
|
|
795
563
|
/*
|
|
796
564
|
* Refetch every visible data source used by the grids.
|
|
@@ -824,6 +592,7 @@ export function GridsModule(p: GridsModuleProps) {
|
|
|
824
592
|
>
|
|
825
593
|
{!showSheets ? null : (
|
|
826
594
|
<GridsSheetsSection
|
|
595
|
+
contextMenuOwnerId={contextMenuOwnerId}
|
|
827
596
|
organizationId={organizationId}
|
|
828
597
|
sheets={displaySheets}
|
|
829
598
|
showCreateTile={showCreateTiles}
|
|
@@ -831,9 +600,8 @@ export function GridsModule(p: GridsModuleProps) {
|
|
|
831
600
|
)}
|
|
832
601
|
{!showDataTables ? null : (
|
|
833
602
|
<GridsDataTablesSection
|
|
603
|
+
contextMenuOwnerId={contextMenuOwnerId}
|
|
834
604
|
dataTables={displayDataTables}
|
|
835
|
-
organizationId={organizationId}
|
|
836
|
-
showCreateTile={showCreateTiles}
|
|
837
605
|
/>
|
|
838
606
|
)}
|
|
839
607
|
</div>
|