mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-14 16:07:52 +00:00
Make the refactoring preview dialog (Rename, Safe Delete, Pull Up / Push Down) and the Pull Members Up / Push Members Down dialog resizable. The preview had a fixed width and a 320px list cap; the list now fills the dialog, the size is remembered and full paths show as tooltips. The member table in the pull/push dialog takes the extra space. Closes #2570
This commit is contained in:
@@ -319,7 +319,13 @@
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.previewDialog [data-dialog-body] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
.previewSummary {
|
||||
flex: none;
|
||||
padding: 10px 14px 6px;
|
||||
font-size: var(--fs-ui);
|
||||
color: var(--fg-muted);
|
||||
@@ -328,7 +334,8 @@
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0 0 8px;
|
||||
max-height: 320px;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
.previewRow {
|
||||
@@ -358,6 +365,7 @@
|
||||
}
|
||||
|
||||
.previewWarning {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
|
||||
@@ -532,15 +532,42 @@ function DefinitionPopup({ popup }: { popup: Extract<LspPopup, { kind: "definiti
|
||||
);
|
||||
}
|
||||
|
||||
const PREVIEW_SIZE_KEY = "openidea.refactor.previewSize";
|
||||
|
||||
function loadPreviewSize(): { w: number; h: number } | null {
|
||||
try {
|
||||
const v = JSON.parse(localStorage.getItem(PREVIEW_SIZE_KEY) ?? "null") as { w?: unknown; h?: unknown } | null;
|
||||
return typeof v?.w === "number" && typeof v.h === "number" ? { w: v.w, h: v.h } : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function savePreviewSize(size: { w: number; h: number }) {
|
||||
try {
|
||||
localStorage.setItem(PREVIEW_SIZE_KEY, JSON.stringify(size));
|
||||
} catch {
|
||||
// Private mode etc. — the size just isn't remembered.
|
||||
}
|
||||
}
|
||||
|
||||
function PreviewDialog({ popup }: { popup: Extract<LspPopup, { kind: "preview" }> }) {
|
||||
const root = useProject((s) => s.project?.root ?? "");
|
||||
const { summary } = popup;
|
||||
const [initialSize] = useState(loadPreviewSize);
|
||||
return (
|
||||
<Dialog
|
||||
open
|
||||
onClose={closePopup}
|
||||
title={popup.title}
|
||||
className={styles.previewDialog}
|
||||
width={560}
|
||||
minWidth={400}
|
||||
minHeight={220}
|
||||
maxHeight={480}
|
||||
resizable="both"
|
||||
initialSize={initialSize}
|
||||
onResized={savePreviewSize}
|
||||
buttons={[
|
||||
{
|
||||
label: popup.confirmLabel,
|
||||
@@ -586,7 +613,9 @@ function PreviewDialog({ popup }: { popup: Extract<LspPopup, { kind: "preview" }
|
||||
<li key={e.path} className={styles.previewRow}>
|
||||
<Icon name={fileIconName(basename(e.path), e.path)} size={14} className={styles.itemIcon} />
|
||||
<span className={styles.previewName}>{basename(e.path)}</span>
|
||||
<span className={styles.previewPath}>{relativePath(root, e.path)}</span>
|
||||
<span className={styles.previewPath} title={relativePath(root, e.path)}>
|
||||
{relativePath(root, e.path)}
|
||||
</span>
|
||||
<span className={styles.spacer} />
|
||||
{e.operation === "rename" && e.to && <span className={styles.previewOp}>→ {basename(e.to)}</span>}
|
||||
{e.operation && e.operation !== "rename" && <span className={styles.previewOp}>{e.operation}</span>}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
.dialog [data-dialog-body] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
@@ -8,6 +16,7 @@
|
||||
}
|
||||
|
||||
.field {
|
||||
flex: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
@@ -23,6 +32,7 @@
|
||||
flex-direction: column;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
@@ -42,7 +52,8 @@
|
||||
}
|
||||
|
||||
.rows {
|
||||
max-height: 280px;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
@@ -62,11 +73,13 @@
|
||||
}
|
||||
|
||||
.hint {
|
||||
flex: none;
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
|
||||
.error {
|
||||
flex: none;
|
||||
color: var(--danger);
|
||||
font-size: var(--fs-small);
|
||||
overflow-wrap: anywhere;
|
||||
|
||||
@@ -58,7 +58,11 @@ function HierarchyDialogInner({ request }: { request: HierarchyRequest }) {
|
||||
open
|
||||
onClose={close}
|
||||
title={titleOf(kind)}
|
||||
className={styles.dialog}
|
||||
width={560}
|
||||
minHeight={300}
|
||||
maxHeight={560}
|
||||
resizable="both"
|
||||
buttons={[
|
||||
{ label: "Preview", role: "extra", disabled: !ready, onClick: () => void submit(true) },
|
||||
{ label: "Refactor", role: "default", disabled: !ready, onClick: () => void submit(false) },
|
||||
|
||||
Reference in New Issue
Block a user