Skip to content

Commit 997dd78

Browse files
authored
Merge pull request #2862 from Harikrishnan1367709/Add-Ctrl+S/CMD+S-keyboard-shortcuts-to-save-.env-file-#2845
Add Ctrl+S/CMD+S keyboard shortcuts to save .env files -#2845
2 parents 60d1bc4 + b662629 commit 997dd78

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

apps/dokploy/components/dashboard/application/environment/show-enviroment.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ export const ShowEnvironment = ({ id, type }: Props) => {
108108
});
109109
};
110110

111+
// Add keyboard shortcut for Ctrl+S/Cmd+S
112+
useEffect(() => {
113+
const handleKeyDown = (e: KeyboardEvent) => {
114+
if ((e.ctrlKey || e.metaKey) && e.key === "s" && !isLoading) {
115+
e.preventDefault();
116+
form.handleSubmit(onSubmit)();
117+
}
118+
};
119+
120+
document.addEventListener("keydown", handleKeyDown);
121+
return () => {
122+
document.removeEventListener("keydown", handleKeyDown);
123+
};
124+
}, [form, onSubmit, isLoading]);
125+
111126
return (
112127
<div className="flex w-full flex-col gap-5 ">
113128
<Card className="bg-background">

apps/dokploy/components/dashboard/application/environment/show.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ export const ShowEnvironment = ({ applicationId }: Props) => {
8686
});
8787
};
8888

89+
// Add keyboard shortcut for Ctrl+S/Cmd+S
90+
useEffect(() => {
91+
const handleKeyDown = (e: KeyboardEvent) => {
92+
if ((e.ctrlKey || e.metaKey) && e.key === "s" && !isLoading) {
93+
e.preventDefault();
94+
form.handleSubmit(onSubmit)();
95+
}
96+
};
97+
98+
document.addEventListener("keydown", handleKeyDown);
99+
return () => {
100+
document.removeEventListener("keydown", handleKeyDown);
101+
};
102+
}, [form, onSubmit, isLoading]);
103+
89104
return (
90105
<Card className="bg-background px-6 pb-6">
91106
<Form {...form}>

apps/dokploy/components/dashboard/project/environment-variables.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ export const EnvironmentVariables = ({ environmentId, children }: Props) => {
8282
.finally(() => {});
8383
};
8484

85+
// Add keyboard shortcut for Ctrl+S/Cmd+S
86+
useEffect(() => {
87+
const handleKeyDown = (e: KeyboardEvent) => {
88+
if ((e.ctrlKey || e.metaKey) && e.key === "s" && !isLoading && isOpen) {
89+
e.preventDefault();
90+
form.handleSubmit(onSubmit)();
91+
}
92+
};
93+
94+
document.addEventListener("keydown", handleKeyDown);
95+
return () => {
96+
document.removeEventListener("keydown", handleKeyDown);
97+
};
98+
}, [form, onSubmit, isLoading, isOpen]);
99+
85100
return (
86101
<Dialog open={isOpen} onOpenChange={setIsOpen}>
87102
<DialogTrigger asChild>

apps/dokploy/components/dashboard/projects/project-environment.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@ export const ProjectEnvironment = ({ projectId, children }: Props) => {
8181
.finally(() => {});
8282
};
8383

84+
// Add keyboard shortcut for Ctrl+S/Cmd+S
85+
useEffect(() => {
86+
const handleKeyDown = (e: KeyboardEvent) => {
87+
if ((e.ctrlKey || e.metaKey) && e.key === "s" && !isLoading && isOpen) {
88+
e.preventDefault();
89+
form.handleSubmit(onSubmit)();
90+
}
91+
};
92+
93+
document.addEventListener("keydown", handleKeyDown);
94+
return () => {
95+
document.removeEventListener("keydown", handleKeyDown);
96+
};
97+
}, [form, onSubmit, isLoading, isOpen]);
98+
8499
return (
85100
<Dialog open={isOpen} onOpenChange={setIsOpen}>
86101
<DialogTrigger asChild>

apps/dokploy/components/dashboard/settings/web-server/edit-traefik-env.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ export const EditTraefikEnv = ({ children, serverId }: Props) => {
7575
});
7676
};
7777

78+
// Add keyboard shortcut for Ctrl+S/Cmd+S
79+
useEffect(() => {
80+
const handleKeyDown = (e: KeyboardEvent) => {
81+
if ((e.ctrlKey || e.metaKey) && e.key === "s" && !isLoading && !canEdit) {
82+
e.preventDefault();
83+
form.handleSubmit(onSubmit)();
84+
}
85+
};
86+
87+
document.addEventListener("keydown", handleKeyDown);
88+
return () => {
89+
document.removeEventListener("keydown", handleKeyDown);
90+
};
91+
}, [form, onSubmit, isLoading, canEdit]);
92+
7893
return (
7994
<Dialog>
8095
<DialogTrigger asChild>{children}</DialogTrigger>

0 commit comments

Comments
 (0)