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

Preview Button not visible when install Plugin using npm i strapi-plugin-preview-button@latest #119

Open
Ram-Metapercept opened this issue Nov 3, 2023 · 8 comments

Comments

@Ram-Metapercept
Copy link

Ram-Metapercept commented Nov 3, 2023

I am installing Plugin with latest version of strapi but not visible eventhough I run command npm run build and added code in my config/plugin.js file by just following https://market.strapi.io/plugins/strapi-plugin-preview-button documention but not getting my problem solved. if anyone has solution please help me

Thank you

@mattmilburn
Copy link
Owner

Hi @Ram-Metapercept Could you provide more your details from your package.json and config/plugins.js files? Have you also tried restarting or rebuiding your app?

@dwhiteGUK
Copy link

I've got this issue, it's any new entries in a collection don't have the preview button. Old entries in a collection are all good:

image

This is my config file:

 module.exports = ({ env }) => {
  return {
    "preview-button": {
      config: {
        contentTypes: [          
          {
            uid: "api::page.page",
            draft: {
              url: `${env("FRONTEND_URL")}/api/preview`,
              query: {
                slug: "{slug}",
                secret: env("FRONTEND_PREVIEW_SECRET"),
              },
            },
            published: {
              url: `${env("FRONTEND_URL")}/api/preview`,
              query: {
                slug: "{slug}",
                secret: env("FRONTEND_PREVIEW_SECRET"),
              },
            },
          },
        ],
      },
    },
  };
};

All running locally, I've rebuilt, restarted the CMS and changed node versions.

@L-Weisz
Copy link

L-Weisz commented Nov 28, 2023

Hello, did you find a way to make it work ? I have the same issue

@mattmilburn
Copy link
Owner

mattmilburn commented Nov 28, 2023

Hi @Ram-Metapercept @dwhiteGUK @L-Weisz Please make sure to provide your package.json details in addition to your config/plugins.js as it can be very helpful in diagnosing this kind of issue.

As of right now, the current stable version of Strapi is v4.14.5 so please make sure you are using that one. There are also alpha releases for v4.15.x and you should avoid that until the alpha label is removed.

@barath-kumar-tw
Copy link

Hi @mattmilburn, I configured as per the documentation but I don't see the preview button.

Here is the config:

export default ({ env }) => ({
  'preview-button': {
    config: {
      contentTypes: [
        {
          uid: "api::home-page.home-page",
          draft: {
            url: "http://localhost:3000/homepage",
            query: {
              mode: "preview",
            },
            openTarget: '_blank',
            alwaysVisible: true,
          },
        },
        
      ],
    },
  },
});

package.json

{
  "name": "strapi-cms",
  "version": "0.1.0",
  "description": "A Strapi application",
  "scripts": {
    "dev": "strapi develop",
    "start": "NODE_ENV=production strapi start",
    "build": "strapi build",
    "strapi": "strapi"
  },
  "dependencies": {
    "@ckeditor/strapi-plugin-ckeditor": "^0.0.10",
    "@strapi/plugin-cloud": "4.17.1",
    "@strapi/plugin-i18n": "4.17.1",
    "@strapi/plugin-users-permissions": "4.17.1",
    "@strapi/provider-upload-aws-s3": "^4.17.1",
    "@strapi/strapi": "4.17.1",
    "better-sqlite3": "8.6.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-router-dom": "5.3.4",
    "strapi-plugin-preview-button": "^2.2.1",
    "styled-components": "5.3.3"
  },
  "author": {
    "name": "Admin"
  },
  "strapi": {
    "uuid": "39c6dbea-1674-4254-8754-cfa3a0904ca7"
  },
  "engines": {
    "node": ">=18.0.0 <=20.x.x",
    "npm": ">=6.0.0"
  },
  "license": "MIT"
}

@L-Weisz
Copy link

L-Weisz commented Jan 18, 2024

Hello I solved my problem I had named the file plugin.ts instead of plugins.ts , the s was missing, check the name of your file @barath-kumar-tw

@barath-kumar-tw
Copy link

barath-kumar-tw commented Jan 19, 2024

@L-Weisz The file name was already plugins.ts. I have an upload plugin and added preview-button as another plugin.

@mattmilburn

Screenshot 2024-01-19 at 10 17 55 AM

@devmeireles
Copy link

For who is facing the same issue, I've just figured out the reason, in my case was missing the API_PREVIEW_URL on .env file, after adding API_PREVIEW_URL=http://localhost:3000/api/preview/ it's working properly and displaying the preview button on Strapi Admin

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

6 participants