decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

feat: add initial workflow status in config

Open RomainOliva opened this issue 3 years ago • 18 comments

Summary

closes #1306

For our case we now use the editional workflow, we use it to preview our changes, but sometimes we just want to publish directly. And this is not possible, we have to save, change status to ready and publish.

I would have preferred to do this issue #4054 but it seemed more complex for a first issue on the project :)

The goal here is to add the initial status in the configuration, then in our cas we can put PENDING_PUBLISH status by default and then publish directly.

Test plan

Checklist

Please add a x inside each checkbox:

  • [x] I have read the contribution guidelines.
  • [x] Code is formatted via running yarn format.
  • [x] Tests are passing via running yarn test.
  • [x] The status checks are successful (continuous integration). Those can be seen below.

Cute animal

RomainOliva avatar May 11 '22 07:05 RomainOliva

I don't really know where to add the expected test, if you can guide me :)

RomainOliva avatar May 11 '22 08:05 RomainOliva

Hello @bytrangle, thanks for your review.

I tried when I start the backend, and everything work right. But inside test I can't find where I can test this behavior, in the file that you have pointed out to me it doesn't work because it's looks like it's not in "editorial_workflow".

I tried here :

  • https://github.com/netlify/netlify-cms/blob/dbf2920254fb3682e12463a6df8ded4b94b55be0/packages/netlify-cms-core/src/tests/backend.spec.js#L347

And here :

  • https://github.com/netlify/netlify-cms/blob/cb2ad687ee250937a9dffc21ebfd4c399c6d76db/packages/netlify-cms-backend-test/src/tests/implementation.spec.js#L48 But we can only access to the window.repoFiles where there is no the entry workflow state.

Can you give me a little help please?

RomainOliva avatar May 31 '22 09:05 RomainOliva

On further investigation, I think the test should be in netlify-cms-core/.../actions/__tests__/config.spec.js.

I got the idea from the test "should set publish_mode from config". I've tried create a barebone config object with two props: publish_mode and default_workflow_status.

Then I called applyDefaults(config). This function takes the original config object parsed from config.yml file and mutate it so that certain important properties won't be undefined if the user forgot to add them.

For example, publish_mode has to be SIMPLE_WOKFLOW, slug has to be an empty object, collections is an empty array unless specified otherwise in the config.

Then I check if applyDefaults(config).default_workflow_status is equal to the value I passed to the namesake property of the config.

You'll also need to modify the applyDefaults(config) so that if the user sets publish_mode to editorial_workflow, and don't specify the default_workflow_status, the mutated config will have a property default_workflow_status set to draft.

Does that make sense?

bytrangle avatar Jun 02 '22 14:06 bytrangle

@bytrangle Oh nice ! It's really clear, I will do that :)

Just for your last sentence, you really think it's useful with the following code ?

  • https://github.com/RomainOliva/netlify-cms/blob/e89358a11101377de3c0ca3eb7187a3cf8b545e1/packages/netlify-cms-core/src/reducers/config.ts#L38

With this line if there is no default_workflow_status it take the first status (draft one)

thanks again for your help

RomainOliva avatar Jun 02 '22 14:06 RomainOliva

@bytrangle I just add a fixup commit with some change and the test, tell me if this sounds good to you :)

RomainOliva avatar Jun 02 '22 15:06 RomainOliva

@krider2010 Look forward to your review.

bytrangle avatar Jun 06 '22 08:06 bytrangle

Just a heads up I'm working on being added to the maintainer group for review reasons.

krider2010 avatar Jun 13 '22 13:06 krider2010

@bytrangle There is no other reviewer who can watch this pr? :)

RomainOliva avatar Jun 14 '22 14:06 RomainOliva

@bytrangle Small up please, this feature would allow us to save a lot of time in our processes 🙈

RomainOliva avatar Jun 23 '22 08:06 RomainOliva

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 26 '23 09:04 stale[bot]

It is still relevant today 🙈

RomainOliva avatar Apr 26 '23 09:04 RomainOliva

It is still relevant today see_no_evil

waiting for this to happen

emp3ror avatar May 15 '23 08:05 emp3ror

@RomainOliva are you still interested in moving this forward?

martinjagodic avatar Oct 16 '23 12:10 martinjagodic

@martinjagodic Yes, it can be interesting to merge it 😇

RomainOliva avatar Oct 16 '23 12:10 RomainOliva

Great! Can you solve the merge conflicts? They mostly emerged because of the package rename.

martinjagodic avatar Oct 16 '23 12:10 martinjagodic

Deploy request for cms-demo rejected.

Name Link
Latest commit cb2ee3da0502823bc4af7273444d73ddeb77956f

netlify[bot] avatar Nov 10 '23 15:11 netlify[bot]

Deploy Preview for decap-www ready!

Name Link
Latest commit cb2ee3da0502823bc4af7273444d73ddeb77956f
Latest deploy log https://app.netlify.com/sites/decap-www/deploys/654e52adad3a9d00086355ce
Deploy Preview https://deploy-preview-6469--decap-www.netlify.app/docs/configuration-options
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Nov 10 '23 15:11 netlify[bot]

@martinjagodic sorry for the delay, it's all good the PR is rebased :)

RomainOliva avatar Nov 10 '23 15:11 RomainOliva