Skip to content

Commit 3d1788a

Browse files
Siumauriciomcfdez
authored andcommitted
feat(deployments): enhance deployment limit selection with custom input option
- Added a custom input field for setting deployment limits, allowing values between 1 and 500. - Updated the API schema to support a maximum limit of 500 for deployment queries. - Improved user experience by enabling a toggle between predefined limits and a custom value.
1 parent df6918a commit 3d1788a

2 files changed

Lines changed: 50 additions & 18 deletions

File tree

apps/dokploy/components/dashboard/application/deployments/show-deployments.tsx

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const ShowDeployments = ({
7171
RouterOutputs["deployment"]["all"][number] | null
7272
>(null);
7373
const [deploymentLimit, setDeploymentLimit] = useState<number>(10);
74+
const [isCustomLimit, setIsCustomLimit] = useState(false);
7475
const { data: deployments, isPending: isLoadingDeployments } =
7576
api.deployment.allByType.useQuery(
7677
{
@@ -169,20 +170,51 @@ export const ShowDeployments = ({
169170
<span className="text-sm text-muted-foreground whitespace-nowrap">
170171
Show:
171172
</span>
172-
<Select
173-
value={deploymentLimit.toString()}
174-
onValueChange={(value) => setDeploymentLimit(Number(value))}
175-
>
176-
<SelectTrigger className="w-20 h-10">
177-
<SelectValue />
178-
</SelectTrigger>
179-
<SelectContent>
180-
<SelectItem value="10">10</SelectItem>
181-
<SelectItem value="25">25</SelectItem>
182-
<SelectItem value="50">50</SelectItem>
183-
<SelectItem value="100">100</SelectItem>
184-
</SelectContent>
185-
</Select>
173+
{isCustomLimit ? (
174+
<input
175+
type="number"
176+
min={1}
177+
max={500}
178+
value={deploymentLimit}
179+
onChange={(e) => {
180+
const val = Number(e.target.value);
181+
if (val >= 1 && val <= 500) {
182+
setDeploymentLimit(val);
183+
}
184+
}}
185+
onBlur={(e) => {
186+
if (!e.target.value || Number(e.target.value) < 1) {
187+
setDeploymentLimit(10);
188+
setIsCustomLimit(false);
189+
}
190+
}}
191+
className="w-20 h-10 rounded-md border border-input bg-background px-3 text-sm"
192+
/>
193+
) : (
194+
<Select
195+
value={deploymentLimit.toString()}
196+
onValueChange={(value) => {
197+
if (value === "custom") {
198+
setIsCustomLimit(true);
199+
} else {
200+
setDeploymentLimit(Number(value));
201+
}
202+
}}
203+
>
204+
<SelectTrigger className="w-24 h-10">
205+
<SelectValue />
206+
</SelectTrigger>
207+
<SelectContent>
208+
<SelectItem value="10">10</SelectItem>
209+
<SelectItem value="25">25</SelectItem>
210+
<SelectItem value="50">50</SelectItem>
211+
<SelectItem value="100">100</SelectItem>
212+
<SelectItem value="200">200</SelectItem>
213+
<SelectItem value="500">500</SelectItem>
214+
<SelectItem value="custom">Custom</SelectItem>
215+
</SelectContent>
216+
</Select>
217+
)}
186218
</div>
187219
{(type === "application" || type === "compose") && (
188220
<ClearDeployments id={id} type={type} />

packages/server/src/db/schema/deployment.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,17 @@ export const apiCreateDeploymentVolumeBackup = schema
211211

212212
export const apiFindAllByApplication = z.object({
213213
applicationId: z.string().min(1),
214-
limit: z.number().min(1).max(100).optional().default(10),
214+
limit: z.number().min(1).max(500).optional().default(10),
215215
});
216216

217217
export const apiFindAllByCompose = z.object({
218218
composeId: z.string().min(1),
219-
limit: z.number().min(1).max(100).optional().default(10),
219+
limit: z.number().min(1).max(500).optional().default(10),
220220
});
221221

222222
export const apiFindAllByServer = z.object({
223223
serverId: z.string().min(1),
224-
limit: z.number().min(1).max(100).optional().default(10),
224+
limit: z.number().min(1).max(500).optional().default(10),
225225
});
226226

227227
export const apiFindAllByType = z.object({
@@ -235,5 +235,5 @@ export const apiFindAllByType = z.object({
235235
"backup",
236236
"volumeBackup",
237237
]),
238-
limit: z.number().min(1).max(100).optional().default(10),
238+
limit: z.number().min(1).max(500).optional().default(10),
239239
});

0 commit comments

Comments
 (0)