@jsb188/mday-web 1.1.12 → 1.1.13

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jsb188
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,20 +1,18 @@
1
1
  {
2
2
  "name": "@jsb188/mday-web",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "Web components and utilities for Marketday app.",
5
- "license": "ISC",
5
+ "license": "MIT",
6
6
  "author": "jsb188",
7
7
  "type": "module",
8
8
  "exports": {
9
- "./libs/public-form-beacon": "./src/libs/public-form-beacon.ts",
10
9
  "./libs/route-metadata.server": "./src/libs/route-metadata.server.ts",
10
+ "./utils/linkedEntity": "./src/utils/linkedEntity.ts",
11
11
  "./utils/email": "./src/utils/email.ts",
12
12
  "./utils/route": "./src/utils/route-helpers.ts",
13
13
  "./utils/log-web": "./src/utils/log-web.ts",
14
14
  "./utils/list-web": "./src/utils/list-web.ts",
15
15
  "./utils/org-web": "./src/utils/org-web.ts",
16
- "./utils/operation-pages": "./src/utils/operation-pages.ts",
17
- "./utils/public-form": "./src/utils/public-form.ts",
18
16
  "./utils/workflow-web": "./src/utils/workflow-web.ts",
19
17
  "./modules/Grids": "./src/modules/Grids.tsx",
20
18
  "./modules/RouteShell": "./src/modules/RouteShell.tsx",
@@ -24,15 +22,23 @@
24
22
  "zod": "^3.25.76"
25
23
  },
26
24
  "peerDependencies": {
27
- "@jsb188/app": "1.1.12",
28
- "@jsb188/graphql": "1.1.12",
29
- "@jsb188/mday": "1.1.12",
30
- "@jsb188/react": "1.1.12",
31
- "@jsb188/react-web": "1.1.12",
32
- "@jsb188/auth-web": "1.1.12",
33
- "@jsb188/form": "1.1.12"
25
+ "@jsb188/app": "1.1.13",
26
+ "@jsb188/graphql": "1.1.13",
27
+ "@jsb188/mday": "1.1.13",
28
+ "@jsb188/react": "1.1.13",
29
+ "@jsb188/react-web": "1.1.13",
30
+ "@jsb188/auth-web": "1.1.13",
31
+ "@jsb188/form": "1.1.13"
34
32
  },
35
33
  "scripts": {
36
34
  "test": "vitest run --config ./vitest.config.ts --passWithNoTests"
37
- }
35
+ },
36
+ "files": [
37
+ "src/**/*.{ts,tsx,css,svg}",
38
+ "!**/*.test.*",
39
+ "!**/*.spec.*",
40
+ "!**/tests/**",
41
+ "!**/*.md",
42
+ "!**/.DS_Store"
43
+ ]
38
44
  }
@@ -1,11 +1,4 @@
1
- import i18n from '@jsb188/app/i18n/index.ts';
2
1
  import { definePageFilterSchema } from '@jsb188/react/libs/page-filters';
3
- import { usePageFilters } from '@jsb188/react/libs/use-page-filters';
4
- import {
5
- makePageToolbarFilters,
6
- type PageToolbarFilter,
7
- } from '@jsb188/react-web/modules/ToolbarFilters';
8
- import type { GridItemSortEnum } from '@jsb188/mday/types/sheet.d.ts';
9
2
 
10
3
  export const GRIDS_FILTER_SCHEMA = definePageFilterSchema({
11
4
  filter: {},
@@ -14,23 +7,3 @@ export const GRIDS_FILTER_SCHEMA = definePageFilterSchema({
14
7
  default: 'UPDATED_AT_DESC',
15
8
  },
16
9
  });
17
- export const GRIDS_SORT_TOOLBAR: PageToolbarFilter = {
18
- control: 'sort',
19
- label: i18n.t('c.sort_by'),
20
- labels: {
21
- UPDATED_AT_DESC: i18n.t('app.grids_sort_updated_date'),
22
- TITLE_ASC: i18n.t('app.grids_sort_title'),
23
- },
24
- };
25
-
26
- /*
27
- * Share committed URL sort state between the grids toolbar and both grid queries.
28
- */
29
- export function useGridsToolbarState() {
30
- const state = usePageFilters(GRIDS_FILTER_SCHEMA);
31
- return {
32
- ...state,
33
- sortQueryValue: state.sort as GridItemSortEnum,
34
- toolbarOptions: makePageToolbarFilters(state, [GRIDS_SORT_TOOLBAR]),
35
- };
36
- }
@@ -1,43 +1,28 @@
1
1
  import { COMMON_CLASSNAMES } from '@jsb188/app/constants/app.ts';
2
2
  import i18n from '@jsb188/app/i18n/index.ts';
3
3
  import { cn } from '@jsb188/app/utils/string.ts';
4
- import { useDataTables } from '@jsb188/graphql/hooks/use-dataTable-qry';
5
4
  import { useSheets } from '@jsb188/graphql/hooks/use-sheet-qry';
6
- import type { DataTableGQL } from '@jsb188/mday/types/dataTable.d.ts';
7
5
  import type { GridItemSortEnum, SheetGQL } from '@jsb188/mday/types/sheet.d.ts';
8
6
  import { useOpenModalPopUp, usePopOverActions, usePopOverDefinition, usePopOverEvent } from '@jsb188/react/states';
9
7
  import type { POListIfaceItem } from '@jsb188/react/types/PopOver.d';
10
8
  import { ContentGate } from '@jsb188/react-web/modules/layout/MainLayout';
11
9
  import { ModalTileGrid } from '@jsb188/react-web/modules/layout/TabbedModalLayout';
12
10
  import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
13
- import { SimpleLabel } from '@jsb188/react-web/ui/Button';
14
11
  import { TileItem } from '@jsb188/react-web/ui/TileUI';
15
12
  import { type MouseEvent, memo, useCallback, useEffect, useId, useMemo, useRef } from 'react';
16
13
  import { mapRenderableItems } from '../utils/list-web.ts';
17
14
 
18
15
  const FILE_CONSTANTS = {
19
- contentPaddingClassName: COMMON_CLASSNAMES.contentXPadding,
20
- dataTableIconName: COMMON_ICON_NAMES.data_table,
21
- gridCreateIconName: COMMON_ICON_NAMES.plus,
22
- sectionDataTables: 'dataTables',
23
- sectionSheets: 'sheets',
24
- sheetIconName: COMMON_ICON_NAMES.sheet,
25
16
  tileContextMenuIdPrefix: 'grids_tile_context_menu:',
26
17
  } as const;
27
18
 
28
- export type GridsSectionMode = 'all' | 'sheets' | 'dataTables';
29
- export { GRIDS_FILTER_SCHEMA, useGridsToolbarState } from './Grids.filters.ts';
19
+ export { GRIDS_FILTER_SCHEMA } from './Grids.filters.ts';
30
20
 
31
21
  type GridItem = {
32
22
  id: string;
33
- __typename: 'Sheet' | 'DataTable';
34
23
  __deleted?: boolean;
35
24
  title: string;
36
25
  description: string;
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;
41
26
  to: string;
42
27
  };
43
28
 
@@ -46,85 +31,6 @@ type GridsTileContextMenuValue = {
46
31
  item: GridItem;
47
32
  };
48
33
 
49
- type GridsReadyData = {
50
- dataTables: DataTableGQL[] | null;
51
- sheets: SheetGQL[] | null;
52
- };
53
-
54
- type GridsSectionVisibility = {
55
- showDataTables: boolean;
56
- showSheets: boolean;
57
- };
58
-
59
- type GridsTileSectionProps = {
60
- contextMenuOwnerId: string;
61
- createDescription?: string;
62
- createTitle?: string;
63
- items: GridItem[];
64
- mocked: boolean;
65
- sectionId: string;
66
- showCreateTile: boolean;
67
- title: string;
68
- onCreate?: () => void;
69
- };
70
-
71
- interface GridsModuleProps {
72
- contentClassName?: string;
73
- notReadyClassName?: string;
74
- organizationId: string;
75
- sections?: GridsSectionMode;
76
- showCreateTiles?: boolean;
77
- sort: GridItemSortEnum;
78
- }
79
-
80
- /*
81
- * Return which grids sections should be visible for one module mode.
82
- */
83
- function getGridsSectionVisibility(sections: GridsSectionMode): GridsSectionVisibility {
84
- return {
85
- showDataTables: sections !== FILE_CONSTANTS.sectionSheets,
86
- showSheets: sections !== FILE_CONSTANTS.sectionDataTables,
87
- };
88
- }
89
-
90
- /*
91
- * Keep the last fully loaded grids data available during replacement fetches.
92
- */
93
- function useLastGridsReadyData(p: {
94
- dataTables?: DataTableGQL[] | null;
95
- sheets?: SheetGQL[] | null;
96
- showDataTables: boolean;
97
- showSheets: boolean;
98
- }) {
99
- const { dataTables, sheets, showDataTables, showSheets } = p;
100
- const readyDataRef = useRef<GridsReadyData | null>(null);
101
-
102
- useEffect(() => {
103
- if ((showSheets && !sheets) || (showDataTables && !dataTables)) {
104
- return;
105
- }
106
-
107
- readyDataRef.current = {
108
- dataTables: showDataTables ? dataTables || null : null,
109
- sheets: showSheets ? sheets || null : null,
110
- };
111
- }, [dataTables, sheets, showDataTables, showSheets]);
112
-
113
- return readyDataRef.current;
114
- }
115
-
116
- /*
117
- * Return query variables for one grids data source when its section is visible.
118
- */
119
- function getGridsQueryVariables(visible: boolean, organizationId: string, sort: GridItemSortEnum) {
120
- return visible
121
- ? {
122
- organizationId,
123
- sort,
124
- }
125
- : null;
126
- }
127
-
128
34
  /*
129
35
  * Convert one sheet record into a grids tile item.
130
36
  */
@@ -135,36 +41,13 @@ function mapSheetToGridItem(sheet: SheetGQL): GridItem | null {
135
41
 
136
42
  return {
137
43
  id: sheet.id,
138
- __typename: 'Sheet',
139
44
  title: sheet.title || i18n.t('app.untitled_sheet'),
140
45
  description: sheet.description || sheet.name || '',
141
- iconName: FILE_CONSTANTS.sheetIconName,
142
46
  to: `/app/s/${sheet.id}`,
143
47
  __deleted: Boolean(sheet.__deleted || sheet.deletedAt),
144
48
  };
145
49
  }
146
50
 
147
- /*
148
- * Convert one dataTable record into a grids tile item.
149
- */
150
- function mapDataTableToGridItem(dataTable: DataTableGQL): GridItem | null {
151
- if (!dataTable.id) {
152
- return null;
153
- }
154
-
155
- return {
156
- id: dataTable.id,
157
- __typename: 'DataTable',
158
- title: dataTable.title || i18n.t('sheet.untitled_data_table'),
159
- description: dataTable.description || '',
160
- iconName: FILE_CONSTANTS.dataTableIconName,
161
- ownerNoteId: dataTable.ownerNote?.id,
162
- ownerNoteHeadline: dataTable.ownerNote?.headline,
163
- to: `/app/d/${dataTable.id}`,
164
- __deleted: Boolean(dataTable.__deleted || dataTable.archivedAt),
165
- };
166
- }
167
-
168
51
  /*
169
52
  * Convert a right-click event into a popover anchor rectangle.
170
53
  */
@@ -191,29 +74,10 @@ function getGridsTileRouteUrl(to: string) {
191
74
  }
192
75
 
193
76
  /*
194
- * Return the modal preset name used to delete one grids tile.
195
- */
196
- function getGridsTileDeleteModalName(item: GridItem) {
197
- return item.__typename === 'Sheet' ? 'DELETE_SHEET' : 'DELETE_DATA_TABLE';
198
- }
199
-
200
- /*
201
- * Return the modal props used to delete one grids tile.
202
- */
203
- function getGridsTileDeleteModalProps(item: GridItem, organizationId: string) {
204
- return {
205
- itemTitle: item.title,
206
- organizationId,
207
- ...(item.__typename === 'Sheet' ? { sheetId: item.id } : { dataTableId: item.id }),
208
- };
209
- }
210
-
211
- /*
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.
77
+ * Build the spreadsheet tile context menu.
214
78
  */
215
79
  function getGridsTileContextOptions(item: GridItem): POListIfaceItem[] {
216
- const options: POListIfaceItem[] = [
80
+ return [
217
81
  {
218
82
  __type: 'LIST_ITEM',
219
83
  iconName: COMMON_ICON_NAMES.open_external_link,
@@ -223,61 +87,29 @@ function getGridsTileContextOptions(item: GridItem): POListIfaceItem[] {
223
87
  item,
224
88
  } satisfies GridsTileContextMenuValue,
225
89
  },
226
- ];
227
-
228
- if (!item.ownerNoteId) {
229
- options.push({
90
+ {
230
91
  __type: 'LIST_ITEM',
231
92
  iconName: COMMON_ICON_NAMES.delete,
232
- text: i18n.t(item.__typename === 'Sheet' ? 'sheet.delete_sheet' : 'sheet.delete_data_table'),
93
+ text: i18n.t('sheet.delete_sheet'),
233
94
  className: 'cl_err_hv',
234
95
  value: {
235
96
  action: 'DELETE_GRID_ITEM',
236
97
  item,
237
98
  } satisfies GridsTileContextMenuValue,
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
- );
262
- }
263
-
264
- /*
265
- * Return the popover id for one grids tile context menu.
266
- */
267
- function getGridsTileContextMenuId(contextMenuOwnerId: string, sectionId: string, item: GridItem) {
268
- return `${FILE_CONSTANTS.tileContextMenuIdPrefix}${contextMenuOwnerId}:${sectionId}:${item.__typename}:${item.id}`;
99
+ },
100
+ ];
269
101
  }
270
102
 
271
103
  /*
272
104
  * Render one mapped grids tile item with a right-click menu.
273
105
  */
274
- const GridsTileItem = memo((p: { contextMenuOwnerId: string; item: GridItem; sectionId: string }) => {
275
- const { contextMenuOwnerId, item, sectionId } = p;
106
+ const GridsTileItem = memo((p: { contextMenuIdPrefix: string; item: GridItem }) => {
107
+ const { contextMenuIdPrefix, item } = p;
276
108
  const popOver = usePopOverDefinition();
277
109
  const { openPopOver } = usePopOverActions();
278
- const popOverId = getGridsTileContextMenuId(contextMenuOwnerId, sectionId, item);
110
+ const popOverId = contextMenuIdPrefix + item.id;
279
111
  const active = popOver?.id === popOverId;
280
- // Sheet and data table routes have no server loader, so their intent prefetch stays route-JS only.
112
+ // Sheet routes have no server loader, so their intent prefetch stays route-JS only.
281
113
  const prefetch = !active ? 'intent' : 'none';
282
114
 
283
115
  /*
@@ -314,9 +146,9 @@ const GridsTileItem = memo((p: { contextMenuOwnerId: string; item: GridItem; sec
314
146
  <TileItem
315
147
  __deleted={item.__deleted}
316
148
  active={active}
317
- iconName={item.iconName}
149
+ iconName={COMMON_ICON_NAMES.sheet}
318
150
  title={item.title}
319
- description={getGridsTileDescription(item)}
151
+ description={item.description}
320
152
  prefetch={prefetch}
321
153
  to={item.to}
322
154
  onContextMenu={onContextMenu}
@@ -327,131 +159,9 @@ const GridsTileItem = memo((p: { contextMenuOwnerId: string; item: GridItem; sec
327
159
  GridsTileItem.displayName = 'GridsTileItem';
328
160
 
329
161
  /*
330
- * Render one presentational grids tile section.
331
- */
332
- const GridsTileSection = memo((p: GridsTileSectionProps) => {
333
- return (
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 : (
343
- <TileItem
344
- iconName={FILE_CONSTANTS.gridCreateIconName}
345
- title={p.createTitle}
346
- description={p.createDescription}
347
- onClick={p.onCreate}
348
- />
349
- )}
350
- </ModalTileGrid>
351
- );
352
- });
353
-
354
- GridsTileSection.displayName = 'GridsTileSection';
355
-
356
- /*
357
- * Render the grids sheets section.
358
- */
359
- function GridsSheetsSection(p: {
360
- contextMenuOwnerId: string;
361
- organizationId: string;
362
- sheets?: SheetGQL[] | null;
363
- showCreateTile: boolean;
364
- }) {
365
- const { contextMenuOwnerId, organizationId, sheets, showCreateTile } = p;
366
- const openModalPopUp = useOpenModalPopUp();
367
- const sheetItems = useMemo(() => mapRenderableItems(sheets, mapSheetToGridItem), [sheets]);
368
-
369
- /*
370
- * Open the sheet creation flow.
371
- */
372
- const openCreateSheet = useCallback(() => {
373
- openModalPopUp({
374
- name: 'CREATE_SHEET',
375
- preset: 'CREATE_SHEET',
376
- props: {
377
- organizationId,
378
- },
379
- });
380
- }, [openModalPopUp, organizationId]);
381
-
382
- return (
383
- <GridsTileSection
384
- contextMenuOwnerId={contextMenuOwnerId}
385
- createDescription={i18n.t('sheet.create_sheet_description')}
386
- createTitle={i18n.t('sheet.create_sheet')}
387
- items={sheetItems}
388
- mocked={!sheets}
389
- sectionId={FILE_CONSTANTS.sectionSheets}
390
- showCreateTile={showCreateTile}
391
- title={i18n.t('sheet.sheets')}
392
- onCreate={openCreateSheet}
393
- />
394
- );
395
- }
396
-
397
- /*
398
- * Render the grids data tables section. Tables are created by agents (and workflows), so this
399
- * section has no create tile.
162
+ * Show spreadsheets in the picker and handle actions on their tiles.
400
163
  */
401
- function GridsDataTablesSection(p: { contextMenuOwnerId: string; dataTables?: DataTableGQL[] | null }) {
402
- const { contextMenuOwnerId, dataTables } = p;
403
- const dataTableItems = useMemo(() => mapRenderableItems(dataTables, mapDataTableToGridItem), [dataTables]);
404
-
405
- return (
406
- <GridsTileSection
407
- contextMenuOwnerId={contextMenuOwnerId}
408
- items={dataTableItems}
409
- mocked={!dataTables}
410
- sectionId={FILE_CONSTANTS.sectionDataTables}
411
- showCreateTile={false}
412
- title={i18n.t('sheet.data_tables')}
413
- />
414
- );
415
- }
416
-
417
- /*
418
- * Return whether visible grids data is missing during a fetch.
419
- */
420
- function getGridsVisibleDataMissing(p: {
421
- dataTables?: DataTableGQL[] | null;
422
- sheets?: SheetGQL[] | null;
423
- showDataTables: boolean;
424
- showSheets: boolean;
425
- }) {
426
- const { dataTables, sheets, showDataTables, showSheets } = p;
427
-
428
- return (showSheets && !sheets) || (showDataTables && !dataTables);
429
- }
430
-
431
- /*
432
- * Return the data lists that should render while preserving last-ready data during fetches.
433
- */
434
- function getGridsDisplayData(p: {
435
- dataTables?: DataTableGQL[] | null;
436
- lastGridsReadyData: GridsReadyData | null;
437
- sheets?: SheetGQL[] | null;
438
- showDataTables: boolean;
439
- showingLastGridsReadyData: boolean;
440
- showSheets: boolean;
441
- }) {
442
- const { dataTables, lastGridsReadyData, sheets, showDataTables, showingLastGridsReadyData, showSheets } = p;
443
-
444
- return {
445
- displayDataTables: showDataTables ? (showingLastGridsReadyData ? lastGridsReadyData?.dataTables : dataTables) : null,
446
- displaySheets: showSheets ? (showingLastGridsReadyData ? lastGridsReadyData?.sheets : sheets) : null,
447
- };
448
- }
449
-
450
- /*
451
- * Fetch grids data and render each visible grids section.
452
- */
453
- export function GridsModule(p: GridsModuleProps) {
454
- const { contentClassName, notReadyClassName, organizationId, sections = 'all', showCreateTiles = true, sort } = p;
164
+ export function GridsModule({ organizationId, sort }: { organizationId: string; sort: GridItemSortEnum }) {
455
165
  const contextMenuOwnerId = useId().replaceAll(':', '_');
456
166
  const contextMenuIdPrefix = `${FILE_CONSTANTS.tileContextMenuIdPrefix}${contextMenuOwnerId}:`;
457
167
  const popOver = usePopOverDefinition();
@@ -459,55 +169,17 @@ export function GridsModule(p: GridsModuleProps) {
459
169
  const activeGridsPopOverId = popOver?.id?.startsWith(contextMenuIdPrefix) ? popOver.id : null;
460
170
  const popOverEvent = usePopOverEvent({ popOverId: activeGridsPopOverId });
461
171
  const openModalPopUp = useOpenModalPopUp();
462
- const { showDataTables, showSheets } = getGridsSectionVisibility(sections);
463
172
  const popOverHandlersRef = useRef({
464
173
  closePopOver,
465
174
  openModalPopUp,
466
175
  });
467
- const sheetsQueryVariables = useMemo(
468
- () => getGridsQueryVariables(showSheets, organizationId, sort),
469
- [organizationId, showSheets, sort],
470
- );
471
- const dataTablesQueryVariables = useMemo(
472
- () => getGridsQueryVariables(showDataTables, organizationId, sort),
473
- [organizationId, showDataTables, sort],
474
- );
475
- const {
476
- dataTables,
477
- error: dataTablesError,
478
- loading: dataTablesLoading,
479
- refetch: refetchDataTables,
480
- } = useDataTables(dataTablesQueryVariables);
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));
484
- const lastGridsReadyData = useLastGridsReadyData({
485
- dataTables,
486
- sheets,
487
- showDataTables,
488
- showSheets,
489
- });
490
- const visibleDataMissing = getGridsVisibleDataMissing({
491
- dataTables,
492
- sheets,
493
- showDataTables,
494
- showSheets,
495
- });
496
- const showingLastGridsReadyData = gridsLoading && visibleDataMissing && !!lastGridsReadyData;
497
- const { displayDataTables, displaySheets } = getGridsDisplayData({
498
- dataTables,
499
- lastGridsReadyData,
500
- sheets,
501
- showDataTables,
502
- showingLastGridsReadyData,
503
- showSheets,
504
- });
505
- const notReady = getGridsVisibleDataMissing({
506
- dataTables: displayDataTables,
507
- sheets: displaySheets,
508
- showDataTables,
509
- showSheets,
510
- });
176
+ const { sheets, loading, error, refetch } = useSheets({ organizationId, sort });
177
+ const lastSheets = useRef<typeof sheets>(null);
178
+ useEffect(() => {
179
+ if (sheets) lastSheets.current = sheets;
180
+ }, [sheets]);
181
+ const visibleSheets = sheets ?? (loading ? lastSheets.current : null);
182
+ const items = useMemo(() => mapRenderableItems(visibleSheets, mapSheetToGridItem), [visibleSheets]);
511
183
  popOverHandlersRef.current = {
512
184
  closePopOver,
513
185
  openModalPopUp,
@@ -551,59 +223,31 @@ export function GridsModule(p: GridsModuleProps) {
551
223
  return;
552
224
  }
553
225
 
554
- const deleteModalName = getGridsTileDeleteModalName(item);
555
-
556
226
  popOverHandlersRef.current.openModalPopUp({
557
- name: deleteModalName,
558
- preset: deleteModalName,
559
- props: getGridsTileDeleteModalProps(item, organizationId),
227
+ name: 'DELETE_SHEET',
228
+ preset: 'DELETE_SHEET',
229
+ props: { sheetId: item.id, itemTitle: item.title, organizationId },
560
230
  });
561
231
  }, [acknowledgePopOverEvent, contextMenuIdPrefix, organizationId, popOverEvent]);
562
232
 
563
- /*
564
- * Refetch every visible data source used by the grids.
565
- */
566
- const refetchGridItems = useCallback(() => {
567
- if (showSheets) {
568
- refetchSheets();
569
- }
570
-
571
- if (showDataTables) {
572
- refetchDataTables();
573
- }
574
- }, [refetchDataTables, refetchSheets, showDataTables, showSheets]);
575
-
576
233
  return (
577
234
  <ContentGate
578
235
  showLoadingIfNotReady
579
- notReady={notReady}
580
- loading={gridsLoading}
581
- error={error || null}
582
- notReadyClassName={notReadyClassName ?? 'fs v_center'}
583
- onRefetch={refetchGridItems}
236
+ notReady={!visibleSheets}
237
+ loading={!!loading}
238
+ error={error}
239
+ notReadyClassName="h_500 v_center"
240
+ onRefetch={() => refetch()}
584
241
  >
585
- <div
586
- className={cn(
587
- 'rel pt_md pb_md',
588
- FILE_CONSTANTS.contentPaddingClassName,
589
- showingLastGridsReadyData && 'anim_data_loading',
590
- contentClassName,
591
- )}
592
- >
593
- {!showSheets ? null : (
594
- <GridsSheetsSection
595
- contextMenuOwnerId={contextMenuOwnerId}
596
- organizationId={organizationId}
597
- sheets={displaySheets}
598
- showCreateTile={showCreateTiles}
599
- />
600
- )}
601
- {!showDataTables ? null : (
602
- <GridsDataTablesSection
603
- contextMenuOwnerId={contextMenuOwnerId}
604
- dataTables={displayDataTables}
605
- />
606
- )}
242
+ <div className={cn('rel pt_md pb_md', COMMON_CLASSNAMES.contentXPadding, !sheets && !!visibleSheets && 'anim_data_loading')}>
243
+ <ModalTileGrid
244
+ className="mb_md"
245
+ loading={!visibleSheets}
246
+ title={i18n.t('sheet.sheets')}
247
+ items={items}
248
+ ItemComponent={GridsTileItem}
249
+ itemProps={{ contextMenuIdPrefix }}
250
+ />
607
251
  </div>
608
252
  </ContentGate>
609
253
  );