-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Laushinka/allow users to delete 5066 #5966
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Fixes #5066
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* Copyright (c) 2021 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License-AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { useContext, useEffect, useState } from "react"; | ||
import { Redirect, useLocation } from "react-router"; | ||
import ConfirmationModal from "../components/ConfirmationModal"; | ||
import { PageWithSubMenu } from "../components/PageWithSubMenu"; | ||
import { getGitpodService, gitpodHostUrl } from "../service/service"; | ||
import { UserContext } from "../user-context"; | ||
import { getCurrentTeam, TeamsContext } from "./teams-context"; | ||
|
||
export default function TeamSettings() { | ||
const [modal, setModal] = useState(false); | ||
const [teamSlug, setTeamSlug] = useState(''); | ||
const [isUserOwner, setIsUserOwner] = useState(true); | ||
const { teams } = useContext(TeamsContext); | ||
const { user } = useContext(UserContext); | ||
const location = useLocation(); | ||
const team = getCurrentTeam(location, teams); | ||
|
||
const close = () => setModal(false); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
if (!team) return; | ||
const members = await getGitpodService().server.getTeamMembers(team.id); | ||
const currentUserInTeam = members.find(member => member.userId === user?.id); | ||
setIsUserOwner(currentUserInTeam?.role === 'owner'); | ||
})(); | ||
}, []); | ||
|
||
if (!isUserOwner) { | ||
return <Redirect to="/" /> | ||
}; | ||
const deleteTeam = async () => { | ||
if (!team || !user) { | ||
return | ||
} | ||
await getGitpodService().server.deleteTeam(team.id, user.id); | ||
document.location.href = gitpodHostUrl.asDashboard().toString(); | ||
}; | ||
|
||
const settingsMenu = [ | ||
{ | ||
title: 'General', | ||
link: [`/t/${team?.slug}/settings`] | ||
} | ||
] | ||
|
||
return <> | ||
<PageWithSubMenu subMenu={settingsMenu} title='General' subtitle='Manage general team settings.'> | ||
<h3>Delete Team</h3> | ||
<p className="text-base text-gray-500 pb-4">Deleting this team will also remove all associated data with this team, including projects and workspaces. Deleted teams cannot be restored!</p> | ||
<button className="danger secondary" onClick={() => setModal(true)}>Delete Account</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: This removes the team entry in the team scope selector but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still an issue. Minor and non-blocking. Added follow up #6016. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: When deleting a team a user is redirected back to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I was torn re where to redirect and was looking forward to your input. It can be a bit disorienting to delete a team and then suddenly seeing another settings page, so I agree with redirecting back to /workspaces. |
||
</PageWithSubMenu> | ||
|
||
<ConfirmationModal | ||
title="Delete Team" | ||
areYouSureText="You are about to permanently delete this team including all associated data with this team." | ||
buttonText="Delete Team" | ||
buttonDisabled={teamSlug !== team!.slug} | ||
visible={modal} | ||
warningText="Warning: This action cannot be reversed." | ||
onClose={close} | ||
onConfirm={deleteTeam} | ||
> | ||
<ol className="text-gray-500 text-m list-outside list-decimal"> | ||
<li className="ml-5">All <b>projects</b> added in this team will be deleted and cannot be restored afterwards.</li> | ||
<li className="ml-5">All <b>workspaces</b> opened for projects within this team will be deleted for all team members and cannot be restored afterwards.</li> | ||
<li className="ml-5">All <b>members</b> of this team will lose access to this team, associated projects and workspaces.</li> | ||
</ol> | ||
<p className="pt-4 pb-2 text-gray-600 dark:text-gray-400 text-base font-semibold">Type your team's URL slug to confirm</p> | ||
<input className="w-full" type="text" onChange={e => setTeamSlug(e.target.value)}></input> | ||
</ConfirmationModal> | ||
</> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) 2021 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License-AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import {MigrationInterface, QueryRunner} from "typeorm"; | ||
import { columnExists } from "./helper/helper"; | ||
|
||
export class AddMarkedDeletedToTeam1632908105486 implements MigrationInterface { | ||
|
||
public async up(queryRunner: QueryRunner): Promise<any> { | ||
if (!(await columnExists(queryRunner, "d_b_team", "markedDeleted"))) { | ||
await queryRunner.query("ALTER TABLE d_b_team ADD COLUMN `markedDeleted` tinyint(4) NOT NULL DEFAULT '0'"); | ||
} | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<any> { | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: This returns an error in console and so feedback to the user when they are have member permissions, not owner permission, which also lacks visual feedback for the user. Hiding the project settings page for members (non-owners) could resolve this issue. WDYT? ❓