Create a pop up alert when deploying node in a no local configuration

Hello.
Nodered 3.1.6

When we are on a server (in a not local configuration) trying to deploy a code, there is no alert sent to notify a potential risk.

I think it can be benefical to add such a feature (to avoid creating important mistakes).

For exemple, i tried on /package/node_modules/@node-red/editor-client/src/js/ui/deploy.js to modify arround line 440 with the following code :
And it result in a pop up when deploying in a no local disposition

....
            let notificationButtons = [];
            let notification;
            if (!window.location.href.includes("localhost") && !window.location.href.includes("127.0.0.1")) {
                showWarning = true;
                notificationMessage = "<p>" + RED._("You are not in localhost. Do not deploy unvalidated flow") + "</p>" +
                    "<p>" +
                    RED._('deploy.confirm.confirm') +
                    "</p>";

                notificationButtons = [
                    {
                        id: "red-ui-deploy-dialog-confirm-deploy-deploy",
                        text: RED._("deploy.confirm.button.confirm"),
                        class: "primary",
                        click: function () {
                            save(true);
                            notification.close();
                        }
                    }
                ];
            } else if (hasUnknown && !ignoreDeployWarnings.unknown) {
                showWarning = true;
                notificationMessage = "<p>" + RED._('deploy.confirm.unknown') + "</p>" +
                    '<ul class="red-ui-deploy-dialog-confirm-list"><li>' + cropList(unknownNodes).map(function (n) { return sanitize(n) }).join("</li><li>") + "</li></ul><p>" +
                    RED._('deploy.confirm.confirm') +
                    "</p>";

                notificationButtons = [
                    {
                        text: RED._("deploy.unknownNodesButton"),
                        class: "pull-left",
                        click: function() {
                            notification.close();
                            RED.actions.invoke("core:search","type:unknown ");
                        }
                    },
                    {
                        id: "red-ui-deploy-dialog-confirm-deploy-deploy",
                        text: RED._("deploy.confirm.button.confirm"),
                        class: "primary",
                        click: function () {
                            save(true);
                            notification.close();
                        }
                    }
                ];
            }
.......

Don't like this.

I never access my Node-red servers using a browser on the server itself so I'm always in a "no local configuration".

This popup, like popups in general, would be very annoying.

2 Likes

So maybe with a setting to enable or disable this kind of popup ?

There is a difference in culture between WIndows and Linux hemispheres.

In WIndows it's very common to see an "Are you sure?" popup. In my experience, this results in clicking Yes without any real consideration of the question.

Contrariwise, Linux tries to do whatever you ask it to, assuming you know what you are doing.
A user generally learns to consider the consequences before clicking Go.

Neither approach actually prevents mistakes.
Fortunately Node-red respects CTRL-Z to undo.

I think it's better to only allow thoughtful and competent users to access important live servers.

I think this may have some merit as an option in settings.js - perhaps a PR?

It certainly couldn't be a fixed feature as it wouldn't allow for the many different ways of using Node-RED.

Thanks for your consideration.
Yes a setting that can be on / off to nofity if the adress is not "localhost" or something custom can be good :wink:
But for sure nodered is used with a lot of different way so I don't know the best solution to implement it

I don't really understand the risk, is it linked to multi-user editing (two users editing at the same time)?