-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
going-confetti
commented
Jul 16, 2024
•
edited
Loading
edited
![image](https://private-user-images.githubusercontent.com/3773351/349090485-d6017480-d675-4759-9542-e604d17ee8a2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2OTM2MjEsIm5iZiI6MTczOTY5MzMyMSwicGF0aCI6Ii8zNzczMzUxLzM0OTA5MDQ4NS1kNjAxNzQ4MC1kNjc1LTQ3NTktOTU0Mi1lNjA0ZDE3ZWU4YTIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTZUMDgwODQxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzNhNDM0MTRmMTAyODM4ZDZmMmM2NzI4YWU3ZDQxYjczM2U0NmU4ZjViNmMzNmM3MjkxYTdlNGJhZTdjMGE5ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.7409zhh-bSfPZrxJcTG7uybdjcnzPubinqqlKAR0YQQ)
export function useHasRecording() { | ||
return useGeneratorStore((state) => state.requests.length > 0) | ||
} |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
{requests.length > 0 && ( | ||
<Button onClick={() => setShowAllowListDialog(true)}> | ||
Allowed hosts [{allowList.length}/{hosts.length}] | ||
</Button> | ||
)} |
There was a problem hiding this comment.
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
<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>} |
There was a problem hiding this comment.
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
@@ -64,7 +51,7 @@ export function Generator() { | |||
</Allotment.Pane> | |||
</Allotment> | |||
</Allotment.Pane> | |||
<Allotment.Pane minSize={300}> | |||
<Allotment.Pane minSize={300} visible={hasRecording}> |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
export function useHasRecording() { | ||
return useGeneratorStore((state) => state.requests.length > 0) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -58,3 +59,8 @@ export const useGeneratorStore = create<GeneratorState>()( | |||
}), | |||
})) | |||
) | |||
|
|||
function generateNewName() { | |||
const date = new Date().toISOString().split('T')[0] |
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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 👀
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 👍
@@ -0,0 +1,53 @@ | |||
import { useGeneratorStore, useHasRecording } from '@/hooks/useGeneratorStore' |
There was a problem hiding this comment.
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