From 5f0ad208c698dcaf254b1e21482099a1064b35d5 Mon Sep 17 00:00:00 2001 From: Kris McGinnes Date: Wed, 4 Dec 2024 16:48:39 -0600 Subject: [PATCH] =?UTF-8?q?Use=20constant=20for=20=E2=80=9Ctypes=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/core/StateProvider/configuration.ts | 7 +++++-- .../src/core/StateProvider/displayVertex.ts | 8 ++++++-- packages/graph-explorer/src/utils/constants.ts | 3 +++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/graph-explorer/src/core/StateProvider/configuration.ts b/packages/graph-explorer/src/core/StateProvider/configuration.ts index 3ed73ba37..3b3c357c5 100644 --- a/packages/graph-explorer/src/core/StateProvider/configuration.ts +++ b/packages/graph-explorer/src/core/StateProvider/configuration.ts @@ -17,7 +17,10 @@ import { VertexPreferences, } from "./userPreferences"; import isDefaultValue from "./isDefaultValue"; -import { RESERVED_ID_PROPERTY } from "@/utils/constants"; +import { + RESERVED_ID_PROPERTY, + RESERVED_TYPES_PROPERTY, +} from "@/utils/constants"; export const isStoreLoadedAtom = atom({ key: "store-loaded", @@ -243,7 +246,7 @@ export const edgeTypesSelector = selector({ export const defaultVertexTypeConfig = { attributes: [], displayNameAttribute: RESERVED_ID_PROPERTY, - longDisplayNameAttribute: "types", + longDisplayNameAttribute: RESERVED_TYPES_PROPERTY, color: "#128EE5", iconUrl: DEFAULT_ICON_URL, iconImageType: "image/svg+xml", diff --git a/packages/graph-explorer/src/core/StateProvider/displayVertex.ts b/packages/graph-explorer/src/core/StateProvider/displayVertex.ts index e01d853f4..3bb085e33 100644 --- a/packages/graph-explorer/src/core/StateProvider/displayVertex.ts +++ b/packages/graph-explorer/src/core/StateProvider/displayVertex.ts @@ -11,7 +11,11 @@ import { DisplayVertexTypeConfig, displayVertexTypeConfigSelector, } from "./displayTypeConfigs"; -import { MISSING_DISPLAY_VALUE, RESERVED_ID_PROPERTY } from "@/utils/constants"; +import { + MISSING_DISPLAY_VALUE, + RESERVED_ID_PROPERTY, + RESERVED_TYPES_PROPERTY, +} from "@/utils/constants"; import { queryEngineSelector } from "../connector"; /** Represents a vertex's display information after all transformations have been applied. */ @@ -97,7 +101,7 @@ const displayVertexSelector = selectorFamily({ function getDisplayAttributeValueByName(name: string | undefined) { if (name === RESERVED_ID_PROPERTY) { return displayId; - } else if (name === "types") { + } else if (name === RESERVED_TYPES_PROPERTY) { return displayTypes; } else if (name) { return ( diff --git a/packages/graph-explorer/src/utils/constants.ts b/packages/graph-explorer/src/utils/constants.ts index 70ff656ec..6b262a085 100644 --- a/packages/graph-explorer/src/utils/constants.ts +++ b/packages/graph-explorer/src/utils/constants.ts @@ -6,6 +6,9 @@ export const DEFAULT_CONCURRENT_REQUESTS_LIMIT = 10; /** The name of the special property representing the node ID */ export const RESERVED_ID_PROPERTY = "~id"; +/** The name of the property representing the list of types of the node */ +export const RESERVED_TYPES_PROPERTY = "types"; + /** The string "Graph Explorer". */ export const APP_NAME = "Graph Explorer";