decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.67k stars 3.03k forks source link

Add custom buttons to the header #4580

Open seancdavis opened 3 years ago

seancdavis commented 3 years ago

Is your feature request related to a problem? Please describe.

I have a client with a workflow in which they are making changes constantly. In an effort to reduce the number of builds, we'd like to manually control when the site gets deployed. It makes sense that this trigger exist right alongside the content management experience.

Describe the solution you'd like

This is similar to #4424. I'd like to be able to add a button to the header, ideally globally. It would be great if it could be a React component so I could also control the click event handler.

Describe alternatives you've considered

I'm considering two other approaches:

  1. A browser extension.
  2. A custom field that enables publishing only when within some editable item.

I don't love either of these, as it's one more thing to manage, when it seems like this could be a valuable addition to the CMS application. However, I'm going to pursue both as an interim solution.

erezrokah commented 3 years ago

Hi @seancdavis, so the experience would be:

Am I correct? I think the a challenge here would be to authenticate to the build/CI service so you can control deploys. I agree there is value in making the CMS more modular though.

Another approach would be to have some kind of ignore logic in the CI/build process (only continue the build if a specific value had changed - for example a version field that an editor needs to bump)

seancdavis commented 3 years ago

Thanks for the response, @erezrokah!

My particular scenario may be an edge case, but in it, the CD pipeline is already disabled. Clicking the button would prompt a build. The rest of the workflow within the CMS would remain unchanged.

But that seems way too specific. What I was thinking of here is more along the lines of being able to add custom elements to the header either globally or within an entry's editor view. Something like registerWidget but for adding elements to the header.

codeitlikemiley commented 3 years ago

my edge usecase is using netlify cms offline, and i would like to add button, that when user click under the hood it will do a git commit , if not commited then git push...

partynikko commented 2 years ago

my edge usecase is using netlify cms offline, and i would like to add button, that when user click under the hood it will do a git commit , if not commited then git push...

Did you find any nice way to solve this? I am actually having the exact same use case :)

erezrokah commented 2 years ago

For offline usage you can use https://www.netlifycms.org/docs/beta-features/#working-with-a-local-git-repository By default it only modifies files. If you want it to commit you can create a .env file with the following:

MODE=git

and then run npx netlify-cms-proxy-server

partynikko commented 2 years ago

For offline usage you can use https://www.netlifycms.org/docs/beta-features/#working-with-a-local-git-repository By default it only modifies files. If you want it to commit you can create a .env file with the following:

MODE=git

and then run npx netlify-cms-proxy-server

Thanks! I have not seen that mode throughout the documentation. Is it new or just undocumented? I just dug through the git middleware and saw it there.

I just tried it and it makes commits on publish, that is nice! However is there any way to push? I am building an offline-first CMS (a page builder with fast feedback) and would want the content editor to not need to learn git to be able to commit and push changes.

I started implementing my own push/release script, but the issue still remains. How can I trigger the script from the CMS UI? AFAIK I cannot add any new API endpoints to the proxy server to trigger such a script?

Do you have any ideas? Many thanks! 😊

erezrokah commented 2 years ago

Is it new or just undocumented?

Undocumented until we feel it's stable enough. The default mode works best for most users.

I started implementing my own push/release script, but the issue still remains. How can I trigger the script from the CMS UI? AFAIK I cannot add any new API endpoints to the proxy server to trigger such a script?

I think you could fork the repo and create a new middleware for the proxy based on the current git one.

partynikko commented 2 years ago

I think you could fork the repo and create a new middleware for the proxy based on the current git one.

Ok thanks, so no hidden/undocumented way of doing something like that today?

Is there any way in git mode to perform a push? Could not find any in the middleware. In that case I could do release things as an Github action instead.

Out of interest, what would be the use case of git mode but not being able to push?

erezrokah commented 2 years ago

Ok thanks, so no hidden/undocumented way of doing something like that today?

Not at the moment.

Out of interest, what would be the use case of git mode but not being able to push?

It's meant for local development, if someone wants to push to GitHub they can use the GitHub backend (then they don't even need git installed). Also, it's the only way to get editorial workflow + local development as it uses branches to track draft entries (the default mode only changes files, so it cannot track drafts).

partynikko commented 2 years ago

It's meant for local development, if someone wants to push to GitHub they can use the GitHub backend (then they don't even need git installed).

Good idea for my use case I think, I will try it out.

Also, it's the only way to get editorial workflow + local development as it uses branches to track draft entries (the default mode only changes files, so it cannot track drafts).

Awesome, did not know you can have editorial with local development. Also want to try that. Any specific steps needed to set it up to work? (besides using git mode and editorial work flow in config).

Many thanks again, this undocumented feature is very tempting 👍

erezrokah commented 2 years ago

Awesome, did not know you can have editorial with local development. Also want to try that. Any specific steps needed to set it up to work? (besides using git mode and editorial work flow in config).

Other than setting the env variable for the proxy and the publish mode in config.yml no.

Many thanks again, this undocumented feature is very tempting

🎉