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

BUG: View DataSource should Update on base workspace change #3760

Open
rolandschuetz opened this issue Mar 21, 2024 · 2 comments
Open

BUG: View DataSource should Update on base workspace change #3760

rolandschuetz opened this issue Mar 21, 2024 · 2 comments
Labels
8.3 9.0 Bug Label to mark the change as bugfix UI & UX

Comments

@rolandschuetz
Copy link
Contributor

rolandschuetz commented Mar 21, 2024

Description

A Inspector View can use a datasource. Here's a very simple example of this: https://github.com/flownative/neos-workspace-preview/blob/main/Configuration/NodeTypes.yaml#L9-L11

Now when a user changes it's base workspace, the datasource is not reloaded: https://github.com/neos/neos-ui/blob/8.4/packages/neos-ui-views/src/Data/DataLoader/index.js#L53-L56

In most cases, reloading the datasoure, when the selectors.CR.Workspaces.baseWorkspaceSelector(state),changes would be expected. As an integrator you can't even force a reload, because the arguments only support ClientEval, and in ClientEval only the node is available, and it's workspace is always the user workspace.

Steps to Reproduce

  1. Install e.g. https://github.com/flownative/neos-workspace-preview or any Inspector View that uses a datasource
  2. Open the dev tools to monitor ajax requests
  3. Changte the base workspace

Expected behavior

Datasource is updated.

Actual behavior

Outdated data.

Affected Versions

Neos: *

UI: 5.0 - 9.0

Possible solution

In the neosContextConnector add baseWorkspace: selectors.CR.Workspaces.baseWorkspaceSelector(state), and in componentDidUpdate reload if the workspace changes.

@mhsdesign
Copy link
Member

i noticed this problem when using dataSourcesDataLoader.resolveValue() directly in a neos ui plugin.

The resolve method will create a cache identifier of all the passed options makeCacheKey(options):

And as the contextNodePath will only ever include user-marchenry and not the baseworkspace, which can be switched without reloading the neos ui, i added a dummy parameter __baseWorkspaceName, which i will not use on the server but only to influence the cache key.

const baseWorkspaceName = useSelector(selectors.CR.Workspaces.baseWorkspaceSelector);

const dataSourcesDataLoader = neos.globalRegistry.get("dataLoaders").get("DataSources");

dataSourcesDataLoader.resolveValue({
  contextNodePath: documentNode.contextPath,
  dataSourceIdentifier: "vendor-site-data-source",
  // to invalidate datasource cache
  __baseWorkspaceName: baseWorkspaceName,
}).then((result) => {
  console.log(result)
});

@rolandschuetz
Copy link
Contributor Author

Sounds good, can we bring this in the neos-ui?

@grebaldi grebaldi changed the title View DataSource should Update on base workspace change BUG: View DataSource should Update on base workspace change Apr 18, 2024
@grebaldi grebaldi added Bug Label to mark the change as bugfix UI & UX 9.0 8.3 labels Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.3 9.0 Bug Label to mark the change as bugfix UI & UX
Projects
None yet
Development

No branches or pull requests

3 participants