mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-20 19:18:45 +00:00
refactor: simplify deployment description toggle logic
- Removed the separate toggleDescription function and integrated its logic directly into the button's onClick handler for better readability. - Maintained functionality for expanding and collapsing deployment descriptions while streamlining the code structure.
This commit is contained in:
@@ -100,26 +100,12 @@ export const ShowDeployments = ({
|
|||||||
}
|
}
|
||||||
const truncated = description.slice(0, MAX_DESCRIPTION_LENGTH);
|
const truncated = description.slice(0, MAX_DESCRIPTION_LENGTH);
|
||||||
const lastSpace = truncated.lastIndexOf(" ");
|
const lastSpace = truncated.lastIndexOf(" ");
|
||||||
// Truncate at word boundary if found near the end
|
|
||||||
if (lastSpace > MAX_DESCRIPTION_LENGTH - 20 && lastSpace > 0) {
|
if (lastSpace > MAX_DESCRIPTION_LENGTH - 20 && lastSpace > 0) {
|
||||||
return `${truncated.slice(0, lastSpace)}...`;
|
return `${truncated.slice(0, lastSpace)}...`;
|
||||||
}
|
}
|
||||||
return `${truncated}...`;
|
return `${truncated}...`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Toggle expand/collapse state for a specific deployment
|
|
||||||
const toggleDescription = (deploymentId: string) => {
|
|
||||||
setExpandedDescriptions((prev) => {
|
|
||||||
const next = new Set(prev);
|
|
||||||
if (next.has(deploymentId)) {
|
|
||||||
next.delete(deploymentId);
|
|
||||||
} else {
|
|
||||||
next.add(deploymentId);
|
|
||||||
}
|
|
||||||
return next;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check for stuck deployment (more than 9 minutes) - only for the most recent deployment
|
// Check for stuck deployment (more than 9 minutes) - only for the most recent deployment
|
||||||
const stuckDeployment = useMemo(() => {
|
const stuckDeployment = useMemo(() => {
|
||||||
if (!isCloud || !deployments || deployments.length === 0) return null;
|
if (!isCloud || !deployments || deployments.length === 0) return null;
|
||||||
@@ -286,9 +272,15 @@ export const ShowDeployments = ({
|
|||||||
{needsTruncation && (
|
{needsTruncation && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() =>
|
onClick={() => {
|
||||||
toggleDescription(deployment.deploymentId)
|
const next = new Set(expandedDescriptions);
|
||||||
}
|
if (next.has(deployment.deploymentId)) {
|
||||||
|
next.delete(deployment.deploymentId);
|
||||||
|
} else {
|
||||||
|
next.add(deployment.deploymentId);
|
||||||
|
}
|
||||||
|
setExpandedDescriptions(next);
|
||||||
|
}}
|
||||||
className="flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit mt-1 cursor-pointer"
|
className="flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit mt-1 cursor-pointer"
|
||||||
aria-label={
|
aria-label={
|
||||||
isExpanded
|
isExpanded
|
||||||
|
|||||||
Reference in New Issue
Block a user