Skip to content

Commit 795670b

Browse files
author
Laurie T. Malau
committed
[dashboard] Allow workspace renaming
Fixes #3946
1 parent 6f6f85d commit 795670b

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

components/dashboard/src/workspaces/WorkspaceEntry.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { GitpodHostUrl } from '@gitpod/gitpod-protocol/lib/util/gitpod-host-url'
99
import moment from 'moment';
1010
import React, { useState } from 'react';
1111
import ConfirmationModal from '../components/ConfirmationModal';
12+
import Modal from '../components/Modal';
1213
import { ContextMenuEntry } from '../components/ContextMenu';
1314
import { Item, ItemField, ItemFieldContextMenu, ItemFieldIcon } from '../components/ItemsList';
1415
import PendingChangesDropdown from '../components/PendingChangesDropdown';
@@ -30,7 +31,8 @@ interface Props {
3031
}
3132

3233
export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
33-
const [isModalVisible, setModalVisible] = useState(false);
34+
const [isDeleteModalVisible, setDeleteModalVisible] = useState(false);
35+
const [isRenameModalVisible, setRenameModalVisible] = useState(false);
3436
const state: WorkspaceInstancePhase = desc.latestInstance?.status?.phase || 'stopped';
3537
const currentBranch = desc.latestInstance?.status.repo?.branch || Workspace.getBranchName(desc.workspace) || '<unknown>';
3638
const ws = desc.workspace;
@@ -45,7 +47,16 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
4547
{
4648
title: 'Open',
4749
href: startUrl.toString()
48-
}];
50+
},
51+
{
52+
title: 'Rename ',
53+
href: "",
54+
onClick: () => {
55+
setRenameModalVisible(true);
56+
}
57+
},
58+
59+
];
4960
if (state === 'running') {
5061
menuEntries.push({
5162
title: 'Stop',
@@ -78,7 +89,7 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
7889
title: 'Delete',
7990
customFontStyle: 'text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300',
8091
onClick: () => {
81-
setModalVisible(true);
92+
setDeleteModalVisible(true);
8293
}
8394
}
8495
);
@@ -111,18 +122,25 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
111122
</Tooltip>
112123
</ItemField>
113124
<ItemFieldContextMenu menuEntries={menuEntries} />
114-
{isModalVisible && <ConfirmationModal
125+
{isDeleteModalVisible && <ConfirmationModal
115126
title="Delete Workspace"
116127
areYouSureText="Are you sure you want to delete this workspace?"
117128
children={{
118129
name: ws.id,
119130
description: ws.description,
120131
}}
121132
buttonText="Delete Workspace"
122-
visible={isModalVisible}
123-
onClose={() => setModalVisible(false)}
133+
visible={isDeleteModalVisible}
134+
onClose={() => setDeleteModalVisible(false)}
124135
onConfirm={() => model.deleteWorkspace(ws.id)}
125136
/>}
137+
{isRenameModalVisible &&
138+
<Modal
139+
visible={true}
140+
onClose={() => setRenameModalVisible(false)}>
141+
<h3>Rename Workspace</h3>
142+
</Modal>
143+
}
126144
</Item>;
127145
}
128146

0 commit comments

Comments
 (0)