xladmin-import-export 0.2.0 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +8 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -266,10 +266,11 @@ function ModelImportExportActions({ client, context }) {
266
266
  return null;
267
267
  }
268
268
  const exportCount = context.selectionCount > 0 ? context.selectionCount : context.total;
269
+ const canImport = context.meta.slug === context.slug && meta.model_slug === context.slug && context.meta.read_only === false && meta.import_formats.length > 0;
269
270
  return /* @__PURE__ */ jsxs(Fragment, { children: [
270
271
  /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 0.5, sx: { alignItems: "center" }, children: [
271
- /* @__PURE__ */ jsx(Tooltip, { title: messages.exportButton, children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: () => setExportOpen(true), disabled: Boolean(error), children: /* @__PURE__ */ jsx(DownloadIcon, { fontSize: "small" }) }) }) }),
272
- /* @__PURE__ */ jsx(Tooltip, { title: messages.importButton, children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: () => setImportOpen(true), disabled: Boolean(error), children: /* @__PURE__ */ jsx(UploadIcon, { fontSize: "small" }) }) }) })
272
+ /* @__PURE__ */ jsx(Tooltip, { title: messages.exportButton, children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(IconButton, { size: "small", "aria-label": messages.exportButton, onClick: () => setExportOpen(true), disabled: Boolean(error), children: /* @__PURE__ */ jsx(DownloadIcon, { fontSize: "small" }) }) }) }),
273
+ canImport ? /* @__PURE__ */ jsx(Tooltip, { title: messages.importButton, children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(IconButton, { size: "small", "aria-label": messages.importButton, onClick: () => setImportOpen(true), disabled: Boolean(error), children: /* @__PURE__ */ jsx(UploadIcon, { fontSize: "small" }) }) }) }) : null
273
274
  ] }),
274
275
  /* @__PURE__ */ jsxs(Dialog, { open: exportOpen, onClose: () => !isExporting && setExportOpen(false), fullWidth: true, maxWidth: "md", children: [
275
276
  /* @__PURE__ */ jsx(DialogTitle, { sx: { px: 3, pt: 3, pb: 1 }, children: messages.exportTitle }),
@@ -324,7 +325,7 @@ function ModelImportExportActions({ client, context }) {
324
325
  /* @__PURE__ */ jsxs(
325
326
  Dialog,
326
327
  {
327
- open: importOpen,
328
+ open: importOpen && canImport,
328
329
  onClose: () => !isValidating && !isImporting && setImportOpen(false),
329
330
  fullWidth: true,
330
331
  maxWidth: "md",
@@ -418,7 +419,7 @@ function ModelImportExportActions({ client, context }) {
418
419
  Button,
419
420
  {
420
421
  variant: "outlined",
421
- onClick: () => void handleValidateImport({
422
+ onClick: () => canImport && void handleValidateImport({
422
423
  client,
423
424
  slug: context.slug,
424
425
  file: importFile,
@@ -429,7 +430,7 @@ function ModelImportExportActions({ client, context }) {
429
430
  setValidationResult,
430
431
  setValidationError
431
432
  }),
432
- disabled: !importFile || selectedImportFields.length === 0 || isValidating || isImporting,
433
+ disabled: !canImport || !importFile || selectedImportFields.length === 0 || isValidating || isImporting,
433
434
  children: messages.validate
434
435
  }
435
436
  ),
@@ -450,7 +451,7 @@ function ModelImportExportActions({ client, context }) {
450
451
  Button,
451
452
  {
452
453
  variant: "contained",
453
- onClick: () => void handleCommitImport({
454
+ onClick: () => canImport && void handleCommitImport({
454
455
  client,
455
456
  slug: context.slug,
456
457
  file: importFile,
@@ -467,7 +468,7 @@ function ModelImportExportActions({ client, context }) {
467
468
  },
468
469
  messages
469
470
  }),
470
- disabled: !importFile || !validationResult || validationResult.summary.errors > 0 || isImporting,
471
+ disabled: !canImport || !importFile || !validationResult || validationResult.summary.errors > 0 || isImporting,
471
472
  children: isImporting ? messages.importing : messages.confirmImport
472
473
  }
473
474
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xladmin-import-export",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Optional import/export extension for xladmin.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -43,7 +43,7 @@
43
43
  "axios": ">=1.0.0 <2.0.0",
44
44
  "react": ">=19.0.0 <20.0.0",
45
45
  "react-dom": ">=19.0.0 <20.0.0",
46
- "xladmin": ">=0.2.8 <1.0.0"
46
+ "xladmin": "^0.10.0"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
49
  "axios": {