Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/repositories/detail/variables/ConfigurationVariableItem.tsx
2502 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 {
8
ConfigurationEnvironmentVariable,
9
EnvironmentVariableAdmission,
10
} from "@gitpod/public-api/lib/gitpod/v1/envvar_pb";
11
import { DropdownActions } from "@podkit/dropdown/DropDownActions";
12
import { TableRow, TableCell } from "@podkit/tables/Table";
13
import { useState } from "react";
14
import { ConfigurationDeleteVariableModal } from "./ConfigurationRemoveVariableModal";
15
import { DropdownMenuItem } from "@podkit/dropdown/DropDown";
16
17
type Props = {
18
configurationId: string;
19
variable: ConfigurationEnvironmentVariable;
20
};
21
export const ConfigurationVariableItem = ({ variable, configurationId }: Props) => {
22
const [showRemoveModal, setShowRemoveModal] = useState<boolean>(false);
23
24
return (
25
<>
26
{showRemoveModal && (
27
<ConfigurationDeleteVariableModal
28
variable={variable}
29
configurationId={configurationId}
30
onClose={() => setShowRemoveModal(false)}
31
/>
32
)}
33
<TableRow key={variable.id}>
34
<TableCell className="break-all">{variable.name}</TableCell>
35
<TableCell>
36
{variable.admission === EnvironmentVariableAdmission.PREBUILD
37
? "Prebuilds only"
38
: "Prebuilds & workspaces"}
39
</TableCell>
40
<TableCell className="flex justify-end">
41
<DropdownActions>
42
<DropdownMenuItem
43
className="text-red-600 dark:text-red-400 focus:text-red-800 dark:focus:text-red-300"
44
onSelect={() => {
45
setShowRemoveModal(true);
46
}}
47
>
48
Delete
49
</DropdownMenuItem>
50
</DropdownActions>
51
</TableCell>
52
</TableRow>
53
</>
54
);
55
};
56
57