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

UI-Template: Should give error if invalid page/ ui is selected #1039

Closed
arturv2000 opened this issue Jun 28, 2024 · 1 comment · Fixed by #1078
Closed

UI-Template: Should give error if invalid page/ ui is selected #1039

arturv2000 opened this issue Jun 28, 2024 · 1 comment · Fixed by #1078
Labels
bug Something isn't working needs-triage Needs looking at to decide what to do

Comments

@arturv2000
Copy link
Contributor

arturv2000 commented Jun 28, 2024

Current Behavior

Currently the ui-template only gives error if no group selected (in case Type = Widget - Group-Scoped)
image

When in (Group-Scoped) there will be a red triangle associated to the node, and an error appear when attempting to a Deploy.

The same error should appear in the other configurations in case no page or ui is selected

image

Currently no error is indicated, leading that the user may do a deploy and start wondering why is not working....

Figured out where one of the error is:

const valid = (this.templateScope === 'local' && !!this.group) || (this.templateScope !== 'local')

The variable this.templateScope is not updated in real time with the selection, it always has the initial value local when is a new template.

Also there is no validation for the css types.

It doesn't show the error while the edit dialog is open, but it shows onde closed with the red triangle on the node, and it will show the error when reopening the edit dialog.

The behaviour is different from Node-Red 4.0.1 and Node-Red 3.1.7

In 3.1.7 by default when selecting a new Type the ui/page automatically selects the first entry, witch normally is a valid option. With 4.0.1 the default option is none

Expected Behavior

No response

Steps To Reproduce

No response

Environment

  • Dashboard version: 1.12.2
  • Node-RED version: 4.0.1
  • Node.js version:
  • npm version:
  • Platform/OS:
  • Browser:

Have you provided an initial effort estimate for this issue?

I am not a FlowFuse team member

@arturv2000 arturv2000 added bug Something isn't working needs-triage Needs looking at to decide what to do labels Jun 28, 2024
@arturv2000
Copy link
Contributor Author

Just for fun, attempted to find a fix / solution for this...

group: {
    type: 'ui-group',
    validate: function () {
        const tempScope = ($('#node-input-templateScope').val() !== undefined) ? $('#node-input-templateScope').val() : this.templateScope
        const groupVal = ($('#node-input-group').val() !== undefined) ? $('#node-input-group').val() : this.group

        if (tempScope !== 'local') {
            return true
        }

        if (tempScope === 'local') {
            if (!!groupVal && groupVal !== '_ADD_') {
                return true
            }
        }
        return false
    }
}, // for when template is scoped to 'local' (default)
page: {
    type: 'ui-page',
    validate: function () {
        const tempScope = ($('#node-input-templateScope').val() !== undefined) ? $('#node-input-templateScope').val() : this.templateScope
        const pageVal = ($('#node-input-page').val() !== undefined) ? $('#node-input-page').val() : this.page

        if (tempScope !== 'widget:page' && tempScope !== 'page:style') {
            return true
        }
        if (tempScope === 'widget:page' || tempScope === 'page:style') {
            if (!!pageVal && pageVal !== '_ADD_') {
                return true
            }
        }
        return false
    }
}, // for when template is scoped to 'page'
ui: {
    type: 'ui-base',
    validate: function () {
        const tempScope = ($('#node-input-templateScope').val() !== undefined) ? $('#node-input-templateScope').val() : this.templateScope
        const uiVal = ($('#node-input-ui').val() !== undefined) ? $('#node-input-ui').val() : this.ui

        if (tempScope !== 'widget:ui' && tempScope !== 'site:style') {
            return true
        }
        if (tempScope === 'widget:ui' || tempScope === 'site:style') {
            if (!!uiVal && uiVal !== '_ADD_') {
                return true
            }
        }
        return false
    }
},

If this is a viable solution, I can open a PR for this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Needs looking at to decide what to do
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant