Skip to content

Commit

Permalink
Use constant for “types”
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcginnes committed Dec 4, 2024
1 parent 0698768 commit 0c94baf
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>({
key: "store-loaded",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import useTranslations from "@/hooks/useTranslations";
import NeighborsList from "@/modules/common/NeighborsList/NeighborsList";
import EntityAttribute from "./EntityAttribute";
import defaultStyles from "./EntityDetail.styles";
import { RESERVED_ID_PROPERTY } from "@/utils/constants";
import {
RESERVED_ID_PROPERTY,
RESERVED_TYPES_PROPERTY,
} from "@/utils/constants";
import { VertexRow } from "@/components";

export type VertexDetailProps = {
Expand Down Expand Up @@ -32,7 +35,7 @@ export default function NodeDetail({ node }: VertexDetailProps) {
/>
<EntityAttribute
attribute={{
name: "types",
name: RESERVED_TYPES_PROPERTY,
displayLabel: t("node-detail.node-type"),
displayValue: node.displayTypes,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import modalDefaultStyles from "./SingleNodeStylingModal.style";
import { useVertexTypeConfig } from "@/core/ConfigurationProvider/useConfiguration";
import { useDebounceValue, usePrevious } from "@/hooks";
import { cn } from "@/utils";
import { RESERVED_ID_PROPERTY } from "@/utils/constants";
import {
RESERVED_ID_PROPERTY,
RESERVED_TYPES_PROPERTY,
} from "@/utils/constants";

export type SingleNodeStylingProps = {
vertexType: string;
Expand Down Expand Up @@ -73,7 +76,7 @@ export default function SingleNodeStyling({

options.unshift({
label: t("nodes-styling.node-type"),
value: "types",
value: RESERVED_TYPES_PROPERTY,
});
options.unshift({
label: t("nodes-styling.node-id"),
Expand Down
3 changes: 3 additions & 0 deletions packages/graph-explorer/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
APP_NAME,
MISSING_DISPLAY_VALUE,
RESERVED_ID_PROPERTY,
RESERVED_TYPES_PROPERTY,
} from "@/utils/constants";

export type ConnectionsProps = {
Expand Down Expand Up @@ -202,7 +203,7 @@ function DisplayNameAndDescriptionOptions({

options.unshift({
label: t("data-explorer.node-type"),
value: "types",
value: RESERVED_TYPES_PROPERTY,
});
options.unshift({
label: t("data-explorer.node-id"),
Expand Down

0 comments on commit 0c94baf

Please sign in to comment.