Skip to content

Commit aee5aae

Browse files
authored
Feat/improve schema sync (#901)
* feat: Improve schema synchronization UX * docs: add sync UI improvements to Changelog.md * docs: fix header sync removal description in Changelog.md * fix: update sync button text for different states * fix: change flex to inline-flex * docs:update Changelog for PR #901 * fix: change InfoItemValue class from inline-flex to inline * fix style: use inline
1 parent 778d122 commit aee5aae

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Upcoming
44

5+
### Other changes
6+
7+
- **Improved** Improved connection details by moving the sync button near the
8+
last sync timestamp ([#901](https://github.com/aws/graph-explorer/pull/901))
9+
510
## Release v1.15.0
611

712
Graph Explorer now offers session persistence, allowing you to seamlessly
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { ComponentPropsWithoutRef } from "react";
2+
import { cn } from "../../utils/cn";
3+
4+
export function LinkButton({
5+
className,
6+
...props
7+
}: ComponentPropsWithoutRef<"button">) {
8+
return (
9+
<button
10+
{...props}
11+
className={cn(
12+
className,
13+
"text-primary-main m-0 cursor-pointer border-0 bg-transparent p-0 underline underline-offset-2 hover:no-underline"
14+
)}
15+
/>
16+
);
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from "./Button";
2+
export * from "./LinkButton";

packages/graph-explorer/src/modules/ConnectionDetail/ConnectionDetail.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
TooltipTrigger,
2727
TrayArrowIcon,
2828
} from "@/components";
29+
import { LinkButton } from "@/components/Button";
2930
import {
3031
activeSchemaSelector,
3132
ConfigurationContextProps,
@@ -74,7 +75,7 @@ function ConnectionDetail({ config }: ConnectionDetailProps) {
7475
const t = useTranslations();
7576
const [edit, setEdit] = useState(false);
7677

77-
const { refetch: syncSchema, isFetching: isSync } = useSchemaSync();
78+
const { isFetching: isSync } = useSchemaSync();
7879

7980
const onConfigExport = useCallback(() => {
8081
saveConfigurationToFile(config);
@@ -96,12 +97,6 @@ function ConnectionDetail({ config }: ConnectionDetailProps) {
9697
{config.displayLabel || config.id}
9798
</PanelTitle>
9899
<PanelHeaderActions>
99-
<PanelHeaderActionButton
100-
label="Synchronize Database"
101-
icon={<SyncIcon className={isSync ? "animate-spin" : ""} />}
102-
isDisabled={isSync}
103-
onActionClick={syncSchema}
104-
/>
105100
<PanelHeaderActionButton
106101
label="Export Connection"
107102
icon={<TrayArrowIcon />}
@@ -213,6 +208,7 @@ function MainContentLayout() {
213208

214209
function LastSyncInfo({ config }: { config: ConfigurationContextProps }) {
215210
const isSyncing = useIsSyncing();
211+
const { refetch: syncSchema } = useSchemaSync();
216212

217213
if (isSyncing) {
218214
return (
@@ -225,18 +221,31 @@ function LastSyncInfo({ config }: { config: ConfigurationContextProps }) {
225221

226222
const lastSyncFail = config.schema?.lastSyncFail === true;
227223
if (lastSyncFail) {
228-
return <InfoItemValue>Synchronization Failed</InfoItemValue>;
224+
return (
225+
<InfoItemValue className="inline">
226+
<span>Synchronization Failed</span>
227+
<LinkButton onClick={() => syncSchema()}>Retry</LinkButton>
228+
</InfoItemValue>
229+
);
229230
}
230231

231232
const lastSyncUpdate = config.schema?.lastUpdate;
232233
if (!lastSyncUpdate) {
233-
return <Chip variant="warning">Not Synchronized</Chip>;
234+
return (
235+
<InfoItemValue className="inline">
236+
<Chip variant="warning">Not Synchronized</Chip>
237+
<LinkButton onClick={() => syncSchema()}>Synchronize</LinkButton>
238+
</InfoItemValue>
239+
);
234240
}
235241

236242
return (
237243
<Tooltip>
238244
<TooltipTrigger asChild>
239-
<InfoItemValue>{formatRelativeDate(lastSyncUpdate)}</InfoItemValue>
245+
<InfoItemValue className="inline">
246+
<span>{formatRelativeDate(lastSyncUpdate)}</span>
247+
<LinkButton onClick={() => syncSchema()}>Refresh</LinkButton>
248+
</InfoItemValue>
240249
</TooltipTrigger>
241250
<TooltipContent>{formatDate(lastSyncUpdate)}</TooltipContent>
242251
</Tooltip>

0 commit comments

Comments
 (0)