Skip to content
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
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"svg-icon": "^0.8.2",
"terminate": "^2.6.1",
"ts-node": "^10.9.1",
"typescript": "*"
"typescript": "^5.4.5"
},
"dependencies": {
"@create-figma-plugin/ui": "2.1.5",
Expand Down
11 changes: 6 additions & 5 deletions src/main/endpoints/highlightNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { createEndpoint } from "../utils/createEndpoint";

const HIGHLIGHT_COLOR: SolidPaint = {
type: "SOLID",
color: { r: 1, g: 0.41, b: 0.58 },
};

export type HighlightNodeProps = {
id: string;
};
Expand All @@ -16,13 +21,9 @@ export const highlightNodeEndpoint = createEndpoint(
}

if (node && !highlitedNodes.has(id)) {
const paint: SolidPaint = {
type: "SOLID",
color: { r: 1, g: 0, b: 0 },
};
highlitedNodes.set(id, node.fills);
const original = node.fills;
node.fills = [paint];
node.fills = [HIGHLIGHT_COLOR];

setTimeout(() => {
node.fills = original;
Expand Down
9 changes: 9 additions & 0 deletions src/ui/views/Index/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ export const Index = () => {
const selectionLoadable = useSelectedNodes();
const selection = selectionLoadable.data?.items || [];

// index page is not removed on certain routes
// refetch when we go back to it
const route = useGlobalState((c) => c.route);
useEffect(() => {
if (route[0] === "index") {
selectionLoadable.refetch();
}
}, [route]);

const [error, setError] = useState<string>();

const languagesLoadable = useApiQuery({
Expand Down
16 changes: 12 additions & 4 deletions src/ui/views/Index/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { h } from "preact";
import { useMemo, useState } from "preact/hooks";
import { useEffect, useMemo, useState } from "preact/hooks";
import { NodeInfo } from "@/types";
import { NodeRow } from "@/ui/components/NodeList/NodeRow";
import { KeyInput } from "./KeyInput";
Expand All @@ -20,7 +20,8 @@ type Props = {

export const ListItem = ({ node, loadedNamespaces }: Props) => {
const [keyName, setKeyName] = useState(node.key);
const [namespace, setNamespace] = useState(node.ns);
const defaultNamespace = useGlobalState((c) => c.config?.namespace);
const [namespace, setNamespace] = useState(node.ns ?? defaultNamespace);

const setNodesDataMutation = useSetNodesDataMutation();

Expand All @@ -29,7 +30,6 @@ export const ListItem = ({ node, loadedNamespaces }: Props) => {
const namespacesDisabled = useGlobalState(
(c) => c.config?.namespacesDisabled
);
const defaultNamespace = useGlobalState((c) => c.config?.namespace);

const handleConnect = (node: NodeInfo) => {
setRoute("connect", { node });
Expand All @@ -53,6 +53,14 @@ export const ListItem = ({ node, loadedNamespaces }: Props) => {
});
};

useEffect(() => {
if (keyName && namespace !== node.ns) {
setNodesDataMutation.mutate({
nodes: [{ ...node, key: keyName, ns: namespace }],
});
}
}, [namespace]);

const handleNsChange = (node: NodeInfo) => (value: string) => {
setNamespace(value);
setNodesDataMutation.mutate({
Expand All @@ -73,7 +81,7 @@ export const ListItem = ({ node, loadedNamespaces }: Props) => {
!namespacesDisabled && (
<div className={styles.nsSelect}>
<NamespaceSelect
value={namespace ?? defaultNamespace ?? ""}
value={namespace ?? ""}
namespaces={namespaces}
onChange={handleNsChange(node)}
/>
Expand Down
23 changes: 9 additions & 14 deletions src/ui/views/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,9 @@ import { Dialog } from "../components/Dialog/Dialog";

const getDialogPage = ([routeKey, routeData]: Route) => {
switch (routeKey) {
case "settings":
return <Settings />;

case "push":
return <Push />;

case "pull":
return <Pull {...routeData} />;

case "connect":
return <Connect {...routeData} />;

case "create_copy":
return <CreateCopy />;

default:
return null;
}
Expand All @@ -41,8 +29,15 @@ type PageProps = {
};

const Page = ({ route: [routeKey, routeData], setRoute }: PageProps) => {
if (routeKey === "settings") {
return <Settings />;
switch (routeKey) {
case "settings":
return <Settings />;
case "push":
return <Push />;
case "pull":
return <Pull {...routeData} />;
case "create_copy":
return <CreateCopy />;
}

const dialogPage = getDialogPage([routeKey, routeData] as Route);
Expand Down