Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(plan): move targets edit beside title and use edit icons (BYT-9754) (#20639)

boojack9107d55af904
diff --git a/frontend/src/react/pages/project/plan-detail/components/PlanDetailChangesBranch.tsx b/frontend/src/react/pages/project/plan-detail/components/PlanDetailChangesBranch.tsx
index 1be0ca1056..f5e1a0f6c6 100644
--- a/frontend/src/react/pages/project/plan-detail/components/PlanDetailChangesBranch.tsx
+++ b/frontend/src/react/pages/project/plan-detail/components/PlanDetailChangesBranch.tsx
@@ -6,6 +6,7 @@ import {
ExternalLink,
FolderTree,
Loader2,
+ Pencil,
XCircle,
} from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -1300,21 +1301,25 @@ function TargetsSection({
return (
<>
<div className="flex flex-col gap-y-1">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-1">
- <span className="textlabel uppercase">
- {t("plan.targets.title")}
+ <div className="flex items-center gap-1">
+ <span className="textlabel uppercase">{t("plan.targets.title")}</span>
+ {targets.length > 1 && (
+ <span className="textlabel text-control-light">
+ ({targets.length})
</span>
- {targets.length > 1 && (
- <span className="textlabel text-control-light">
- ({targets.length})
- </span>
- )}
- </div>
+ )}
{allowEdit && (
- <Button onClick={onEdit} size="xs" variant="outline">
- {t("common.edit")}
- </Button>
+ <Tooltip content={t("common.edit")}>
+ <Button
+ aria-label={t("common.edit")}
+ className="text-control-light hover:text-control"
+ onClick={onEdit}
+ size="xs"
+ variant="ghost"
+ >
+ <Pencil className="size-3.5" />
+ </Button>
+ </Tooltip>
)}
</div>
{!isLoadingTargets && nonEnvDatabaseNames.length > 0 && (
diff --git a/frontend/src/react/pages/project/plan-detail/components/PlanDetailStatementSection.tsx b/frontend/src/react/pages/project/plan-detail/components/PlanDetailStatementSection.tsx
index 86ac4f2820..abbe2c8672 100644
--- a/frontend/src/react/pages/project/plan-detail/components/PlanDetailStatementSection.tsx
+++ b/frontend/src/react/pages/project/plan-detail/components/PlanDetailStatementSection.tsx
@@ -1,5 +1,5 @@
import { clone, create } from "@bufbuild/protobuf";
-import { Loader2, Table, Upload } from "lucide-react";
+import { Loader2, Pencil, Table, Upload } from "lucide-react";
import { type ChangeEvent, useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import {
@@ -238,6 +238,11 @@ export function PlanDetailStatementSection({
hasProjectPermissionV2(project, "bb.plans.update"))
);
const canEdit = canModifyStatement && !isSheetOversize && !page.isCreating;
+ // An active edit session (not whole-plan creation) shows Save/Cancel.
+ const isInlineEditing = isEditing && !page.isCreating;
+ // Hide Upload/Schema editor only when editing an already-persisted statement;
+ // a new pending-draft spec still needs them to author its first statement.
+ const isEditingExistingStatement = isInlineEditing && !isPendingDraft;
const hasChanges = page.isCreating
? draftStatement !== statement
: isEditing && draftStatement !== statement;
@@ -448,61 +453,61 @@ export function PlanDetailStatementSection({
onChange={(event) => void handleFileUpload(event)}
type="file"
/>
- <div className="flex flex-wrap items-center justify-end gap-x-2 gap-y-2">
- {(canModifyStatement || isEditing) && (
- <div className="flex flex-wrap items-center justify-end gap-x-2 gap-y-2">
- <Button onClick={handleUploadClick} size="xs" variant="outline">
- <Upload className="h-3.5 w-3.5" />
- {t("issue.upload-sql")}
- </Button>
- {schemaEditorEligible && (
- <Button
- onClick={() => setIsSchemaEditorOpen(true)}
- size="xs"
- variant="outline"
- >
- <Table className="h-3.5 w-3.5" />
- {t("schema-editor.self")}
+ {(canModifyStatement || isEditing) && (
+ <div className="flex flex-wrap items-center justify-end gap-x-2 gap-y-2">
+ {!isEditingExistingStatement && (
+ <>
+ <Button onClick={handleUploadClick} size="xs" variant="outline">
+ <Upload className="h-3.5 w-3.5" />
+ {t("issue.upload-sql")}
</Button>
- )}
- {!isEditing ? (
- canEdit ? (
- <Button
- onClick={() => setIsEditing(true)}
- size="xs"
- variant="outline"
- >
- {t("common.edit")}
- </Button>
- ) : null
- ) : !page.isCreating ? (
- <>
+ {schemaEditorEligible && (
<Button
- disabled={!canSave}
- onClick={() => void handleSave()}
+ onClick={() => setIsSchemaEditorOpen(true)}
size="xs"
variant="outline"
>
- {isSaving && (
- <Loader2 className="h-3.5 w-3.5 animate-spin" />
- )}
- {t("common.save")}
- </Button>
- <Button
- onClick={() => {
- setDraftStatement(statement);
- setIsEditing(false);
- }}
- size="xs"
- variant="ghost"
- >
- {t("common.cancel")}
+ <Table className="h-3.5 w-3.5" />
+ {t("schema-editor.self")}
</Button>
- </>
- ) : null}
- </div>
- )}
- </div>
+ )}
+ </>
+ )}
+ {!isEditing && canEdit && (
+ <Button
+ onClick={() => setIsEditing(true)}
+ size="xs"
+ variant="outline"
+ >
+ <Pencil className="h-3.5 w-3.5" />
+ {t("common.edit")}
+ </Button>
+ )}
+ {isInlineEditing && (
+ <>
+ <Button
+ disabled={!canSave}
+ onClick={() => void handleSave()}
+ size="xs"
+ variant="outline"
+ >
+ {isSaving && <Loader2 className="h-3.5 w-3.5 animate-spin" />}
+ {t("common.save")}
+ </Button>
+ <Button
+ onClick={() => {
+ setDraftStatement(statement);
+ setIsEditing(false);
+ }}
+ size="xs"
+ variant="ghost"
+ >
+ {t("common.cancel")}
+ </Button>
+ </>
+ )}
+ </div>
+ )}
</div>
{isSheetOversize && (
<Alert