Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/user-settings/EnvironmentVariableEntry.tsx
2500 views
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
};
46
47