xladmin-import-export 0.1.2 → 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 (3) hide show
  1. package/README.md +7 -2
  2. package/dist/index.js +12 -11
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <img src="https://img.shields.io/badge/English-blue?style=for-the-badge" alt="English">
4
4
  </a>
5
5
  <a href="./docs/README.ru.md">
6
- <img src="https://img.shields.io/badge/%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9-red?style=for-the-badge" alt="Русский">
6
+ <img src="https://img.shields.io/badge/%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9-red?style=for-the-badge" alt="Russian">
7
7
  </a>
8
8
  </div>
9
9
 
@@ -21,7 +21,7 @@ Optional frontend extension for `xladmin` that adds import/export actions to mod
21
21
  ## Install
22
22
 
23
23
  ```bash
24
- npm i xladmin xladmin-import-export
24
+ npm install xladmin xladmin-import-export
25
25
  ```
26
26
 
27
27
  ## Minimal Example
@@ -53,3 +53,8 @@ npm run test --workspace ./packages/xladmin-import-export
53
53
  npm run check --workspace ./packages/xladmin-import-export
54
54
  npm run build --workspace ./packages/xladmin-import-export
55
55
  ```
56
+
57
+ ## Docs
58
+
59
+ - [npm package](https://www.npmjs.com/package/xladmin-import-export)
60
+ - [Monorepo README](../../../README.md)
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
- /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 0.5, 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" }) }) }) })
271
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 0.5, sx: { alignItems: "center" }, children: [
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",
@@ -413,12 +414,12 @@ function ModelImportExportActions({ client, context }) {
413
414
  noneLabel: messages.clearFields
414
415
  }
415
416
  ),
416
- /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
417
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, sx: { alignItems: "center" }, children: [
417
418
  /* @__PURE__ */ jsx(
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
  )
@@ -486,7 +487,7 @@ function FieldsSelector({
486
487
  noneLabel
487
488
  }) {
488
489
  return /* @__PURE__ */ jsxs(Stack, { children: [
489
- /* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [
490
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", sx: { justifyContent: "space-between", alignItems: "center" }, children: [
490
491
  /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", children: title }),
491
492
  /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
492
493
  /* @__PURE__ */ jsx(Button, { size: "small", onClick: () => onChange(fields.map((field) => field.name)), children: allLabel }),
@@ -520,7 +521,7 @@ function FieldsSelector({
520
521
  }
521
522
  }
522
523
  ),
523
- label: /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 0.75, alignItems: "center", sx: { minHeight: 24 }, children: [
524
+ label: /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 0.75, sx: { minHeight: 24, alignItems: "center" }, children: [
524
525
  /* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { lineHeight: 1.35 }, children: field.label }),
525
526
  field.label !== field.name ? /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", sx: { lineHeight: 1.2 }, children: field.name }) : null
526
527
  ] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xladmin-import-export",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "description": "Optional import/export extension for xladmin.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,12 +38,12 @@
38
38
  "peerDependencies": {
39
39
  "@emotion/react": ">=11.14.0 <12.0.0",
40
40
  "@emotion/styled": ">=11.14.0 <12.0.0",
41
- "@mui/icons-material": ">=7.0.0 <8.0.0",
42
- "@mui/material": ">=7.0.0 <8.0.0",
41
+ "@mui/icons-material": ">=9.0.0 <10.0.0",
42
+ "@mui/material": ">=9.0.0 <10.0.0",
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": {