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

feat: Embed widget loading workspace settings #2068

Merged
merged 4 commits into from
Jun 12, 2024

Conversation

mattrunyon
Copy link
Collaborator

@mattrunyon mattrunyon commented Jun 11, 2024

Fixes #1964. Also removed a bunch of unnecessary code in AppInit where we were using the redux connect API with a functional component instead of just using the redux hooks

Note that even though this moves a bunch of files to app-utils, I don't consider it breaking since they are being moved out of code-studio. They wouldn't be consumed by anything else since code-studio is published as a bundle.

Due to local storage requiring a port match, this can only be tested w/ the local server in 2 steps (this should be fine in prod since the app and embed-widget run on the same port there).

  1. Start the dev server and go to the app
  2. Run some code to create a table.
  3. Change user formatting settings (e.g. show timezones and have a timestamp column)
  4. Stop the dev server.
  5. Run PORT=4000 npm run start:embed-widget. This will let us access the saved workspace from the app
  6. Go to localhost:4000/?name=<your-variable-name>
  7. The formatting settings should be applied

@mattrunyon mattrunyon requested review from bmingles and mofojed June 11, 2024 19:54
@mattrunyon mattrunyon self-assigned this Jun 11, 2024
return {
listItems: jest.fn(async () => []),
loadFile: jest.fn(async () => {
throw new Error('No file loaded');
}),
deleteItem: jest.fn(async () => undefined),
saveFile: jest.fn(async () => undefined),
saveFile: jest.fn(
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a good spot for

TestUtils.createMockProxy<dh.storage.StorageService>({
  loadFile: jest.fn(async () => {
      throw new Error('No file loaded');
  }),
})

@@ -60,6 +88,43 @@ function App(): JSX.Element {
throw new Error('Missing URL parameter "name"');
}

const sessionDetails = await getSessionDetails();
Copy link
Contributor

Choose a reason for hiding this comment

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

There seems to be a lot of duplicate code here as AppInit initApp effect. Any chance we could split out the common code into a useInitApp hook or something?

Copy link
Collaborator Author

@mattrunyon mattrunyon Jun 11, 2024

Choose a reason for hiding this comment

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

Probably. I think I'd name it useInitRedux or something like that.

There were a few I omitted since they aren't needed in embed-widget (like CommandHistory). I initially had most of the new code in a separate effect, but it actually caused a race condition with loading a table because the widget would get fetched and start rendering, but the user hadn't been set in redux yet.

I did also try moving some of the redux setters to their respective *Bootstrap components. But would need to hoist the redux store up since right now it's a child of all the bootstraps. Shouldn't have an impact though if that's what we went with

Copy link
Member

Choose a reason for hiding this comment

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

Instead of hook could just be an async helper function that gets called with all these params passed in, then await initializeApp(...) here; or a Bootstrap component as you suggested. Either way this is fine for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True. Either way pulling it out then requires moving some redux things out of code-studio and I think this is fine as is for now

@bmingles
Copy link
Contributor

Tested and confirmed this works as described.

Copy link
Contributor

@bmingles bmingles left a comment

Choose a reason for hiding this comment

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

Left 2 suggestions. Nothing big enough to block the PR

packages/code-studio/src/main/AppInit.tsx Show resolved Hide resolved
@@ -60,6 +88,43 @@ function App(): JSX.Element {
throw new Error('Missing URL parameter "name"');
}

const sessionDetails = await getSessionDetails();
Copy link
Member

Choose a reason for hiding this comment

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

Instead of hook could just be an async helper function that gets called with all these params passed in, then await initializeApp(...) here; or a Bootstrap component as you suggested. Either way this is fine for now.

@mattrunyon mattrunyon merged commit b090f20 into deephaven:main Jun 12, 2024
12 checks passed
@mattrunyon mattrunyon deleted the embed-widget-settings branch June 12, 2024 14:38
@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Embed widget should load workspace settings
3 participants