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: Recording selector draft #36

Merged
merged 6 commits into from
Jul 17, 2024
Merged

Conversation

going-confetti
Copy link
Collaborator

@going-confetti going-confetti commented Jul 16, 2024

image

Comment on lines +20 to +22
export function useHasRecording() {
return useGeneratorStore((state) => state.requests.length > 0)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@e-fisher what's your favorite way of defining reusable selectors? Maybe the should be callbacks that we then import and pass to useGeneratorStore?

Copy link
Member

Choose a reason for hiding this comment

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

pmndrs/zustand#387

would this approach work well ? Seems like a clean way to have a file defining selectors, importing them and using with the useGeneratorStore
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes! That's what I meant by callbacks that we then import and pass to useGeneratorStore, I should've been more specific

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd probably vote for the callback approach just because it's a bit more explicit -
useHasRecording - hook named this way could be doing anything
useGeneratorStore(selectHasRecording) - indicates that value is read from store

Comment on lines +32 to +36
{requests.length > 0 && (
<Button onClick={() => setShowAllowListDialog(true)}>
Allowed hosts [{allowList.length}/{hosts.length}]
</Button>
)}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not needed until we have the recording

Comment on lines -49 to +41
<Button onClick={saveGenerator}>Save</Button>
<Button onClick={handleImport}>Import HAR</Button>
<RecordingSelector />
<AllowList />
<Button onClick={handleExport} disabled={!hasRecording}>
Export script
</Button>
{hasRecording && <Button onClick={saveGenerator}>Save</Button>}
{hasRecording && <Button onClick={handleExport}>Export script</Button>}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Took the liberty of rearranging the buttons to have the most important ones on the right + hiding save, export, and allow list until there's an actual recording.
It still looks a bit crowded, but probably the biggest UX issue is that primary buttons are overused in the header. We'll probably tackle this once the design is ready
image

@@ -64,7 +51,7 @@ export function Generator() {
</Allotment.Pane>
</Allotment>
</Allotment.Pane>
<Allotment.Pane minSize={300}>
<Allotment.Pane minSize={300} visible={hasRecording}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Similar reasoning as with the header buttons: no need to show the sidebar if it's empty

<CaretDownIcon />
</IconButton>
</Popover.Trigger>
<Popover.Content size="1" align="end">
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will have a scrollable/searchable list of saved recordings once we implement filesystem integration and all that

<Flex gap="2">
<Popover.Close>
<Button variant="outline" asChild>
<Link to="/recorder">Start recording</Link>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently, just redirects to the recorder page, but should also start a new recording in future

Copy link
Member

@Llandy3d Llandy3d left a comment

Choose a reason for hiding this comment

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

🚀

Comment on lines +20 to +22
export function useHasRecording() {
return useGeneratorStore((state) => state.requests.length > 0)
}
Copy link
Member

Choose a reason for hiding this comment

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

pmndrs/zustand#387

would this approach work well ? Seems like a clean way to have a file defining selectors, importing them and using with the useGeneratorStore
image

@@ -58,3 +59,8 @@ export const useGeneratorStore = create<GeneratorState>()(
}),
}))
)

function generateNewName() {
const date = new Date().toISOString().split('T')[0]
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't split it, so that if you are working on multiple ones you can save them with a different name on the same day 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, you're right! A fix is incoming in a bit 👀

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed it, but used the US format 🤔. We should probably use the same format we use in GCk6 for test names

Copy link
Member

Choose a reason for hiding this comment

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

I think format is a 🔥 topic, using US format would add unneeded confusion 🤔

Maybe the ideal is to use the common syntax of YYYY-MM-DD ? What do you think ?

You could argue that the format you are using is more readable, so I'm not completely sure. I would still slightly prefer the format that is readable out of the box for both US & Europe, but maybe we can gather more feedback.

Remembering that this is just the generator file name, I don't think we have a strong need for keeping the format used in test names 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

using US format would add unneeded confusion 🤔

That's fair

Maybe the ideal is to use the common syntax of YYYY-MM-DD ? What do you think ?

I'd rather use a format we use in other parts of k6 offerings, for consistency reasons

Remembering that this is just the generator file name, I don't think we have a strong need for keeping the format used in test names 🤔

As of now, it's not actually a part of the filename, but I did think about adding it to the filename

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Llandy3d I don't have a strong opinion actually, let's discuss it some time next week and pick one format 👍

src/hooks/useWindowTitle.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,53 @@
import { useGeneratorStore, useHasRecording } from '@/hooks/useGeneratorStore'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some unused imports in this file, maybe we could add this plugin to clear imports automatically (we already run eslint --fix on commit)
https://www.npmjs.com/package/eslint-plugin-unused-imports

@going-confetti going-confetti merged commit 575ce8f into main Jul 17, 2024
1 check passed
@going-confetti going-confetti deleted the feat/recording-selector branch July 17, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants