Skip to content

Commit a2d7ede

Browse files
committed
cp dines
1 parent cbf037e commit a2d7ede

5 files changed

Lines changed: 240 additions & 49 deletions

File tree

src/commands/network-policy/list.tsx

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ const ListNetworkPoliciesUI = ({
9494
);
9595
const [operationLoading, setOperationLoading] = React.useState(false);
9696
const [showCreatePolicy, setShowCreatePolicy] = React.useState(false);
97+
const [showEditPolicy, setShowEditPolicy] = React.useState(false);
98+
const [editingPolicy, setEditingPolicy] =
99+
React.useState<NetworkPolicyListItem | null>(null);
97100
const [showDeleteConfirm, setShowDeleteConfirm] = React.useState(false);
98101

99102
// Calculate overhead for viewport height
@@ -109,7 +112,7 @@ const ListNetworkPoliciesUI = ({
109112
const fixedWidth = 6; // border + padding
110113
const idWidth = 25;
111114
const egressWidth = 15;
112-
const timeWidth = 15;
115+
const timeWidth = 20;
113116
const showDescription = terminalWidth >= 100;
114117
const descriptionWidth = Math.max(20, terminalWidth >= 140 ? 40 : 25);
115118

@@ -189,6 +192,7 @@ const ListNetworkPoliciesUI = ({
189192
!showPopup &&
190193
!executingOperation &&
191194
!showCreatePolicy &&
195+
!showEditPolicy &&
192196
!showDeleteConfirm,
193197
deps: [PAGE_SIZE],
194198
});
@@ -202,6 +206,12 @@ const ListNetworkPoliciesUI = ({
202206
color: colors.primary,
203207
icon: figures.pointer,
204208
},
209+
{
210+
key: "edit",
211+
label: "Edit Network Policy",
212+
color: colors.warning,
213+
icon: figures.pointer,
214+
},
205215
{
206216
key: "delete",
207217
label: "Delete Network Policy",
@@ -364,6 +374,11 @@ const ListNetworkPoliciesUI = ({
364374
return;
365375
}
366376

377+
// Handle edit policy screen
378+
if (showEditPolicy) {
379+
return;
380+
}
381+
367382
// Handle popup navigation
368383
if (showPopup) {
369384
if (key.upArrow && selectedOperation > 0) {
@@ -380,6 +395,10 @@ const ListNetworkPoliciesUI = ({
380395
navigate("network-policy-detail", {
381396
networkPolicyId: selectedPolicyItem.id,
382397
});
398+
} else if (operationKey === "edit") {
399+
// Show edit form
400+
setEditingPolicy(selectedPolicyItem);
401+
setShowEditPolicy(true);
383402
} else if (operationKey === "delete") {
384403
// Show delete confirmation
385404
setSelectedPolicy(selectedPolicyItem);
@@ -400,6 +419,11 @@ const ListNetworkPoliciesUI = ({
400419
navigate("network-policy-detail", {
401420
networkPolicyId: selectedPolicyItem.id,
402421
});
422+
} else if (input === "e" && selectedPolicyItem) {
423+
// Edit hotkey
424+
setShowPopup(false);
425+
setEditingPolicy(selectedPolicyItem);
426+
setShowEditPolicy(true);
403427
} else if (key.escape || input === "q") {
404428
setShowPopup(false);
405429
setSelectedOperation(0);
@@ -446,6 +470,10 @@ const ListNetworkPoliciesUI = ({
446470
} else if (input === "c") {
447471
// Create shortcut
448472
setShowCreatePolicy(true);
473+
} else if (input === "e" && selectedPolicyItem) {
474+
// Edit shortcut
475+
setEditingPolicy(selectedPolicyItem);
476+
setShowEditPolicy(true);
449477
} else if (key.escape) {
450478
if (onBack) {
451479
onBack();
@@ -546,6 +574,25 @@ const ListNetworkPoliciesUI = ({
546574
);
547575
}
548576

577+
// Edit policy screen
578+
if (showEditPolicy && editingPolicy) {
579+
return (
580+
<NetworkPolicyCreatePage
581+
onBack={() => {
582+
setShowEditPolicy(false);
583+
setEditingPolicy(null);
584+
}}
585+
onCreate={() => {
586+
setShowEditPolicy(false);
587+
setEditingPolicy(null);
588+
// Refresh the list to show updated data
589+
setTimeout(() => refresh(), 0);
590+
}}
591+
initialPolicy={editingPolicy}
592+
/>
593+
);
594+
}
595+
549596
// Loading state
550597
if (loading && policies.length === 0) {
551598
return (
@@ -639,9 +686,11 @@ const ListNetworkPoliciesUI = ({
639686
? "c"
640687
: op.key === "view_details"
641688
? "v"
642-
: op.key === "delete"
643-
? "d"
644-
: "",
689+
: op.key === "edit"
690+
? "e"
691+
: op.key === "delete"
692+
? "d"
693+
: "",
645694
}))}
646695
selectedOperation={selectedOperation}
647696
onClose={() => setShowPopup(false)}
@@ -660,6 +709,7 @@ const ListNetworkPoliciesUI = ({
660709
},
661710
{ key: "Enter", label: "Details" },
662711
{ key: "c", label: "Create" },
712+
{ key: "e", label: "Edit" },
663713
{ key: "a", label: "Actions" },
664714
{ key: "Esc", label: "Back" },
665715
]}

src/commands/object/list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const ListObjectsUI = ({
8989
const stateWidth = 12;
9090
const typeWidth = 15;
9191
const sizeWidth = 12;
92-
const timeWidth = 15;
92+
const timeWidth = 20;
9393
const ttlWidth = 14;
9494
const showTypeColumn = terminalWidth >= 100;
9595
const showSizeColumn = terminalWidth >= 90;

0 commit comments

Comments
 (0)