Skip to content

Commit

Permalink
fix actions dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Apr 27, 2024
1 parent 3ed8cd5 commit 0cc86d0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 62 deletions.
8 changes: 0 additions & 8 deletions ui/app/mirrors/[mirrorId]/configValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ const MirrorValues = (mirrorConfig: FlowConnectionConfigs | undefined) => {
value: `${mirrorConfig?.softDelete}`,
label: 'Soft Delete',
},
{
value: mirrorConfig?.cdcStagingPath || 'Local',
label: 'CDC Staging Path',
},
{
value: mirrorConfig?.snapshotStagingPath || 'Local',
label: 'Snapshot Staging Path',
},
{
value: mirrorConfig?.script,
label: 'Script',
Expand Down
34 changes: 11 additions & 23 deletions ui/components/EditButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { Button } from '@/lib/Button';
import { Label } from '@/lib/Label';
import { ProgressCircle } from '@/lib/ProgressCircle';
import { Tooltip } from '@/lib/Tooltip';
import { useRouter } from 'next/navigation';
import { useState } from 'react';

Expand All @@ -21,32 +20,21 @@ const EditButton = ({
router.push(toLink);
};
return (
<Tooltip
<Button
onClick={handleEdit}
variant='normalBorderless'
style={{
display: disabled ? 'flex' : 'none',
backgroundColor: 'white',
color: 'black',
display: 'flex',
alignItems: 'flex-start',
justifyContent: 'left',
columnGap: '0.3rem',
width: '100%',
}}
content='Pause the mirror to enable editing'
disabled={disabled}
>
<Button
className='IconButton'
onClick={handleEdit}
aria-label='sort up'
variant='normalBorderless'
style={{
display: 'flex',
alignItems: 'flex-start',
columnGap: '0.3rem',
width: '100%',
}}
disabled={disabled}
>
<Label>Edit mirror</Label>
{loading && <ProgressCircle variant='determinate_progress_circle' />}
</Button>
</Tooltip>
<Label>Edit {disabled ? '(pause first)' : 'mirror'}</Label>
{loading && <ProgressCircle variant='determinate_progress_circle' />}
</Button>
);
};

Expand Down
38 changes: 12 additions & 26 deletions ui/components/MirrorActionsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import EditButton from '@/components/EditButton';
import { ResyncDialog } from '@/components/ResyncDialog';
import { FlowConnectionConfigs, FlowStatus } from '@/grpc_generated/flow';
import { MirrorStatusResponse } from '@/grpc_generated/route';
import { Select, SelectItem } from '@tremor/react';
import { Select } from '@tremor/react';
import { useEffect, useState } from 'react';
import PauseOrResumeButton from './PauseOrResumeButton';

Expand Down Expand Up @@ -36,31 +36,17 @@ const MirrorActions = ({
if (mounted)
return (
<div>
<Select
placeholder='Actions'
value='Actions'
style={{ width: 'fit-content' }}
>
<SelectItem value='1' style={{ padding: 0 }}>
{mirrorStatus && (
<PauseOrResumeButton
mirrorConfig={mirrorConfig}
mirrorStatus={mirrorStatus}
/>
)}
</SelectItem>
<SelectItem value='2' style={{ padding: 0 }}>
<EditButton toLink={editLink} disabled={isNotPaused} />
</SelectItem>

<SelectItem value='3' style={{ padding: 0 }}>
{canResync && (
<ResyncDialog
mirrorConfig={mirrorConfig}
workflowId={workflowId}
/>
)}
</SelectItem>
<Select placeholder='Actions' value='Actions'>
{mirrorStatus && (
<PauseOrResumeButton
mirrorConfig={mirrorConfig}
mirrorStatus={mirrorStatus}
/>
)}
<EditButton toLink={editLink} disabled={isNotPaused} />
{canResync && (
<ResyncDialog mirrorConfig={mirrorConfig} workflowId={workflowId} />
)}
</Select>
</div>
);
Expand Down
6 changes: 2 additions & 4 deletions ui/components/PauseOrResumeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ function PauseOrResumeButton({
if (mirrorStatus.toString() === FlowStatus[FlowStatus.STATUS_RUNNING]) {
return (
<Button
className='IconButton'
aria-label='Pause'
variant='normalBorderless'
style={{ width: '100%', justifyContent: 'left' }}
onClick={() => changeFlowState(mirrorConfig, FlowStatus.STATUS_PAUSED)}
>
<Label>Pause mirror</Label>
Expand All @@ -25,8 +24,7 @@ function PauseOrResumeButton({
} else if (mirrorStatus.toString() === FlowStatus[FlowStatus.STATUS_PAUSED]) {
return (
<Button
className='IconButton'
aria-label='Play'
style={{ width: '100%', justifyContent: 'left' }}
onClick={() => changeFlowState(mirrorConfig, FlowStatus.STATUS_RUNNING)}
>
<Label>Resume mirror</Label>
Expand Down
5 changes: 4 additions & 1 deletion ui/components/ResyncDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export const ResyncDialog = ({
noInteract={true}
size='xLarge'
triggerButton={
<Button variant='normalBorderless' style={{ width: '100%' }}>
<Button
variant='normalBorderless'
style={{ width: '100%', justifyContent: 'left' }}
>
<Label as='label'>Resync mirror</Label>
</Button>
}
Expand Down

0 comments on commit 0cc86d0

Please sign in to comment.