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

Make commands editable and re-usable #1268

Merged
merged 63 commits into from
Feb 1, 2021

Conversation

OskarDamkjaer
Copy link
Contributor

@OskarDamkjaer OskarDamkjaer commented Jan 21, 2021

This pull request aims to make it possible to edit and re-run frames. It's added as an experimental setting for now, but defaults to on for ease of testing.

I've annotated the source code to explain what's changed and why. Apologies for the size of the PR, I recommend setting the "side by side" diff ignoring whitespace to get a better view of the bigger changes.

Demo: https://user-images.githubusercontent.com/10564538/105364088-098cad80-5bfd-11eb-9869-d606b59699a6.mp4

Try it yourself at: http://reusable-frame.surge.sh/

build_scripts/webpack-plugins.js Show resolved Hide resolved
package.json Show resolved Hide resolved
package.json Show resolved Hide resolved
src/browser/components/icons/Icons.tsx Show resolved Hide resolved
src/browser/modules/Editor/EditorFrame.tsx Show resolved Hide resolved
@@ -452,14 +452,14 @@ const switchToRequestedDb = (store: any) => {
const activeConnection = getActiveConnectionData(store.getState())
const requestedUseDb = activeConnection?.requestedUseDb

const useDefaultDb = () => {
const switchToDefaultDb = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed because of react hooks lint rule

export const REQUEST_SENT = 'requests/SENT'
export const CANCEL_REQUEST = 'requests/CANCEL'
export const REQUEST_CANCELED = 'requests/CANCELED'
export const REQUEST_UPDATED = 'requests/UPDATED'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typescript struggles to correctly type the actions if they´re not simple strings

getSettings,
REPLACE,
UPDATE
getSettings
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A few unused imports

this.code = code
// @ts-expect-error ts-migrate(2683) FIXME: 'this' implicitly has type 'any' because it does n... Remove this comment to see the full error message
this.message = message
class UseDbError extends Error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Threw together an a better Error to avoid ts-errors

if (response) {
if (response.then) {
response.then((res: any) => {
if (res) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the conditions in a way I found easier to read

Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

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

Wow, I like this feature more than I thought!
The user experience is actually really good, it's no big deal to just click in a query in the stream and edit it.
Well done!

I've left some comments but the main issue is around fullscreen mode.

e2e_tests/integration/topics.spec.ts Show resolved Hide resolved
src/browser/modules/Editor/Monaco.tsx Outdated Show resolved Hide resolved
src/browser/modules/Editor/Monaco.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@HerrEmil HerrEmil left a comment

Choose a reason for hiding this comment

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

Really cool feature :)

The gutter width does not update immediately when the useDb changes, so it's often cut off when starting to edit in a frame title bar for me
Screenshot 2021-01-28 at 17 41 58

e2e_tests/integration/0.index.spec.ts Outdated Show resolved Hide resolved
e2e_tests/support/commands.ts Outdated Show resolved Hide resolved
e2e_tests/support/commands.ts Outdated Show resolved Hide resolved
e2e_tests/support/global.d.ts Outdated Show resolved Hide resolved
e2e_tests/integration/params.spec.ts Outdated Show resolved Hide resolved
src/browser/modules/Editor/Monaco.tsx Outdated Show resolved Hide resolved
src/browser/modules/Stream/PlayFrame.tsx Outdated Show resolved Hide resolved
@OskarDamkjaer
Copy link
Contributor Author

I've gone through your comments, tests pass locally and the preview is updated (http://reusable-frame.surge.sh/). Awaiting more feedback/green pipe :)

Copy link
Contributor

@HerrEmil HerrEmil left a comment

Choose a reason for hiding this comment

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

🎉

Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

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

Not all frames seems to have the "exit fullscreen" button, which would be needed now that all frame can go into fullscreen.

Example:

  1. On :play start that shows up, click the frame editor.
  2. Press Esc to go into fullscreen on that frame
  3. Click on an input field on the frame
  4. Press Esc.
  5. Nothing happens and there's no obvious way for the user how to get out of the fullscreen state (click editor + press Esc is the only way out)

@OskarDamkjaer
Copy link
Contributor Author

Oh right forgot about that, I've removed the conditional render of it now! @oskarhane

Comment on lines -117 to -121
const cmd = frame.cmd.replace(/^:/, '')
const Frame = cmd[0].toUpperCase() + cmd.slice(1) + 'Frame'
MyFrame = require('./Extras/index')[Frame]
if (!MyFrame) {
MyFrame = getFrame(frame.type)
Copy link
Member

Choose a reason for hiding this comment

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

This was written for us to sneak in fun frames without having to explicitly import them. I think we should keep it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's always easier to take fun out than put it in, I'll keep it as is then :)

Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

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

Executing:

RETURN 1;
RETURN "hej";

kills the stream (at least when I'm not connected to a DBMS)

Comment on lines +20 to +25
},
[reusableFrame]: {
name: reusableFrame,
on: true,
displayName: 'Enable reuseable frame',
tooltip: 'Edit and rerun right in a frame'
Copy link
Member

Choose a reason for hiding this comment

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

👍

Comment on lines +374 to +386
const rollDownAnimation = keyframes`
from {
transform: translate(0, -${dim.frameBodyHeight}px);
max-height: 0;
}
to {
transform: translateY(0);
max-height: 500px; /* Greater than a frame can be */
}
`
export const AnimationContainer = styled.div`
animation: ${rollDownAnimation} 0.4s ease-in;
`
Copy link
Member

Choose a reason for hiding this comment

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

👍

@OskarDamkjaer
Copy link
Contributor Author

Good that you caught the multi statement issue! Should be resolved now.

Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

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

Let's do this 🎞️

@OskarDamkjaer OskarDamkjaer merged commit a8dc660 into neo4j:master Feb 1, 2021
@OskarDamkjaer OskarDamkjaer deleted the rebased_reusable branch February 1, 2021 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants