Skip to content

Commit d5d7659

Browse files
henit-chobisaroboquat
authored andcommitted
feat: Improved UX for Environment Variable Item List ( Settings )
1 parent 85ec355 commit d5d7659

File tree

2 files changed

+54
-28
lines changed

2 files changed

+54
-28
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License.AGPL.txt in the project root for license information.
5+
*/
6+
7+
import { UserEnvVarValue } from "@gitpod/gitpod-protocol";
8+
import { Item, ItemField, ItemFieldContextMenu } from "../components/ItemsList";
9+
import { useState } from "react";
10+
11+
export const EnvironmentVariableEntry = (props: {
12+
variable: UserEnvVarValue;
13+
edit: (varible: UserEnvVarValue) => void;
14+
confirmDeleteVariable: (varible: UserEnvVarValue) => void;
15+
}) => {
16+
const [menuActive, setMenuActive] = useState(false);
17+
18+
const changeMenuState = (state: boolean) => {
19+
setMenuActive(state);
20+
};
21+
22+
return (
23+
<Item className="whitespace-nowrap" solid={menuActive}>
24+
<ItemField className="w-5/12 overflow-ellipsis truncate my-auto">{props.variable.name}</ItemField>
25+
<ItemField className="w-5/12 overflow-ellipsis truncate text-sm text-gray-400 my-auto">
26+
{props.variable.repositoryPattern}
27+
</ItemField>
28+
<ItemFieldContextMenu
29+
changeMenuState={changeMenuState}
30+
menuEntries={[
31+
{
32+
title: "Edit",
33+
onClick: () => props.edit(props.variable),
34+
separator: true,
35+
},
36+
{
37+
title: "Delete",
38+
customFontStyle: "text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300",
39+
onClick: () => props.confirmDeleteVariable(props.variable),
40+
},
41+
]}
42+
/>
43+
</Item>
44+
);
45+
};

components/dashboard/src/user-settings/EnvironmentVariables.tsx

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
import { UserEnvVar, UserEnvVarValue } from "@gitpod/gitpod-protocol";
88
import { useEffect, useRef, useState } from "react";
99
import ConfirmationModal from "../components/ConfirmationModal";
10-
import { Item, ItemField, ItemFieldContextMenu, ItemsList } from "../components/ItemsList";
10+
import { Item, ItemField, ItemsList } from "../components/ItemsList";
1111
import Modal, { ModalBody, ModalFooter, ModalHeader } from "../components/Modal";
1212
import { getGitpodService } from "../service/service";
1313
import { PageWithSettingsSubMenu } from "./PageWithSettingsSubMenu";
14+
import { EnvironmentVariableEntry } from "./EnvironmentVariableEntry";
1415

1516
interface EnvVarModalProps {
1617
envVar: UserEnvVarValue;
@@ -259,33 +260,13 @@ export default function EnvVars() {
259260
<ItemField className="w-5/12 my-auto">Name</ItemField>
260261
<ItemField className="w-5/12 my-auto">Scope</ItemField>
261262
</Item>
262-
{envVars.map((variable) => {
263-
return (
264-
<Item className="whitespace-nowrap">
265-
<ItemField className="w-5/12 overflow-ellipsis truncate my-auto">
266-
{variable.name}
267-
</ItemField>
268-
<ItemField className="w-5/12 overflow-ellipsis truncate text-sm text-gray-400 my-auto">
269-
{variable.repositoryPattern}
270-
</ItemField>
271-
<ItemFieldContextMenu
272-
menuEntries={[
273-
{
274-
title: "Edit",
275-
onClick: () => edit(variable),
276-
separator: true,
277-
},
278-
{
279-
title: "Delete",
280-
customFontStyle:
281-
"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300",
282-
onClick: () => confirmDeleteVariable(variable),
283-
},
284-
]}
285-
/>
286-
</Item>
287-
);
288-
})}
263+
{envVars.map((variable) => (
264+
<EnvironmentVariableEntry
265+
variable={variable}
266+
edit={edit}
267+
confirmDeleteVariable={confirmDeleteVariable}
268+
/>
269+
))}
289270
</ItemsList>
290271
)}
291272
</PageWithSettingsSubMenu>

0 commit comments

Comments
 (0)