Skip to content

Commit 7efff58

Browse files
committed
chore: Consistently refer to this as New Table
https://harperdb.atlassian.net/browse/STUDIO-463
1 parent 0cdb833 commit 7efff58

File tree

6 files changed

+41
-16
lines changed

6 files changed

+41
-16
lines changed

src/features/instance/applications/components/AddSchemaForm/index.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const addSchema = z.object({
3737
});
3838

3939
export function AddSchemaForm() {
40-
const closeModal = useSetWatchedValue('ShowAddSchemaModal', false);
40+
const closeModal = useSetWatchedValue('ShowNewTableModal', false);
4141
const { openedEntry, openedEntryContents } = useEditorView();
4242
const { setContent } = useEditorFileContent(!!openedEntry && !openedEntry.package && openedEntry.path);
4343

@@ -317,6 +317,19 @@ type ${formData.tableName} @table${formData.replicate ? '' : '(replicate: false)
317317
<Plus /> Add Another Field
318318
</Button>
319319

320+
<div className="text-muted-foreground italic text-sm pb-2">
321+
There are even more directives available to you when editing your schema.graphql by hand! You can read more
322+
about them{' '}
323+
<a
324+
className="underline"
325+
target="_blank"
326+
rel="noreferrer"
327+
href="https://docs.harperdb.io/docs/developers/applications/defining-schemas"
328+
>
329+
in our documentation
330+
</a>.
331+
</div>
332+
320333
<div className="flex w-full gap-4">
321334
<Button variant="ghost" className="w-full rounded-full" onClick={closeModal}>
322335
<Ban /> Cancel
@@ -327,7 +340,7 @@ type ${formData.tableName} @table${formData.replicate ? '' : '(replicate: false)
327340
className="w-full rounded-full"
328341
disabled={!formState.isValid}
329342
>
330-
<PlusIcon /> Add Schema
343+
<PlusIcon /> New Table
331344
</Button>
332345
</div>
333346
</form>

src/features/instance/applications/components/ContentActions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function ContentActions({
4747
const onRedeployClick = useSetWatchedValue('ShowRedeployApplicationModal', true);
4848
const onSaveClick = useEmitToListeners('SaveFile', true);
4949
const onRevertChangesClicked = useEmitToListeners('RevertChanges', true);
50-
const onAddSchemaClick = useEmitToListeners('ShowAddSchemaModal', true);
50+
const onNewTableClick = useEmitToListeners('ShowNewTableModal', true);
5151

5252
const fileIsClean = updatedFileContent === undefined || updatedFileContent === openedEntryContents;
5353

@@ -148,7 +148,7 @@ export function ContentActions({
148148
)}
149149

150150
{openedEntry.path.endsWith('.graphql') && canManageBrowseInstance && (
151-
<Button variant="ghost" className="rounded-none" onClick={onAddSchemaClick} title="New Table">
151+
<Button variant="ghost" className="rounded-none" onClick={onNewTableClick} title="New Table">
152152
<PlusIcon className="pointer-events-none" />
153153
<span className="hidden lg:inline-block pointer-events-none">
154154
<span className="hidden xl:inline-block">New</span> Table

src/features/instance/applications/context/EditorViewProvider.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
useSetComponentFile,
2222
} from '@/integrations/api/instance/applications/setComponentFile';
2323
import { transformNodes } from '@/lib/arrays/transformNodes';
24+
import { setWatchedValue } from '@/lib/events/watcher';
2425
import { useQuery, useQueryClient, useSuspenseQuery } from '@tanstack/react-query';
2526
import { useNavigate, useSearch } from '@tanstack/react-router';
2627
import { PropsWithChildren, useCallback, useEffect, useMemo, useState } from 'react';
@@ -113,18 +114,29 @@ export function EditorViewProvider({ children }: PropsWithChildren) {
113114
*/
114115
useEffect(() => {
115116
if (open?.length) {
116-
const parts = open.split('/');
117+
// ./schema.graphql?ShowNewTableModal=true
118+
const openParts = open.split('?');
119+
const ref = openParts[0];
120+
const action = openParts[1];
121+
const refParts = ref.split('/');
117122

123+
if (action) {
124+
const actionParts = action.split('=');
125+
setWatchedValue(
126+
actionParts[0] as any,
127+
actionParts[1] === 'true' ? true : actionParts[1] === 'false' ? false : actionParts[1],
128+
);
129+
}
118130
setExpandedItems(expandedItems => {
119131
const expansion = new Set(expandedItems);
120-
for (let i = 1; i < parts.length; i++) {
121-
expansion.add(parts.slice(0, i).join('/'));
132+
for (let i = 1; i < refParts.length; i++) {
133+
expansion.add(refParts.slice(0, i).join('/'));
122134
}
123135
return [...expansion];
124136
});
125137

126-
setSelectedItems([open]);
127-
setFocusedItem(open);
138+
setSelectedItems([ref]);
139+
setFocusedItem(ref);
128140

129141
void navigate({ search: undefined });
130142
}

src/features/instance/applications/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { AddSchemaModal } from '@/features/instance/applications/modals/AddSchemaModal';
21
import { useSessionToggler } from '@/hooks/useSessionToggler';
32
import { cx } from 'class-variance-authority';
43
import { ApplicationsSidebar } from './components/ApplicationsSidebar';
@@ -8,6 +7,7 @@ import { EditorViewProvider } from './context/EditorViewProvider';
87
import { AddDirectoryOrFileModal } from './modals/AddDirectoryOrFileModal';
98
import { DeleteDirectoryOrFileModal } from './modals/DeleteDirectoryOrFileModal';
109
import { DownloadApplicationModal } from './modals/DownloadApplicationModal';
10+
import { NewTableModal } from './modals/NewTableModal';
1111
import { RedeployApplicationModal } from './modals/RedeployApplicationModal';
1212
import { RenameFileModal } from './modals/RenameFileModal';
1313

@@ -44,7 +44,7 @@ export function ApplicationsEditor() {
4444
</div>
4545

4646
<AddDirectoryOrFileModal />
47-
<AddSchemaModal />
47+
<NewTableModal />
4848
<DeleteDirectoryOrFileModal />
4949
<DownloadApplicationModal />
5050
<RedeployApplicationModal />

src/features/instance/applications/modals/AddSchemaModal.tsx renamed to src/features/instance/applications/modals/NewTableModal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import { attemptToRestoreFocus } from '@/lib/attemptToRestoreFocus';
44
import { setWatchedValue, useWatchedValue } from '@/lib/events/watcher';
55
import { useCallback } from 'react';
66

7-
export function AddSchemaModal() {
8-
const { value: isModalOpen, trigger } = useWatchedValue('ShowAddSchemaModal', false);
7+
export function NewTableModal() {
8+
const { value: isModalOpen, trigger } = useWatchedValue('ShowNewTableModal', false);
99

1010
const closeModal = useCallback(() => {
11-
setWatchedValue('ShowAddSchemaModal', false);
11+
setWatchedValue('ShowNewTableModal', false);
1212
attemptToRestoreFocus(trigger);
1313
}, [trigger]);
1414

1515
return (
1616
<Dialog onOpenChange={closeModal} open={isModalOpen}>
1717
<DialogContent aria-describedby={undefined} className="text-white">
1818
<DialogHeader>
19-
<DialogTitle>Add Schema</DialogTitle>
19+
<DialogTitle>New Table</DialogTitle>
2020
<DialogDescription>
2121
Creating a table is the basis of a data-driven application and can immediately be used as RESTful endpoints.
2222
This can also be configured as a caching table and extended and customized for specific endpoint behavior.

src/lib/storage/watchedValueKeys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export interface WatchedValuesTypeMap {
22
RevertChanges: true;
33
SaveFile: true;
44
ShowAddDirectoryOrFileModalType: 'file' | 'directory' | false;
5-
ShowAddSchemaModal: boolean;
5+
ShowNewTableModal: boolean;
66
ShowDeleteDirectoryOrFileModal: boolean;
77
ShowDownloadApplicationModal: boolean;
88
ShowRedeployApplicationModal: boolean;

0 commit comments

Comments
 (0)