Skip to content

Commit 0b60d7e

Browse files
committed
fix #8426 -- make it easy to remove myself from all matching projects
1 parent c2ecdea commit 0b60d7e

File tree

3 files changed

+48
-9
lines changed

3 files changed

+48
-9
lines changed

src/packages/frontend/collaborators/current-collabs.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export const CurrentCollaboratorsPanel: React.FC<Props> = (props: Props) => {
4040
const project_id = project.get("project_id");
4141
redux.getActions("projects").remove_collaborator(project_id, account_id);
4242
if (account_id === get_account_id()) {
43-
return (redux.getActions("page") as any).close_project_tab(project_id); // TODO: better types
43+
(redux.getActions("page") as any).close_project_tab(project_id);
44+
// TODO: better types
4445
}
4546
}
4647

src/packages/frontend/projects/project-list-desc.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
import { Gap, Icon } from "@cocalc/frontend/components";
2121
import { labels } from "@cocalc/frontend/i18n";
2222
import { plural } from "@cocalc/util/misc";
23+
import RemoveMyself from "./remove-myself";
2324

2425
interface Props {
2526
visible_projects: string[];
@@ -92,16 +93,16 @@ export const ProjectsListingDescription: React.FC<Props> = ({
9293
}
9394

9495
function render_projects_actions_toolbar(): React.JSX.Element {
96+
if (visible_projects.length == 0) {
97+
return null;
98+
}
9599
return (
96100
<ButtonGroup style={{ margin: "15px" }}>
97-
{visible_projects.length > 0 && !deleted
98-
? render_delete_all_button()
99-
: undefined}
100-
{visible_projects.length > 0 && !hidden
101-
? render_hide_all_button()
102-
: undefined}
103-
{visible_projects.length > 0 ? render_stop_all_button() : undefined}
104-
{visible_projects.length > 0 ? render_restart_all_button() : undefined}
101+
{!deleted ? render_delete_all_button() : undefined}
102+
{!hidden ? render_hide_all_button() : undefined}
103+
{render_stop_all_button()}
104+
{render_restart_all_button()}
105+
<RemoveMyself project_ids={visible_projects} />
105106
</ButtonGroup>
106107
);
107108
}
@@ -195,6 +196,8 @@ export const ProjectsListingDescription: React.FC<Props> = ({
195196
);
196197
}
197198

199+
function renderRemoveMyself() {}
200+
198201
function render_hide_all(): React.JSX.Element | undefined {
199202
if (visible_projects.length === 0) {
200203
return;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Button, Popconfirm } from "antd";
2+
import { plural } from "@cocalc/util/misc";
3+
import { redux, useTypedRedux } from "@cocalc/frontend/app-framework";
4+
5+
export default function RemoveMyself({ project_ids }) {
6+
const account_id = useTypedRedux("account", "account_id");
7+
8+
return (
9+
<Popconfirm
10+
title="Remove myself from projects"
11+
description={
12+
<div style={{ maxWidth: "400px" }}>
13+
Are you sure to remove yourself from up to {project_ids.length}{" "}
14+
{plural(project_ids.length, "project")}? You will no longer have
15+
access and cannot add yourself back.{" "}
16+
<b>You will not be removed from projects you own.</b>
17+
</div>
18+
}
19+
onConfirm={() => {
20+
const projects = redux.getActions("projects");
21+
const page = redux.getActions("page");
22+
for (const project_id of project_ids) {
23+
try {
24+
projects.remove_collaborator(project_id, account_id);
25+
page.close_project_tab(project_id);
26+
} catch {}
27+
}
28+
}}
29+
okText="Yes"
30+
cancelText="No"
31+
>
32+
<Button>Remove Myself...</Button>
33+
</Popconfirm>
34+
);
35+
}

0 commit comments

Comments
 (0)