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

Add page parameters to navigation actions #1876

Merged
merged 33 commits into from
May 9, 2023

Conversation

apedroferreira
Copy link
Member

@apedroferreira apedroferreira commented Apr 12, 2023

Closes #1800
Closes #1579

Allow setting destination page parameters in navigation actions, including binding them to the current page state.

Also add documentation about navigation actions.

Screen.Recording.2023-04-27.at.22.30.15.mov

@apedroferreira apedroferreira added the new feature New feature or request label Apr 12, 2023
@apedroferreira apedroferreira self-assigned this Apr 12, 2023
@apedroferreira apedroferreira marked this pull request as ready for review April 13, 2023 21:21
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 21, 2023
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 21, 2023
@@ -385,6 +385,7 @@ function mergeThemeIntoAppDom(dom: appDom.AppDom, themeFile: Theme): appDom.AppD
}

function toBindable<V>(value: V | { $$jsExpression: string }): BindableAttrValue<V> {
console.log('fuck');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂

@apedroferreira apedroferreira force-pushed the add-navigation-page-params branch 2 times, most recently from 1670609 to 42d8617 Compare April 26, 2023 17:35
@@ -1114,15 +1114,15 @@ export function ref(nodeId: NodeId): NodeReference;
export function ref(nodeId: null | undefined): null;
export function ref(nodeId: Maybe<NodeId>): NodeReference | null;
export function ref(nodeId: Maybe<NodeId>): NodeReference | null {
return nodeId ? { $$ref: nodeId } : null;
return nodeId ? { $ref: nodeId } : null;
Copy link
Member Author

@apedroferreira apedroferreira Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we inject the initial DOM state in the HTML in the <script> tags all the $$ref properties are being changed to $ref now with the Vite runtime... Not sure exactly why.
So all navigation actions were broken.
Can we just use $ref for these properties? It shouldn't even need a migration, right? I only saw it being used in a few old connections besides navigation actions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently have two formats for bindings/actions/...

One legacy one in the appDom, one new one from the new file system format. Over time we will move the whole application over to the second format

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! How do you suggest fixing the navigation actions for now? appDom.deRef tries to get $$ref but the local DOM has the page as $ref.
Are the changes in this PR about that ok or do you suggest an alternative?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're changing the existing format, my suggestion would be to change it to align it close to the what's in the file schema. The more we can reduce the amount of conversion needed from schema to internal representation, the better. With the north star goal to get rid of the conversion completely.
Otherwise, if it works, it works, and this can be merged

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot this comment... will take a second look and add changes if it makes sense.

@apedroferreira
Copy link
Member Author

I've also allowed navigating to the current page to close #1579 too.

<img src="/static/toolpad/docs/data-binding/bind-12.png" alt="Binding editor for navigation actions" width="800" />

<!---
@TODO: Link "any query string parameters that the destination page supports" to page parameters documentation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is to be done here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should document the feature of being able to set page parameters separately from navigation actions in my opinion, and then we could link to it from here.
But I wasn't sure at the time in which section the page parameters should be documented, so I added this todo. I can make sure we do this soon enough as we're working on the docs.

@apedroferreira apedroferreira merged commit e455cd4 into master May 9, 2023
@apedroferreira apedroferreira deleted the add-navigation-page-params branch May 9, 2023 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
2 participants