Skip to content

Commit 96169dc

Browse files
authored
ENG-1504 - Fix relation migration dialog logic, css, and remove unused vars (#852)
* Refactor HomePersonalSettings component to streamline migration flow and improve UI responsiveness. Adjusted dialog structure and button actions for better user experience during relation migration. Removed unused imports from migrateRelations utility. * format
1 parent 70f659e commit 96169dc

2 files changed

Lines changed: 45 additions & 51 deletions

File tree

apps/roam/src/components/settings/HomePersonalSettings.tsx

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,11 @@ const HomePersonalSettings = ({ onloadArgs }: { onloadArgs: OnloadArgs }) => {
293293
}}
294294
style={{ width: "600px" }}
295295
>
296-
{isOngoing ? (
297-
<div className={Classes.DIALOG_BODY}>
296+
<div className={Classes.DIALOG_BODY}>
297+
{isOngoing ? (
298298
<p>Migrating relations, please wait</p>
299-
</div>
300-
) : (
301-
<>
302-
<div className={Classes.DIALOG_BODY}>
299+
) : (
300+
<>
303301
<p>
304302
Activating the faster relations system will migrate all
305303
previously created relations and newly created relations will
@@ -308,58 +306,56 @@ const HomePersonalSettings = ({ onloadArgs }: { onloadArgs: OnloadArgs }) => {
308306
deleted; however, they will not be accessible until you
309307
reactivate the faster relation system.
310308
</p>
311-
{activeRelationMigration === RelationMigrationDialog.activate ? (
312-
<div className="flex justify-center">
313-
<div className="mt-1 inline-block align-middle">
314-
<Label className="!my-0 pr-2">Relations</Label>
315-
</div>
316-
<pre className="m-0 p-1.5 pt-2">{numExistingRelations}</pre>
309+
{activeRelationMigration ===
310+
RelationMigrationDialog.reactivate ? (
311+
<div className="flex flex-col items-center">
312+
<Label className="font-semibold">Relations</Label>
313+
<pre className="m-0 rounded border border-gray-300 bg-gray-50 p-2 text-center">
314+
{numExistingRelations}
315+
</pre>
317316
</div>
318-
) : (
319-
""
320-
)}
321-
</div>
322-
<div className={Classes.DIALOG_FOOTER}>
323-
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
324-
<Button
325-
small
326-
onClick={() => {
327-
setActiveRelationMigration(RelationMigrationDialog.none);
328-
}}
329-
>
330-
Cancel
331-
</Button>
332-
{activeRelationMigration ===
333-
RelationMigrationDialog.reactivate ? (
334-
<Button
335-
small
336-
intent={Intent.PRIMARY}
337-
onClick={() => {
338-
setStoredRelations(true);
339-
setActiveRelationMigration(RelationMigrationDialog.none);
340-
}}
341-
>
342-
Reactivate without Migration
343-
</Button>
344-
) : (
345-
""
346-
)}
317+
) : null}
318+
</>
319+
)}
320+
</div>
321+
{!isOngoing && (
322+
<div className={Classes.DIALOG_FOOTER}>
323+
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
324+
<Button
325+
small
326+
onClick={() => {
327+
setActiveRelationMigration(RelationMigrationDialog.none);
328+
}}
329+
>
330+
Cancel
331+
</Button>
332+
{activeRelationMigration ===
333+
RelationMigrationDialog.reactivate ? (
347334
<Button
348335
small
349336
intent={Intent.PRIMARY}
350337
onClick={() => {
351-
setIsOngoing(true);
352-
void startMigration();
338+
setStoredRelations(true);
339+
setActiveRelationMigration(RelationMigrationDialog.none);
353340
}}
354341
>
355-
{activeRelationMigration ===
356-
RelationMigrationDialog.reactivate
357-
? "Migrate again and Reactivate"
358-
: "Activate and Migrate"}
342+
Reactivate without Migration
359343
</Button>
360-
</div>
344+
) : null}
345+
<Button
346+
small
347+
intent={Intent.PRIMARY}
348+
onClick={() => {
349+
setIsOngoing(true);
350+
void startMigration();
351+
}}
352+
>
353+
{activeRelationMigration === RelationMigrationDialog.reactivate
354+
? "Migrate again and Reactivate"
355+
: "Activate and Migrate"}
356+
</Button>
361357
</div>
362-
</>
358+
</div>
363359
)}
364360
</Dialog>
365361
<Dialog

apps/roam/src/utils/migrateRelations.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import getRelationData from "./getRelationData";
22
import getBlockProps from "./getBlockProps";
33
import type { json } from "./getBlockProps";
44
import setBlockProps from "./setBlockProps";
5-
import { getSetting, setSetting } from "./extensionSettings";
6-
import { USE_REIFIED_RELATIONS } from "~/data/userSettings";
75
import internalError from "./internalError";
86
import {
97
createReifiedRelation,

0 commit comments

Comments
 (0)