Skip to content

Commit f7124c9

Browse files
authored
Move label constants in to module (#1252)
1 parent c500739 commit f7124c9

File tree

27 files changed

+83
-98
lines changed

27 files changed

+83
-98
lines changed

packages/graph-explorer/src/connector/entities/bundle.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, expect } from "vitest";
22
import { createPatchedResultBundle, getDisplayValueForBundle } from "./bundle";
33
import { createResultScalar } from "./scalar";
4-
import { MISSING_DISPLAY_VALUE, ASCII } from "@/utils/constants";
4+
import { ASCII, LABELS } from "@/utils/constants";
55
import { createTestableEdge, createTestableVertex } from "@/utils/testing";
66

77
describe("getDisplayValueForBundle", () => {
@@ -47,7 +47,7 @@ describe("getDisplayValueForBundle", () => {
4747
const result = getDisplayValueForBundle(bundle);
4848

4949
expect(result).toBe(
50-
`EmptyField: ${MISSING_DISPLAY_VALUE}${ASCII.NBSP}${MISSING_DISPLAY_VALUE}`
50+
`EmptyField: ${LABELS.MISSING_VALUE}${ASCII.NBSP}${LABELS.MISSING_VALUE}`
5151
);
5252
});
5353

@@ -276,7 +276,7 @@ describe("getDisplayValueForBundle", () => {
276276
const result = getDisplayValueForBundle(bundle, upperCaseTransformer);
277277

278278
expect(result).toBe(
279-
`EMPTY_FIELD: ${MISSING_DISPLAY_VALUE}${ASCII.NBSP}${MISSING_DISPLAY_VALUE}`
279+
`EMPTY_FIELD: ${LABELS.MISSING_VALUE}${ASCII.NBSP}${LABELS.MISSING_VALUE}`
280280
);
281281
});
282282

packages/graph-explorer/src/connector/entities/scalar.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
getDisplayValueForScalar,
1010
ResultScalar,
1111
} from "./scalar";
12-
import { MISSING_DISPLAY_VALUE } from "@/utils";
12+
import { LABELS } from "@/utils";
1313

1414
describe("scalar", () => {
1515
describe("createScalar", () => {
@@ -150,7 +150,7 @@ describe("scalar", () => {
150150
describe("getDisplayValueForScalar", () => {
151151
it("should return null for null scalar", () => {
152152
const result = getDisplayValueForScalar(null);
153-
expect(result).toBe(MISSING_DISPLAY_VALUE);
153+
expect(result).toBe(LABELS.MISSING_VALUE);
154154
});
155155

156156
it("should return string for string scalar", () => {

packages/graph-explorer/src/connector/entities/scalar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatDate, MISSING_DISPLAY_VALUE } from "@/utils";
1+
import { formatDate, LABELS } from "@/utils";
22

33
/**
44
* Represents a scalar value that can be returned from a graph database query.
@@ -101,6 +101,6 @@ export function getDisplayValueForScalar(value: ScalarValue) {
101101
case "date":
102102
return formatDate(typedValue.value);
103103
case "null":
104-
return MISSING_DISPLAY_VALUE;
104+
return LABELS.MISSING_VALUE;
105105
}
106106
}

packages/graph-explorer/src/core/AppErrorPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Paragraph,
88
ResetIcon,
99
} from "@/components";
10-
import { APP_NAME, RELOAD_URL } from "@/utils/constants";
10+
import { LABELS, RELOAD_URL } from "@/utils/constants";
1111

1212
/** This is the app wide error page that will be shown when the app essentially crashes */
1313
export default function AppErrorPage(props: FallbackProps) {
@@ -25,7 +25,7 @@ export default function AppErrorPage(props: FallbackProps) {
2525
{/* Force a full reload of the app in the browser */}
2626
<a href={RELOAD_URL}>
2727
<Button variant="filled" size="large" icon={<ResetIcon />}>
28-
Reload {APP_NAME}
28+
Reload {LABELS.APP_NAME}
2929
</Button>
3030
</a>
3131
</div>

packages/graph-explorer/src/core/StateProvider/displayAttribute.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
createRandomInteger,
1313
createRandomName,
1414
} from "@shared/utils/testing";
15-
import { formatDate, MISSING_DISPLAY_VALUE } from "@/utils";
15+
import { formatDate, LABELS } from "@/utils";
1616
import { getDisplayValueForScalar } from "@/connector/entities";
1717

1818
describe("mapToDisplayAttribute", () => {
@@ -67,7 +67,7 @@ describe("mapToDisplayAttribute", () => {
6767
expect(displayAttribute).toStrictEqual({
6868
name,
6969
displayLabel: name,
70-
displayValue: MISSING_DISPLAY_VALUE,
70+
displayValue: LABELS.MISSING_VALUE,
7171
});
7272
});
7373

packages/graph-explorer/src/core/StateProvider/displayEdge.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ import {
1414
edgeTypeAttributesSelector,
1515
} from "@/core";
1616
import { textTransformSelector } from "@/hooks";
17-
import {
18-
MISSING_DISPLAY_VALUE,
19-
RESERVED_ID_PROPERTY,
20-
RESERVED_TYPES_PROPERTY,
21-
} from "@/utils";
17+
import { LABELS, RESERVED_ID_PROPERTY, RESERVED_TYPES_PROPERTY } from "@/utils";
2218
import { atom, useAtomValue } from "jotai";
2319
import { atomFamily } from "jotai/utils";
2420

@@ -96,11 +92,11 @@ const displayEdgeSelector = atomFamily((edge: Edge) =>
9692
} else if (name) {
9793
return (
9894
sortedAttributes.find(attr => attr.name === name)?.displayValue ??
99-
MISSING_DISPLAY_VALUE
95+
LABELS.MISSING_VALUE
10096
);
10197
}
10298

103-
return MISSING_DISPLAY_VALUE;
99+
return LABELS.MISSING_VALUE;
104100
}
105101

106102
const displayName = getDisplayAttributeValueByName(

packages/graph-explorer/src/core/StateProvider/displayTypeConfigs.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
mapToDisplayVertexTypeConfig,
1515
} from "./displayTypeConfigs";
1616
import { createRandomName } from "@shared/utils/testing";
17-
import { MISSING_DISPLAY_TYPE } from "@/utils";
17+
import { LABELS } from "@/utils";
1818
import type { TextTransformer } from "@/hooks";
1919

2020
// Simple identity text transformer for testing (non-SPARQL behavior)
@@ -49,7 +49,7 @@ describe("useDisplayVertexTypeConfig", () => {
4949
useDisplayVertexTypeConfig("")
5050
);
5151

52-
expect(result.current.displayLabel).toBe(MISSING_DISPLAY_TYPE);
52+
expect(result.current.displayLabel).toBe(LABELS.MISSING_TYPE);
5353
});
5454

5555
it("should ignore display label from schema", () => {
@@ -346,7 +346,7 @@ describe("useDisplayEdgeTypeConfig", () => {
346346
it("should use empty label constant when the type is empty", () => {
347347
const { result } = renderHookWithState(() => useDisplayEdgeTypeConfig(""));
348348

349-
expect(result.current.displayLabel).toBe(MISSING_DISPLAY_TYPE);
349+
expect(result.current.displayLabel).toBe(LABELS.MISSING_TYPE);
350350
});
351351

352352
it("should ignore display label from the config", () => {

packages/graph-explorer/src/core/StateProvider/displayTypeConfigs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
LineStyle,
1313
} from "@/core";
1414
import { TextTransformer, textTransformSelector } from "@/hooks";
15-
import { MISSING_DISPLAY_TYPE, RESERVED_TYPES_PROPERTY } from "@/utils";
15+
import { LABELS, RESERVED_TYPES_PROPERTY } from "@/utils";
1616
import { atomFamily, useAtomCallback } from "jotai/utils";
1717
import { atom, useAtomValue } from "jotai";
1818
import { useCallback } from "react";
@@ -133,7 +133,7 @@ export function mapToDisplayVertexTypeConfig(
133133
const displayLabel =
134134
typeConfig.displayLabel ||
135135
textTransform(typeConfig.type) ||
136-
MISSING_DISPLAY_TYPE;
136+
LABELS.MISSING_TYPE;
137137

138138
const attributes: DisplayConfigAttribute[] = typeConfig.attributes
139139
.map(attr => ({
@@ -170,7 +170,7 @@ export function mapToDisplayEdgeTypeConfig(
170170
const displayLabel =
171171
typeConfig.displayLabel ||
172172
textTransform(typeConfig.type) ||
173-
MISSING_DISPLAY_TYPE;
173+
LABELS.MISSING_TYPE;
174174

175175
const attributes: DisplayConfigAttribute[] = typeConfig.attributes
176176
.map(attr => ({

packages/graph-explorer/src/core/StateProvider/displayVertex.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
patchToRemoveDisplayLabel,
2727
} from "./configuration";
2828
import { createRandomDate, createRandomName } from "@shared/utils/testing";
29-
import { MISSING_DISPLAY_VALUE } from "@/utils/constants";
29+
import { LABELS } from "@/utils/constants";
3030
import { mapToDisplayVertexTypeConfig } from "./displayTypeConfigs";
3131
import { QueryEngine } from "@shared/types";
3232
import { getDisplayValueForScalar } from "@/connector/entities";
@@ -203,7 +203,7 @@ describe("useDisplayVertexFromVertex", () => {
203203
<DisplayAttribute>{
204204
name: attr.name,
205205
displayLabel: attr.name,
206-
displayValue: MISSING_DISPLAY_VALUE,
206+
displayValue: LABELS.MISSING_VALUE,
207207
}
208208
)
209209
.toSorted((a, b) => a.displayLabel.localeCompare(b.displayLabel));

packages/graph-explorer/src/core/StateProvider/displayVertex.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ import {
1414
useVertex,
1515
} from "@/core";
1616
import { textTransformSelector } from "@/hooks";
17-
import {
18-
MISSING_DISPLAY_VALUE,
19-
RESERVED_ID_PROPERTY,
20-
RESERVED_TYPES_PROPERTY,
21-
} from "@/utils";
17+
import { LABELS, RESERVED_ID_PROPERTY, RESERVED_TYPES_PROPERTY } from "@/utils";
2218
import { atom, useAtomValue } from "jotai";
2319
import { atomFamily } from "jotai/utils";
2420

@@ -109,11 +105,11 @@ const displayVertexSelector = atomFamily((vertex: Vertex) =>
109105
} else if (name) {
110106
return (
111107
sortedAttributes.find(attr => attr.name === name)?.displayValue ??
112-
MISSING_DISPLAY_VALUE
108+
LABELS.MISSING_VALUE
113109
);
114110
}
115111

116-
return MISSING_DISPLAY_VALUE;
112+
return LABELS.MISSING_VALUE;
117113
}
118114

119115
const displayName = getDisplayAttributeValueByName(

0 commit comments

Comments
 (0)