Skip to content

Commit ae885e4

Browse files
committed
Inline the tab group with the copy/clear buttons
1 parent 8b47126 commit ae885e4

File tree

2 files changed

+37
-41
lines changed
  • apps/webapp/app
    • components/code
    • routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.test.tasks.$taskParam

2 files changed

+37
-41
lines changed

apps/webapp/app/components/code/JSONEditor.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface JSONEditorProps extends Omit<ReactCodeMirrorProps, "onBlur"> {
2121
showClearButton?: boolean;
2222
linterEnabled?: boolean;
2323
allowEmpty?: boolean;
24+
additionalActions?: React.ReactNode;
2425
}
2526

2627
const languages = {
@@ -64,6 +65,7 @@ export function JSONEditor(opts: JSONEditorProps) {
6465
showClearButton = true,
6566
linterEnabled,
6667
allowEmpty,
68+
additionalActions,
6769
} = {
6870
...defaultProps,
6971
...opts,
@@ -152,6 +154,7 @@ export function JSONEditor(opts: JSONEditorProps) {
152154
>
153155
{showButtons && (
154156
<div className="mx-3 flex items-center justify-end gap-2 border-b border-grid-dimmed">
157+
{additionalActions && additionalActions}
155158
{showClearButton && (
156159
<Button
157160
type="button"

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.test.tasks.$taskParam/route.tsx

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -366,54 +366,47 @@ function StandardTaskForm({
366366
<ResizablePanelGroup orientation="horizontal" className="grow">
367367
<ResizablePanel id="test-task-main" min="300px">
368368
<div className="flex h-full flex-col overflow-hidden bg-charcoal-900">
369-
<TabContainer className="flex items-baseline justify-between pl-3 pr-2 pt-1.5">
370-
<div className="flex gap-5">
371-
<TabButton
372-
isActive={!tab || tab === "payload"}
373-
layoutId="test-editor"
374-
onClick={() => {
375-
replace({ tab: "payload" });
376-
}}
377-
>
378-
Payload
379-
</TabButton>
380-
381-
<TabButton
382-
isActive={tab === "metadata"}
383-
layoutId="test-editor"
384-
onClick={() => {
385-
replace({ tab: "metadata" });
386-
}}
387-
>
388-
Metadata
389-
</TabButton>
390-
</div>
391-
</TabContainer>
392369
<div className="flex-1 overflow-hidden">
393370
<JSONEditor
394-
defaultValue={defaultPayloadJson}
371+
defaultValue={!tab || tab === "payload" ? defaultPayloadJson : defaultMetadataJson}
395372
readOnly={false}
396373
basicSetup
397374
onChange={(v) => {
398-
currentPayloadJson.current = v;
399-
setDefaultPayloadJson(v);
400-
}}
401-
height="100%"
402-
autoFocus={!tab || tab === "payload"}
403-
className={cn("h-full overflow-auto", tab === "metadata" && "hidden")}
404-
/>
405-
<JSONEditor
406-
defaultValue={defaultMetadataJson}
407-
readOnly={false}
408-
basicSetup
409-
onChange={(v) => {
410-
currentMetadataJson.current = v;
411-
setDefaultMetadataJson(v);
375+
if (!tab || tab === "payload") {
376+
currentPayloadJson.current = v;
377+
setDefaultPayloadJson(v);
378+
} else {
379+
currentMetadataJson.current = v;
380+
setDefaultMetadataJson(v);
381+
}
412382
}}
413383
height="100%"
414-
autoFocus={tab === "metadata"}
415-
placeholder=""
416-
className={cn("h-full overflow-auto", tab !== "metadata" && "hidden")}
384+
autoFocus={true}
385+
className={cn("h-full overflow-auto")}
386+
additionalActions={
387+
<TabContainer className="flex grow items-baseline justify-between self-end border-none">
388+
<div className="flex gap-5">
389+
<TabButton
390+
isActive={!tab || tab === "payload"}
391+
layoutId="test-editor"
392+
onClick={() => {
393+
replace({ tab: "payload" });
394+
}}
395+
>
396+
Payload
397+
</TabButton>
398+
<TabButton
399+
isActive={tab === "metadata"}
400+
layoutId="test-editor"
401+
onClick={() => {
402+
replace({ tab: "metadata" });
403+
}}
404+
>
405+
Metadata
406+
</TabButton>
407+
</div>
408+
</TabContainer>
409+
}
417410
/>
418411
</div>
419412
</div>

0 commit comments

Comments
 (0)