Coder Social home page Coder Social logo

Comments (4)

netwolfuk avatar netwolfuk commented on June 12, 2024

Several years ago, I made a conscious decision to not clear the checked items when one selects a template that has less supported events.

I decided that because if one changes back to the original template, one as to remember what events were previously selected because that information is lost.

Since then, the logic in that edit webhook dialog has been completely re-written and is much more advanced. It is also Jquery unit tested!

I should be able to support one of the following scenarios:

  1. Store (inside state in the webhook dialog), the original webhook config.
    When the user changes to a new template, only check the events that were previously checked and are supported by the new template.
    If the user changes to another template, do the same using the original selected events and so on.
    If the user changes back to the original template, the original events should be re-instated.

    However, what logic is applied if the user deliberately checks or un-checks an event and then changes template?

  2. Validate the available build events on the server side when the webhook is saved.
    Only enable the ones that have an applicable event available in the template.

I'm leaning towards the first option, because that at least shows to the user what the intended configuration will be when they click the save button. Option two is easier to code ;-)

from tcwebhooks.

netwolfuk avatar netwolfuk commented on June 12, 2024

However, what logic is applied if the user deliberately checks or un-checks an event and then changes template?

Thinking about that, I can handle that case too. If a user intentionally modifies the set of checked/unchecked events, then save that to the stored state.

Any further changes to template will honour the same rules as above, but the state will have been updated to reflect the user action.

If the user wants to completely back out, they can just press Cancel and no changes will be made.

It does reveal an interesting bug. What should the REST API or Controller logic do when a user selected a build event that the template does not support?

Obviously at the moment, it silently ignores that mis-match and allows the update to be written. This is why you can see these errors being thrown in the log.

I feel like an invalid update (PUT) should return 400 bad request when the list of requested events are not supported by the template.

from tcwebhooks.

netwolfuk avatar netwolfuk commented on June 12, 2024

@matt-richardson Which page URL are you using to edit webhooks?

The index page with the blurb on the right, or the edit project page?

from tcwebhooks.

matt-richardson avatar matt-richardson commented on June 12, 2024

A third option - you could inform the user "new template doesn't support x, y, and z - these have been de-selected."

A fourth option could be to do the same, but also have a "revert to previous template" option that puts you back in the previous state.

In terms of the REST API / Controller - I think it should return a bad request as you suggest 👍

@matt-richardson Which page URL are you using to edit webhooks?

The index page with the blurb on the right, or the edit project page?

I was using the edit project page.

from tcwebhooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.