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: move recording selector position #413

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 51 additions & 47 deletions src/views/Generator/GeneratorControls/GeneratorControls.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react'
import { DropdownMenu, IconButton } from '@radix-ui/themes'
import { DropdownMenu, Flex, IconButton } from '@radix-ui/themes'

import { useScriptPreview } from '@/hooks/useScriptPreview'
import { exportScript } from '../Generator.utils'
Expand All @@ -11,6 +11,7 @@ import { useNavigate } from 'react-router-dom'
import { getRoutePath } from '@/routeMap'
import { ButtonWithTooltip } from '@/components/ButtonWithTooltip'
import { getFileNameWithoutExtension } from '@/utils/file'
import { RecordingSelector } from '../RecordingSelector'

interface GeneratorControlsProps {
onSave: () => void
Expand Down Expand Up @@ -38,52 +39,55 @@ export function GeneratorControls({ onSave, isDirty }: GeneratorControlsProps) {

return (
<>
<ButtonWithTooltip
onClick={onSave}
disabled={!isDirty}
tooltip={!isDirty ? 'Changes saved' : ''}
>
Save generator
</ButtonWithTooltip>
<DropdownMenu.Root>
<DropdownMenu.Trigger>
<IconButton variant="ghost" color="gray">
<DotsVerticalIcon />
</IconButton>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item
onSelect={() => setIsValidatorDialogOpen(true)}
disabled={!isScriptExportable}
>
Validate script
</DropdownMenu.Item>
<DropdownMenu.Item
onSelect={() => setIsExportScriptDialogOpen(true)}
disabled={!isScriptExportable}
>
Export script
</DropdownMenu.Item>
<DropdownMenu.Separator />
<DropdownMenu.Item onSelect={handleDeleteGenerator} color="red">
Delete generator
</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Root>
{isScriptExportable && (
<>
<ValidatorDialog
script={preview}
open={isValidatorDialogOpen}
onOpenChange={setIsValidatorDialogOpen}
/>
<ExportScriptDialog
onExport={exportScript}
open={isExportScriptDialogOpen}
onOpenChange={setIsExportScriptDialogOpen}
/>
</>
)}
<RecordingSelector />
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the + button might be a bit confusing with this new placement: it's not immediately clear if it's a part of the recording selected, the save generator button, or something else entirely. Perhaps we can add a gap/margin so that the hierarchy is clearer?
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.

I considered using a vertical divider as an alternative, but I kept the extra margin so it's easier to manage in smaller resolutions.

<Flex align="center" justify="between" gap="2" ml="2">
<ButtonWithTooltip
onClick={onSave}
disabled={!isDirty}
tooltip={!isDirty ? 'Changes saved' : ''}
>
Save generator
</ButtonWithTooltip>
<DropdownMenu.Root>
<DropdownMenu.Trigger>
<IconButton variant="ghost" color="gray">
<DotsVerticalIcon />
</IconButton>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item
onSelect={() => setIsValidatorDialogOpen(true)}
disabled={!isScriptExportable}
>
Validate script
</DropdownMenu.Item>
<DropdownMenu.Item
onSelect={() => setIsExportScriptDialogOpen(true)}
disabled={!isScriptExportable}
>
Export script
</DropdownMenu.Item>
<DropdownMenu.Separator />
<DropdownMenu.Item onSelect={handleDeleteGenerator} color="red">
Delete generator
</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Root>
{isScriptExportable && (
<>
<ValidatorDialog
script={preview}
open={isValidatorDialogOpen}
onOpenChange={setIsValidatorDialogOpen}
/>
<ExportScriptDialog
onExport={exportScript}
open={isExportScriptDialogOpen}
onOpenChange={setIsExportScriptDialogOpen}
/>
</>
)}
</Flex>
</>
)
}
7 changes: 1 addition & 6 deletions src/views/Generator/GeneratorSidebar/RequestList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Flex, ScrollArea } from '@radix-ui/themes'
import { Flex, ScrollArea } from '@radix-ui/themes'
import { Allotment } from 'allotment'
import { useState } from 'react'
import { css } from '@emotion/react'
Expand All @@ -9,7 +9,6 @@ import { ProxyData } from '@/types'
import { Details } from '@/components/WebLogView/Details'
import { Filter } from '@/components/WebLogView/Filter'
import { useFilterRequests } from '@/components/WebLogView/Filter.hooks'
import { RecordingSelector } from '../RecordingSelector'
import { useProxyDataGroups } from '@/hooks/useProxyDataGroups'
import { useStudioUIStore } from '@/store/ui'
import { useGeneratorStore } from '@/store/generator'
Expand Down Expand Up @@ -41,9 +40,6 @@ export function RequestList({ requests }: RequestListProps) {

return (
<Flex direction="column" height="100%">
<Box py="2" px="4">
<RecordingSelector />
</Box>
<div
css={css`
flex-grow: 1;
Expand All @@ -66,7 +62,6 @@ export function RequestList({ requests }: RequestListProps) {
borderRadius: 0,
outlineOffset: '-2px',
boxShadow: 'none',
borderTop: '1px solid var(--gray-a5)',
}}
size="2"
/>
Expand Down
5 changes: 4 additions & 1 deletion src/views/Generator/RecordingSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ export function RecordingSelector() {
id="recording-selector"
placeholder="Select recording"
css={css`
width: 250px;
width: 300px;
@media (max-width: 1060px) {
width: 125px;
}
`}
>
<Flex as="span" align="center" gap="1">
Expand Down
Loading