Skip to content

Commit

Permalink
[dashboard] Allow workspace renaming
Browse files Browse the repository at this point in the history
Fixes #3946
  • Loading branch information
laushinka committed Sep 13, 2021
1 parent 07d8d81 commit cc77574
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions components/dashboard/src/workspaces/WorkspaceEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { GitpodHostUrl } from '@gitpod/gitpod-protocol/lib/util/gitpod-host-url'
import moment from 'moment';
import React, { useState } from 'react';
import ConfirmationModal from '../components/ConfirmationModal';
import Modal from '../components/Modal';
import { ContextMenuEntry } from '../components/ContextMenu';
import { Item, ItemField, ItemFieldContextMenu, ItemFieldIcon } from '../components/ItemsList';
import PendingChangesDropdown from '../components/PendingChangesDropdown';
Expand All @@ -30,7 +31,8 @@ interface Props {
}

export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
const [isModalVisible, setModalVisible] = useState(false);
const [isDeleteModalVisible, setDeleteModalVisible] = useState(false);
const [isRenameModalVisible, setRenameModalVisible] = useState(false);
const state: WorkspaceInstancePhase = desc.latestInstance?.status?.phase || 'stopped';
const currentBranch = desc.latestInstance?.status.repo?.branch || Workspace.getBranchName(desc.workspace) || '<unknown>';
const ws = desc.workspace;
Expand All @@ -45,7 +47,16 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
{
title: 'Open',
href: startUrl.toString()
}];
},
{
title: 'Rename ',
href: "",
onClick: () => {
setRenameModalVisible(true);
}
},

];
if (state === 'running') {
menuEntries.push({
title: 'Stop',
Expand Down Expand Up @@ -78,7 +89,7 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
title: 'Delete',
customFontStyle: 'text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300',
onClick: () => {
setModalVisible(true);
setDeleteModalVisible(true);
}
}
);
Expand Down Expand Up @@ -111,18 +122,25 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
</Tooltip>
</ItemField>
<ItemFieldContextMenu menuEntries={menuEntries} />
{isModalVisible && <ConfirmationModal
{isDeleteModalVisible && <ConfirmationModal
title="Delete Workspace"
areYouSureText="Are you sure you want to delete this workspace?"
children={{
name: ws.id,
description: ws.description,
}}
buttonText="Delete Workspace"
visible={isModalVisible}
onClose={() => setModalVisible(false)}
visible={isDeleteModalVisible}
onClose={() => setDeleteModalVisible(false)}
onConfirm={() => model.deleteWorkspace(ws.id)}
/>}
{isRenameModalVisible &&
<Modal
visible={true}
onClose={() => setRenameModalVisible(false)}>
<h3>Rename Workspace</h3>
</Modal>
}
</Item>;
}

Expand Down

0 comments on commit cc77574

Please sign in to comment.