Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Export forces Whole Database when a collection is selected & open #185

Open
barrett-rob opened this issue Mar 18, 2024 · 6 comments
Open
Assignees

Comments

@barrett-rob
Copy link

Describe the bug

When I click export for a collection it always defaults to "Whole database"

To Reproduce
Steps to reproduce the behavior:

  1. Click on "Content Manager" on the LHS
  2. Click on a collection
  3. Click the "Export" button
  4. Observe that the dialog/modal shows "Whole database"

Expected behavior

I should be able to export only the selected collection.

Screenshots

image
@barrett-rob
Copy link
Author

Sorry! I should add this is for the following versions:

    "@strapi/strapi": "4.17.0",
    "strapi-plugin-import-export-entries": "^1.23.1",

@abhishek1020N
Copy link

abhishek1020N commented Apr 2, 2024

The issue is due to the change in the strapi cms url path. The error arises inside the hook useSlug.
Here the value of the slug is set based on the regex with
const matches = pathname.match(/content-manager\/(collectionType|singleType)\/([a-zA-Z0-9\-:_.]*)/);
However in the latest strapi version post 4.16, the match should be done with
const matches = pathname.match(/content-manager\/(collection-types|single-types)\/([a-zA-Z0-9\-:_.]*)/);.

Hope this helps and we recieve the new version sooner. @Baboo7

@red-made
Copy link

Any update on that? Tnx

@KantapongC
Copy link

KantapongC commented Jun 20, 2024

@barrett-rob @red-made
I suggest you use patch-package. Changes are based from @abhishek1020N.

1. Make an edit to the node_modules

  • Navigate to: node_modules > strapi-plugin-import-export-entries > admin > src > hooks > useSlug.js
  • Update content
-    const matches = pathname.match(/content-manager\/(collectionType|singleType)\/([a-zA-Z0-9\-:_.]*)/);
+    const matches = pathname.match(/content-manager\/(collectionType|singleType|collection-types|single-types)\/([a-zA-Z0-9\-:_.]*)/);

2. Make changes persist in the project

  • Run npx patch-package strapi-plugin-import-export-entries
  • A new dir and file should be created automatically calledpatches/strapi-plugin-import-export-entries+1.23.1.patch. Should look something like so:
diff --git a/node_modules/strapi-plugin-import-export-entries/admin/src/hooks/useSlug.js b/node_modules/strapi-plugin-import-export-entries/admin/src/hooks/useSlug.js
index 3d206c9..24d3866 100644
--- a/node_modules/strapi-plugin-import-export-entries/admin/src/hooks/useSlug.js
+++ b/node_modules/strapi-plugin-import-export-entries/admin/src/hooks/useSlug.js
@@ -7,7 +7,7 @@ export const useSlug = () => {
   const { pathname } = useLocation();
 
   const slug = useMemo(() => {
-    const matches = pathname.match(/content-manager\/(collectionType|singleType)\/([a-zA-Z0-9\-:_.]*)/);
+    const matches = pathname.match(/content-manager\/(collectionType|singleType|collection-types|single-types)\/([a-zA-Z0-9\-:_.]*)/);
     return matches?.[2] ? matches[2] : SLUG_WHOLE_DB;
   }, [pathname]);

3. Install patch-package: So that when yarn install - our changes will be applied

  • Run: yarn add patch-package postinstall-postinstall
  • Update package.json
  "scripts": {
    ...
    "postinstall": "patch-package"
  }

4. (Optional) Ensure that our changes applied

  • Delete node_modules: rm -rf node_modules
  • Reinstall packages: yarn install
  • Start Strapi: yarn build && yarn start
  • Test that the issue is fixed

@bhavyabhut
Copy link

Any official fix?

@CodeDruid13
Copy link

Any official fix?

The steps given by @KantapongC works perfectly. There have been multiple PR's done to fix the issue but the dev has been unavailable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants