@aglyn/plugins-data 1.12.0 → 1.13.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/package.json +10 -10
- package/src/lib/components/dataset-schema-dialog.component.d.ts +14 -0
- package/src/lib/components/dataset-schema-dialog.component.js +150 -117
- package/src/lib/components/dataset-schema-dialog.component.js.map +1 -1
- package/src/lib/components/host-datasets-card.component.js +71 -34
- package/src/lib/components/host-datasets-card.component.js.map +1 -1
- package/src/lib/components/use-dataset-writes-blocked.d.ts +49 -12
- package/src/lib/components/use-dataset-writes-blocked.js +87 -19
- package/src/lib/components/use-dataset-writes-blocked.js.map +1 -1
- package/src/lib/declarations.d.ts +25 -0
- package/src/lib/declarations.js +37 -0
- package/src/lib/declarations.js.map +1 -0
- package/src/lib/model/data-permissions.d.ts +34 -0
- package/src/lib/model/data-permissions.js +108 -0
- package/src/lib/model/data-permissions.js.map +1 -0
- package/src/lib/model/dataset-access.d.ts +22 -0
- package/src/lib/model/dataset-access.js +30 -0
- package/src/lib/model/dataset-access.js.map +1 -0
- package/src/lib/plugin.js +4 -1
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/server/dataset-access.server.d.ts +40 -0
- package/src/lib/server/dataset-access.server.js +47 -0
- package/src/lib/server/dataset-access.server.js.map +1 -0
- package/src/lib/server/dataset-figures.js +12 -0
- package/src/lib/server/dataset-figures.js.map +1 -1
- package/src/lib/server/datasets-route.js +61 -15
- package/src/lib/server/datasets-route.js.map +1 -1
- package/src/lib/transfer/dataset-transfer-access.server.d.ts +23 -0
- package/src/lib/transfer/dataset-transfer-access.server.js +45 -0
- package/src/lib/transfer/dataset-transfer-access.server.js.map +1 -0
- package/src/lib/transfer/dataset-transfer-resource.js +2 -1
- package/src/lib/transfer/dataset-transfer-resource.js.map +1 -1
|
@@ -44,7 +44,7 @@ import { fillRecordAddresses } from "../record-pages/record-pages.js";
|
|
|
44
44
|
import { planReferenceFixups, referencingFieldIds, restrictedDeleteMessage } from "../model/dataset-record-delete-plan.js";
|
|
45
45
|
import { BlockedControl } from "@aglyn/shared-ui-jsx/components/blocked-control.component";
|
|
46
46
|
import { datasetListScope } from "../model/dataset-record-list.js";
|
|
47
|
-
import {
|
|
47
|
+
import { DATASETS_EXPORT_REFUSAL, DATASETS_VIEW_RECORDS_REFUSAL, DATASETS_WRITE_REFUSAL, useDatasetWritesBlocked } from "./use-dataset-writes-blocked.js";
|
|
48
48
|
import { DATASET_SAMPLE_RECORD_NOTE, datasetDisplayName, isSampleDatasetRecord, parseDatasetFieldEntries } from "../model/datasets.js";
|
|
49
49
|
import { datasetTransferResourceKey } from "../transfer/dataset-transfer-key.js";
|
|
50
50
|
/**
|
|
@@ -55,6 +55,16 @@ import { datasetTransferResourceKey } from "../transfer/dataset-transfer-key.js"
|
|
|
55
55
|
* sharing is "Only the site they were created in". Everywhere else a new
|
|
56
56
|
* dataset starts on All sites: the org Data page has no site to limit it to.
|
|
57
57
|
*/ /** The records walk serves no header order: every header sorts the page. */ const NO_QUERY_SORTS = [];
|
|
58
|
+
/** The grid's own Export and Print, off for a member without "Export data" (AGL-4047). */ const EXPORT_OFF_TOOLBAR = {
|
|
59
|
+
toolbar: {
|
|
60
|
+
csvOptions: {
|
|
61
|
+
disableToolbarButton: true
|
|
62
|
+
},
|
|
63
|
+
printOptions: {
|
|
64
|
+
disableToolbarButton: true
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
58
68
|
/** Stable, so an empty answer does not re-render the card. */ const NO_DATASETS = [];
|
|
59
69
|
/** The most datasets the card lists, and the most a delete's reference check walks. */ const DATASET_LIST_WINDOW = 100;
|
|
60
70
|
/** A dataset read off its document, as the card's rows carry it. */ const datasetRow = (snapshot)=>_extends({
|
|
@@ -117,7 +127,6 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
117
127
|
// it easy to miss: the page looks right and logs a denial every mount.
|
|
118
128
|
const scopeReady = Boolean(dataScope) && scopeLoaded;
|
|
119
129
|
const firestore = useFirestore();
|
|
120
|
-
const blocked = useDatasetWritesBlocked(orgId);
|
|
121
130
|
const { enqueueSnackbar } = useSnackbar();
|
|
122
131
|
const { confirm } = useConfirmationContext();
|
|
123
132
|
const { org } = props;
|
|
@@ -228,6 +237,9 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
228
237
|
const [selectedId, setSelectedId] = useState(null);
|
|
229
238
|
const [schemaOpen, setSchemaOpen] = useState(false);
|
|
230
239
|
const selected = (_datasets_find = datasets.find((item)=>item.$id === selectedId)) != null ? _datasets_find : datasets[0];
|
|
240
|
+
// What this member may do with THIS dataset (AGL-4047): one placed on one site
|
|
241
|
+
// answers to that site.
|
|
242
|
+
const blocked = useDatasetWritesBlocked(orgId, selected == null ? void 0 : selected.visibleTo);
|
|
231
243
|
// Typed model (AGL-179): drives headers, cell rendering, and the
|
|
232
244
|
// document form; v1 datasets get a derived all-text model.
|
|
233
245
|
const model = useMemo(()=>effectiveDatasetModel(selected != null ? selected : {}), [
|
|
@@ -328,11 +340,12 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
328
340
|
filters: recordPlan.plan.filters,
|
|
329
341
|
orderBy: recordPlan.plan.orderBy
|
|
330
342
|
});
|
|
331
|
-
const { rows: records, hasMore: hasMoreRecords, page: recordPage, setPage: setRecordPage, pageSize: recordPageSize, setPageSize: setRecordPageSize } = usePagedCollection((pageLimit)=>dataScope && (selected == null ? void 0 : selected.$id) ? query(collection(firestore, dataScope[0], dataScope[1], 'datasets', selected.$id, 'records'), ...listQueryConstraints(recordPlan.plan), limit(pageLimit)) : null, [
|
|
343
|
+
const { rows: records, hasMore: hasMoreRecords, page: recordPage, setPage: setRecordPage, pageSize: recordPageSize, setPageSize: setRecordPageSize } = usePagedCollection((pageLimit)=>dataScope && (selected == null ? void 0 : selected.$id) && !blocked.records ? query(collection(firestore, dataScope[0], dataScope[1], 'datasets', selected.$id, 'records'), ...listQueryConstraints(recordPlan.plan), limit(pageLimit)) : null, [
|
|
332
344
|
firestore,
|
|
333
345
|
dataScope,
|
|
334
346
|
selected == null ? void 0 : selected.$id,
|
|
335
|
-
recordPlanKey
|
|
347
|
+
recordPlanKey,
|
|
348
|
+
blocked.records
|
|
336
349
|
], {
|
|
337
350
|
idField: '$id'
|
|
338
351
|
});
|
|
@@ -413,7 +426,7 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
413
426
|
// above, which is the PICKER value and is null until the user chooses.
|
|
414
427
|
const countedDatasetId = selected == null ? void 0 : selected.$id;
|
|
415
428
|
useEffect(()=>{
|
|
416
|
-
if (!dataScope || !countedDatasetId) return;
|
|
429
|
+
if (!dataScope || !countedDatasetId || blocked.records) return;
|
|
417
430
|
let active = true;
|
|
418
431
|
void getCountFromServer(collection(firestore, dataScope[0], dataScope[1], 'datasets', countedDatasetId, 'records')).then((snapshot)=>{
|
|
419
432
|
if (active) {
|
|
@@ -432,7 +445,8 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
432
445
|
firestore,
|
|
433
446
|
dataScope,
|
|
434
447
|
countedDatasetId,
|
|
435
|
-
recordCountEpoch
|
|
448
|
+
recordCountEpoch,
|
|
449
|
+
blocked.records
|
|
436
450
|
]);
|
|
437
451
|
// Pending, denied, or answered about the PREVIOUS selection, the loaded
|
|
438
452
|
// rows stand in. They can only UNDERSTATE (same collections, capped),
|
|
@@ -1032,14 +1046,17 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1032
1046
|
* matched and written on the server, through the same record writes as
|
|
1033
1047
|
* every other create and update, and the export streams the fields the
|
|
1034
1048
|
* person picks. Outside the console shell there is no launcher, and no
|
|
1035
|
-
* Import or Export to offer. Inside it, Import is
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
1049
|
+
* Import or Export to offer. Inside it, Import is on for a member who may
|
|
1050
|
+
* write this dataset and switched off with the permission named for one who
|
|
1051
|
+
* may not, and Export likewise for "Export data", for a member who can see it
|
|
1052
|
+
* (AGL-3546, AGL-4047) — the transfer routes' own rule.
|
|
1038
1053
|
*/ const transfer = useTransferLauncher();
|
|
1039
|
-
const transferTarget = (selected == null ? void 0 : selected.$id) ? {
|
|
1054
|
+
const transferTarget = (selected == null ? void 0 : selected.$id) ? _extends({
|
|
1040
1055
|
resource: datasetTransferResourceKey(selected.$id),
|
|
1041
1056
|
scope: 'org'
|
|
1042
|
-
}
|
|
1057
|
+
}, blocked.known ? {
|
|
1058
|
+
importAllowed: !blocked.writes
|
|
1059
|
+
} : {}) : null;
|
|
1043
1060
|
const canImport = Boolean(transfer && transferTarget && transfer.can('import', transferTarget));
|
|
1044
1061
|
const canExport = Boolean(transfer && transferTarget && transfer.can('export', transferTarget));
|
|
1045
1062
|
const handleImport = useCallback(()=>{
|
|
@@ -1153,7 +1170,7 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1153
1170
|
}),
|
|
1154
1171
|
/*#__PURE__*/ _jsx(BlockedControl, {
|
|
1155
1172
|
blocked: blocked.writes,
|
|
1156
|
-
reason:
|
|
1173
|
+
reason: blocked.writesReason,
|
|
1157
1174
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
1158
1175
|
size: "small",
|
|
1159
1176
|
onClick: handleOpenRecord(record),
|
|
@@ -1162,7 +1179,7 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1162
1179
|
}),
|
|
1163
1180
|
/*#__PURE__*/ _jsx(BlockedControl, {
|
|
1164
1181
|
blocked: blocked.writes,
|
|
1165
|
-
reason:
|
|
1182
|
+
reason: blocked.writesReason,
|
|
1166
1183
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
1167
1184
|
size: "small",
|
|
1168
1185
|
color: "error",
|
|
@@ -1181,7 +1198,8 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1181
1198
|
handleOpenRecord,
|
|
1182
1199
|
handleDeleteRecord,
|
|
1183
1200
|
recordFilter,
|
|
1184
|
-
blocked.writes
|
|
1201
|
+
blocked.writes,
|
|
1202
|
+
blocked.writesReason
|
|
1185
1203
|
]);
|
|
1186
1204
|
/*
|
|
1187
1205
|
* EVERY HEADER SORTS — THE PAGE ON SCREEN (AGL-3680). A record's values are
|
|
@@ -1269,7 +1287,7 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1269
1287
|
}),
|
|
1270
1288
|
/*#__PURE__*/ _jsx(BlockedControl, {
|
|
1271
1289
|
blocked: blocked.writes,
|
|
1272
|
-
reason:
|
|
1290
|
+
reason: blocked.writesReason,
|
|
1273
1291
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
1274
1292
|
size: "small",
|
|
1275
1293
|
color: "primary",
|
|
@@ -1278,8 +1296,8 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1278
1296
|
})
|
|
1279
1297
|
}),
|
|
1280
1298
|
/*#__PURE__*/ _jsx(BlockedControl, {
|
|
1281
|
-
blocked: blocked.writes,
|
|
1282
|
-
reason:
|
|
1299
|
+
blocked: blocked.writes && !blocked.sharingOnly,
|
|
1300
|
+
reason: blocked.writesReason,
|
|
1283
1301
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
1284
1302
|
size: "small",
|
|
1285
1303
|
onClick: ()=>setSchemaOpen(true),
|
|
@@ -1293,19 +1311,27 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1293
1311
|
} : {}, {
|
|
1294
1312
|
onFinished: ()=>setRecordCountEpoch((epoch)=>epoch + 1)
|
|
1295
1313
|
})) : null,
|
|
1296
|
-
canImport ? /*#__PURE__*/ _jsx(
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
children:
|
|
1314
|
+
canImport || transfer && transferTarget && blocked.writes ? /*#__PURE__*/ _jsx(BlockedControl, {
|
|
1315
|
+
blocked: !canImport,
|
|
1316
|
+
reason: blocked.writesReason,
|
|
1317
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
1318
|
+
size: "small",
|
|
1319
|
+
onClick: handleImport,
|
|
1320
|
+
children: 'Import'
|
|
1321
|
+
})
|
|
1300
1322
|
}) : null,
|
|
1301
|
-
canExport && (recordCount || records.length) ? /*#__PURE__*/ _jsx(
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
children:
|
|
1323
|
+
canExport && (recordCount || records.length) || transfer && blocked.exports ? /*#__PURE__*/ _jsx(BlockedControl, {
|
|
1324
|
+
blocked: blocked.exports,
|
|
1325
|
+
reason: DATASETS_EXPORT_REFUSAL,
|
|
1326
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
1327
|
+
size: "small",
|
|
1328
|
+
onClick: handleExport,
|
|
1329
|
+
children: 'Export'
|
|
1330
|
+
})
|
|
1305
1331
|
}) : null,
|
|
1306
1332
|
/*#__PURE__*/ _jsx(BlockedControl, {
|
|
1307
1333
|
blocked: blocked.deletes,
|
|
1308
|
-
reason:
|
|
1334
|
+
reason: blocked.deletesReason,
|
|
1309
1335
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
1310
1336
|
size: "small",
|
|
1311
1337
|
color: "error",
|
|
@@ -1321,7 +1347,11 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1321
1347
|
limit: checkQuota(org, 'recordsPerDataset', recordCount).limit,
|
|
1322
1348
|
noun: "record"
|
|
1323
1349
|
}) : null,
|
|
1324
|
-
selected &&
|
|
1350
|
+
selected && blocked.records ? /*#__PURE__*/ _jsx(Typography, {
|
|
1351
|
+
variant: "body2",
|
|
1352
|
+
color: "text.secondary",
|
|
1353
|
+
children: DATASETS_VIEW_RECORDS_REFUSAL
|
|
1354
|
+
}) : selected && (records.length > 0 || recordPage > 0 || filteringRecords) ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
1325
1355
|
children: [
|
|
1326
1356
|
/*#__PURE__*/ _jsx(ListFilterChips, {
|
|
1327
1357
|
fields: recordFilter.fields,
|
|
@@ -1337,7 +1367,7 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1337
1367
|
...recordColumnSort.notices
|
|
1338
1368
|
]
|
|
1339
1369
|
}),
|
|
1340
|
-
/*#__PURE__*/ _jsx(ListTable, {
|
|
1370
|
+
/*#__PURE__*/ _jsx(ListTable, _extends({
|
|
1341
1371
|
"aria-label": "Records",
|
|
1342
1372
|
rows: recordColumnSort.rows,
|
|
1343
1373
|
columnSort: recordColumnSort,
|
|
@@ -1349,9 +1379,12 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1349
1379
|
filterMode: "server",
|
|
1350
1380
|
filterModel: gridFilter.filterModel,
|
|
1351
1381
|
onFilterModelChange: gridFilter.onFilterModelChange,
|
|
1352
|
-
quickFilter: true
|
|
1382
|
+
quickFilter: true
|
|
1383
|
+
}, blocked.exports ? {
|
|
1384
|
+
slotProps: EXPORT_OFF_TOOLBAR
|
|
1385
|
+
} : {}, {
|
|
1353
1386
|
noRowsLabel: filteringRecords ? 'No records match these filters' : 'No records yet.'
|
|
1354
|
-
}),
|
|
1387
|
+
})),
|
|
1355
1388
|
/*#__PURE__*/ _jsx(ListPagination, {
|
|
1356
1389
|
page: recordPage,
|
|
1357
1390
|
pageSize: recordPageSize,
|
|
@@ -1375,7 +1408,7 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1375
1408
|
},
|
|
1376
1409
|
children: [
|
|
1377
1410
|
/*#__PURE__*/ _jsx(BlockedControl, {
|
|
1378
|
-
blocked: blocked.
|
|
1411
|
+
blocked: blocked.creates,
|
|
1379
1412
|
reason: DATASETS_WRITE_REFUSAL,
|
|
1380
1413
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
1381
1414
|
size: "small",
|
|
@@ -1386,7 +1419,7 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1386
1419
|
})
|
|
1387
1420
|
}),
|
|
1388
1421
|
datasets.length >= 2 ? /*#__PURE__*/ _jsx(BlockedControl, {
|
|
1389
|
-
blocked: blocked.
|
|
1422
|
+
blocked: blocked.creates,
|
|
1390
1423
|
reason: DATASETS_WRITE_REFUSAL,
|
|
1391
1424
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
1392
1425
|
size: "small",
|
|
@@ -1716,7 +1749,7 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1716
1749
|
})
|
|
1717
1750
|
]
|
|
1718
1751
|
}),
|
|
1719
|
-
/*#__PURE__*/ _jsx(DatasetSchemaDialog, {
|
|
1752
|
+
/*#__PURE__*/ _jsx(DatasetSchemaDialog, _extends({
|
|
1720
1753
|
hostId: hostId,
|
|
1721
1754
|
orgId: orgId != null ? orgId : undefined,
|
|
1722
1755
|
dataset: schemaOpen && selected ? selected : null,
|
|
@@ -1728,8 +1761,12 @@ export function newDatasetSharingNote(siteOnly) {
|
|
|
1728
1761
|
seedFromCache: datasetsFromCache,
|
|
1729
1762
|
seedUnreadable: datasetsStatus === 'error',
|
|
1730
1763
|
seedListen: datasetsListen,
|
|
1764
|
+
canChangeSharing: !blocked.creates
|
|
1765
|
+
}, blocked.sharingOnly ? {
|
|
1766
|
+
sharingOnlyReason: blocked.writesReason
|
|
1767
|
+
} : {}, {
|
|
1731
1768
|
onClose: ()=>setSchemaOpen(false)
|
|
1732
|
-
})
|
|
1769
|
+
}))
|
|
1733
1770
|
]
|
|
1734
1771
|
});
|
|
1735
1772
|
}
|