mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-11-30 01:00:27 +03:00
fix(core): restore sync progress tooltip and remove nested hover (#15971)
Use Tooltip for non-diagnostic sync status in WorkspaceCard so hover shows sync progress and clicks still open the workspace selector. Pass withoutHover and tooltip to the diagnostic status Button to prevent double hover backgrounds. Co-authored-by: DarkSky <darksky2048@gmail.com>
This commit is contained in:
1 parent
b0fe3c351d
commit
adefb43588
3 files changed
+80
-29
No files matched your search
+36
@@ -98,6 +98,7 @@ test.each([undefined, 'server-revision'])(
|
||||
try {
|
||||
expect(await screen.findByText('Upload paused')).toBeTruthy();
|
||||
const status = screen.getByRole('button', { name: 'Sync status' });
|
||||
expect(Object.hasOwn(status.dataset, 'noHover')).toBe(true);
|
||||
status.focus();
|
||||
expect(document.activeElement).toBe(status);
|
||||
fireEvent.click(status);
|
||||
@@ -129,3 +130,38 @@ test.each([undefined, 'server-revision'])(
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
test('syncing status shows progress tooltip without nested hover button', async () => {
|
||||
const onCardClick = vi.fn();
|
||||
mocks.workspace = {
|
||||
id: 'workspace-syncing',
|
||||
flavour: 'affine-cloud',
|
||||
engine: {
|
||||
doc: {
|
||||
state$: new BehaviorSubject({
|
||||
total: 10,
|
||||
syncing: 4,
|
||||
synced: false,
|
||||
syncRetrying: false,
|
||||
syncErrorMessage: null,
|
||||
}),
|
||||
},
|
||||
},
|
||||
};
|
||||
const view = render(
|
||||
<WorkspaceCard
|
||||
workspaceMetadata={{ id: 'workspace-syncing', flavour: 'affine-cloud' }}
|
||||
showSyncStatus
|
||||
onClick={onCardClick}
|
||||
/>
|
||||
);
|
||||
try {
|
||||
const syncing = await screen.findByText('Syncing...');
|
||||
expect(screen.getByText('Syncing with AFFiNE Cloud (60%)')).toBeTruthy();
|
||||
expect(screen.queryByRole('button', { name: 'Sync status' })).toBeNull();
|
||||
fireEvent.click(syncing);
|
||||
expect(onCardClick).toHaveBeenCalledTimes(1);
|
||||
} finally {
|
||||
view.unmount();
|
||||
}
|
||||
});
|
||||
@@ -315,37 +315,49 @@ const WorkspaceSyncInfo = ({
|
||||
{/* when syncing/offline/... */}
|
||||
{syncStatus && (
|
||||
<div className={styles.workspaceInfo} data-type="events">
|
||||
<Popover
|
||||
content={
|
||||
<>
|
||||
<div>{syncStatus.message}</div>
|
||||
{syncStatus.diagnostics && (
|
||||
<>
|
||||
<Button variant="plain" onClick={copyDiagnostics}>
|
||||
Copy diagnostics
|
||||
{syncStatus.diagnostics ? (
|
||||
<Popover
|
||||
content={
|
||||
<>
|
||||
<div>{syncStatus.message}</div>
|
||||
<Button variant="plain" onClick={copyDiagnostics}>
|
||||
Copy diagnostics
|
||||
</Button>
|
||||
{BUILD_CONFIG.isElectron && (
|
||||
<Button variant="plain" onClick={openExport}>
|
||||
Open Quick Export
|
||||
</Button>
|
||||
{BUILD_CONFIG.isElectron && (
|
||||
<Button variant="plain" onClick={openExport}>
|
||||
Open Quick Export
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
contentOptions={{ className: styles.workspaceInfoTooltip }}
|
||||
>
|
||||
<Button
|
||||
variant="plain"
|
||||
size="custom"
|
||||
aria-label="Sync status"
|
||||
className={styles.workspaceActiveStatus}
|
||||
contentClassName={styles.workspaceActiveStatusContent}
|
||||
onClick={event => event.stopPropagation()}
|
||||
)}
|
||||
</>
|
||||
}
|
||||
contentOptions={{ className: styles.workspaceInfoTooltip }}
|
||||
>
|
||||
{syncStatus.icon}
|
||||
</Button>
|
||||
</Popover>
|
||||
<Button
|
||||
variant="plain"
|
||||
size="custom"
|
||||
withoutHover
|
||||
tooltip={syncStatus.message}
|
||||
tooltipOptions={{
|
||||
options: { className: styles.workspaceInfoTooltip },
|
||||
}}
|
||||
aria-label="Sync status"
|
||||
className={styles.workspaceActiveStatus}
|
||||
contentClassName={styles.workspaceActiveStatusContent}
|
||||
onClick={event => event.stopPropagation()}
|
||||
>
|
||||
{syncStatus.icon}
|
||||
</Button>
|
||||
</Popover>
|
||||
) : (
|
||||
<Tooltip
|
||||
content={syncStatus.message}
|
||||
options={{ className: styles.workspaceInfoTooltip }}
|
||||
>
|
||||
<div className={styles.workspaceActiveStatus}>
|
||||
{syncStatus.icon}
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -120,6 +120,9 @@ globalStyle(`.${workspaceStatus} svg`, {
|
||||
});
|
||||
|
||||
export const workspaceActiveStatus = style({
|
||||
display: 'flex',
|
||||
gap: 2,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'flex-start',
|
||||
padding: 0,
|
||||
fontSize: cssVar('fontSm'),
|
||||
|
||||
Reference in new issue
Block a user