mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2026-08-08 02:02:33 +00:00
Chart Builder: open a snippet in the builder to edit it in place
This commit is contained in:
@@ -1466,6 +1466,12 @@ export function ChartBuilderModal() {
|
||||
const setStack = useChartBuilderStore((s) => s.setStack);
|
||||
const applyWarningFix = useChartBuilderStore((s) => s.applyWarningFix);
|
||||
const runCreate = useChartBuilderStore((s) => s.createSnippet);
|
||||
const runSave = useChartBuilderStore((s) => s.saveEdits);
|
||||
// Edit-in-place (spec §06 → Open in builder): when a snippet was opened in the
|
||||
// builder, the primary action *saves back* to it instead of creating a new snippet.
|
||||
const editingSnippetId = useChartBuilderStore((s) => s.editingSnippetId);
|
||||
const editingSnippetName = useChartBuilderStore((s) => s.editingSnippetName);
|
||||
const editing = editingSnippetId !== null;
|
||||
|
||||
// Validity + guidance + which chart-level controls apply are derived from the
|
||||
// stable `config` reference via useMemo, NOT a store selector that would build a
|
||||
@@ -1526,6 +1532,11 @@ export function ChartBuilderModal() {
|
||||
<div className="visually-hidden" role="status" aria-live="polite">
|
||||
{fixAnnouncement}
|
||||
</div>
|
||||
{editing && (
|
||||
<p className={styles.editingBanner}>
|
||||
Editing <strong>{editingSnippetName}</strong>
|
||||
</p>
|
||||
)}
|
||||
<DatasetPicker datasetId={datasetId} />
|
||||
|
||||
<IntentStrip />
|
||||
@@ -1610,7 +1621,7 @@ export function ChartBuilderModal() {
|
||||
|
||||
{!valid && (
|
||||
<p id="cb-create-hint" className={styles.createHint}>
|
||||
Map at least one channel to a column to create a snippet.
|
||||
Map at least one channel to a column to {editing ? 'save changes' : 'create a snippet'}.
|
||||
</p>
|
||||
)}
|
||||
<div className={styles.actions}>
|
||||
@@ -1622,12 +1633,12 @@ export function ChartBuilderModal() {
|
||||
size="lg"
|
||||
disabled={!valid}
|
||||
aria-describedby={!valid ? 'cb-create-hint' : undefined}
|
||||
// The create is the user's confirmation — close with no discard prompt.
|
||||
// The commit is the user's confirmation — close with no discard prompt.
|
||||
onClick={() => {
|
||||
if (runCreate()) void closeModal(true);
|
||||
if (editing ? runSave() : runCreate()) void closeModal(true);
|
||||
}}
|
||||
>
|
||||
Create Snippet
|
||||
{editing ? 'Save changes' : 'Create Snippet'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user