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

Default Redirect Configuration #151

Closed
cornehoskam opened this issue Sep 13, 2022 · 7 comments
Closed

Default Redirect Configuration #151

cornehoskam opened this issue Sep 13, 2022 · 7 comments
Assignees
Labels
release/4.0.3 type/feature New feature or request umbraco/v10 Issues and tasks related to Umbraco 10.

Comments

@cornehoskam
Copy link

Hi there!
Is there an option to set a Default configuration when adding a new redirect? Our client wishes for the "Forward query string" option to be enabled by default when adding new redirects, and only explicitly disable it when they wish to do so, to make sure that they don't forget to enable this option. Is there any option/configuration to do this?
Kind regards,

@abjerner
Copy link
Member

Hi @cornehoskam

Not currently 😦

I guess adding support for that could make sense, but that would require sending a model to the add redirect overlay, which isn't happening right now.

@cornehoskam
Copy link
Author

Hi Anders,

Darn, that's a shame! Thank you anyway for the quick response! 🙂

@abjerner
Copy link
Member

Thinking a bit more about it, broadcasting a JavaScript event that lets you manipulate the initial model might actually not require that much. I can try giving that a go.

Doing the same from C# would require some more development.

Is this for Umbraco 10 btw?

@cornehoskam
Copy link
Author

As of right now it's still the latest version of Umbraco 9, but we're also in the middle of upgrading and within a week we should be on Umbraco 10, so consider this question only relevant for v10! 🙂

@abjerner abjerner added type/feature New feature or request umbraco/v10 Issues and tasks related to Umbraco 10. labels Sep 13, 2022
@abjerner abjerner self-assigned this Sep 13, 2022
abjerner added a commit that referenced this issue Sep 13, 2022
This commit introduces two new events broadcasted via Umbraco's JavaScript event system. The events could be used for setting default values for new redirects, or manipulating the parts of the UI of the redirect overlay.

Related to #151
@abjerner
Copy link
Member

Hi @cornehoskam

I just pushed a new v4.0.3 release, which exposes two new JavaScript events for the redirect overlay. They can be used something like this:

app.run(function (eventsService) {

    eventsService.on("skybrud.umbraco.redirects.overlay.initializing", function (_, args) {

        if (args.model.redirect.id > 0) return;

        args.model.redirect.forward = true;
        args.model.redirect.permanent = false;

    });

    eventsService.on("skybrud.umbraco.redirects.overlay.initialized", function (_, args) {

        if (args.model.redirect.id === 0) return;

        args.model.navigation.push({
            alias: "statistics",
            name: "Statistics",
            view: "nope",
            icon: "icon-chart-curve"
        });

    });

});

The overlay does various initialization - eg. it creates an array of the properties visible in the overlay. To change the default value for Forward query string, you'd want to use the skybrud.umbraco.redirects.overlay.initializing event as this fires before the properties arrays are initialized.

The events also allows you to do other things - eg. add a fictitious content app showing statistics about the redirect via the skybrud.umbraco.redirects.overlay.initialized event:

image

The release is for Umbraco 10. I can't remember how much it will take to change the same in the Umbraco 9 package.

@Rockerby
Copy link

Rockerby commented Oct 9, 2023

What's the appetite for having this configured in C#? Not sure how much work is involved (I'd be happy to spend some time on it). Having something set in the appsettings would feel much more natural than requiring to create a "package" to inject some JS for this.

@abjerner
Copy link
Member

abjerner commented Oct 9, 2023

What's the appetite for having this configured in C#? Not sure how much work is involved (I'd be happy to spend some time on it). Having something set in the appsettings would feel much more natural than requiring to create a "package" to inject some JS for this.

It's not something I've looked for in a while - partially because it has only been requested a few times. But it's a feature that does make sense to improve a bit. The current JS solution was quick to add, but I agree that is should be configurable from app settings and potentially also C#.

@Rockerby if you're working on something, I'd suggest introducing a Skybrud:Redirects:DefaultSettings:ForwardQueryString value in app settings. You can find the existing setting models here:

https://github.com/skybrud/Skybrud.Umbraco.Redirects/tree/v4/main/src/Skybrud.Umbraco.Redirects/Config

I'm not entirely sure about the DefaultSettings name, so feel free to use something else if it makes more sense.

Redirects can be added both from the dashboard, the content app and the inbound redirects property editor. The default setting models somehow needs to be passed on to the Angular controllers for these. It could be via the exiting API calls to get redirects in a given context. Or since the package is already setting some server variables, these could be extended to expose the default settings:

https://github.com/skybrud/Skybrud.Umbraco.Redirects/blob/v4/main/src/Skybrud.Umbraco.Redirects/Notifications/Handlers/ServerVariablesParsingHandler.cs

I hope this helps. Otherwise it's totally fine to submit an unfinished PR, and I can try to help out and point you in the right direction 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/4.0.3 type/feature New feature or request umbraco/v10 Issues and tasks related to Umbraco 10.
Projects
None yet
Development

No branches or pull requests

3 participants