mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-27 19:33:08 -05:00
add save button to config bottom
This commit is contained in:
@@ -61,24 +61,25 @@ export const ConfigLayout = <
|
||||
)}
|
||||
{selector}
|
||||
{changesMade && (
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={onReset}
|
||||
disabled={disabled || !changesMade}
|
||||
className="flex items-center gap-2"
|
||||
>
|
||||
<History className="w-4 h-4" />
|
||||
Reset
|
||||
</Button>
|
||||
)}
|
||||
{changesMade && (
|
||||
<ConfirmUpdate
|
||||
previous={original}
|
||||
content={update}
|
||||
onConfirm={async () => onConfirm()}
|
||||
disabled={disabled}
|
||||
file_contents_language={file_contents_language}
|
||||
/>
|
||||
<>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={onReset}
|
||||
disabled={disabled || !changesMade}
|
||||
className="flex items-center gap-2"
|
||||
>
|
||||
<History className="w-4 h-4" />
|
||||
Reset
|
||||
</Button>
|
||||
<ConfirmUpdate
|
||||
previous={original}
|
||||
content={update}
|
||||
onConfirm={async () => onConfirm()}
|
||||
disabled={disabled}
|
||||
file_contents_language={file_contents_language}
|
||||
key_listener
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
@@ -309,6 +310,30 @@ export const Config = <T,>({
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
{changesMade && (
|
||||
<div className="flex gap-2 justify-end">
|
||||
<div className="text-muted-foreground flex items-center gap-2">
|
||||
<AlertTriangle className="w-4 h-4" /> Unsaved changes
|
||||
<AlertTriangle className="w-4 h-4" />
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={onReset}
|
||||
disabled={disabled}
|
||||
className="flex items-center gap-2"
|
||||
>
|
||||
<History className="w-4 h-4" />
|
||||
Reset
|
||||
</Button>
|
||||
<ConfirmUpdate
|
||||
previous={original}
|
||||
content={update}
|
||||
onConfirm={onConfirm}
|
||||
disabled={disabled}
|
||||
file_contents_language={file_contents_language}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</ConfigLayout>
|
||||
|
||||
@@ -600,6 +600,7 @@ interface ConfirmUpdateProps<T> {
|
||||
disabled: boolean;
|
||||
language?: MonacoLanguage;
|
||||
file_contents_language?: MonacoLanguage;
|
||||
key_listener?: boolean;
|
||||
}
|
||||
|
||||
export function ConfirmUpdate<T>({
|
||||
@@ -610,9 +611,11 @@ export function ConfirmUpdate<T>({
|
||||
disabled,
|
||||
language,
|
||||
file_contents_language,
|
||||
key_listener = false,
|
||||
}: ConfirmUpdateProps<T>) {
|
||||
const [open, set] = useState(false);
|
||||
useCtrlKeyListener("Enter", () => {
|
||||
if (!key_listener) return;
|
||||
if (open) {
|
||||
onConfirm();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user