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

Fix mirror actions dropdown #1650

Merged
merged 1 commit into from
Apr 27, 2024
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
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
Loading