Skip to content

Commit bd5e19b

Browse files
committed
frontend -- implement account customize: disableCollaborators
1 parent 64fae61 commit bd5e19b

File tree

4 files changed

+49
-16
lines changed

4 files changed

+49
-16
lines changed

src/packages/frontend/account/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ export interface AccountState {
3636
name?: string;
3737
unlisted?: boolean;
3838
profile: TypedMap<{ color: string }>;
39+
customize?: {
40+
disableCollaborators?: boolean;
41+
disableAI?: boolean;
42+
[key: string]: any;
43+
};
3944
email_address?: string;
4045
editor_settings: TypedMap<{
4146
jupyter_classic?: boolean;

src/packages/frontend/collaborators/add-collaborators.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export const AddCollaborators: React.FC<Props> = ({
9595
);
9696
const isFlyout = mode === "flyout";
9797
const student = useStudentProjectFunctionality(project_id);
98+
const accountCustomize = useTypedRedux("account", "customize")?.toJS() as
99+
| { disableCollaborators?: boolean }
100+
| undefined;
98101
const user_map = useTypedRedux("users", "user_map");
99102
const project_map = useTypedRedux("projects", "project_map");
100103
const project: Project | undefined = useMemo(
@@ -684,7 +687,7 @@ export const AddCollaborators: React.FC<Props> = ({
684687
);
685688
}
686689

687-
if (student.disableCollaborators) {
690+
if (student.disableCollaborators || accountCustomize?.disableCollaborators) {
688691
return <div></div>;
689692
}
690693

src/packages/frontend/project/page/flyouts/collabs.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
CurrentCollaboratorsPanel,
1111
} from "@cocalc/frontend/collaborators";
1212
import { Icon, Loading, Paragraph, Title } from "@cocalc/frontend/components";
13+
import { Alert } from "antd";
1314
import { getStudentProjectFunctionality } from "@cocalc/frontend/course";
1415
import { labels } from "@cocalc/frontend/i18n";
1516
import { useProject } from "../common";
@@ -26,23 +27,34 @@ export function CollabsFlyout({
2627
}: CollabsProps): React.JSX.Element {
2728
const intl = useIntl();
2829
const user_map = useTypedRedux("users", "user_map");
30+
const accountCustomize = useTypedRedux("account", "customize")?.toJS() as
31+
| { disableCollaborators?: boolean }
32+
| undefined;
2933
const student = getStudentProjectFunctionality(project_id);
3034
const { project, group } = useProject(project_id);
35+
const disableCollaborators =
36+
accountCustomize?.disableCollaborators || student.disableCollaborators;
3137

3238
function renderSettings() {
3339
if (project == null) {
3440
return <Loading theme="medium" transparent />;
3541
}
3642
return wrap(
3743
<>
38-
<CurrentCollaboratorsPanel
39-
key="current-collabs"
40-
project={project}
41-
user_map={user_map}
42-
mode="flyout"
43-
/>
44-
{!student.disableCollaborators && (
44+
{disableCollaborators ? (
45+
<Alert
46+
type="warning"
47+
showIcon
48+
message="Collaborator configuration is disabled."
49+
/>
50+
) : (
4551
<>
52+
<CurrentCollaboratorsPanel
53+
key="current-collabs"
54+
project={project}
55+
user_map={user_map}
56+
mode="flyout"
57+
/>
4658
<br />
4759
<Title level={3}>
4860
<Icon name="UserAddOutlined" /> Add New Collaborators

src/packages/frontend/project/page/project-collaborators.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
SettingBox,
1818
Title,
1919
} from "@cocalc/frontend/components";
20+
import { Alert } from "antd";
2021
import { getStudentProjectFunctionality } from "@cocalc/frontend/course";
2122
import { labels } from "@cocalc/frontend/i18n";
2223
import { useProjectContext } from "@cocalc/frontend/project/context";
@@ -28,28 +29,40 @@ export function ProjectCollaboratorsPage(): React.JSX.Element {
2829
const intl = useIntl();
2930
const { project_id } = useProjectContext();
3031
const user_map = useTypedRedux("users", "user_map");
32+
const accountCustomize = useTypedRedux("account", "customize")?.toJS() as
33+
| { disableCollaborators?: boolean }
34+
| undefined;
3135
const student = getStudentProjectFunctionality(project_id);
3236
const { project, group } = useProject(project_id);
37+
const disableCollaborators =
38+
accountCustomize?.disableCollaborators || student.disableCollaborators;
3339

3440
function renderSettings() {
3541
if (project == null) {
3642
return <Loading theme="medium" />;
3743
}
44+
if (disableCollaborators) {
45+
return (
46+
<Alert
47+
type="warning"
48+
showIcon
49+
message="Collaborator configuration is disabled."
50+
/>
51+
);
52+
}
3853
return (
3954
<>
4055
<CurrentCollaboratorsPanel
4156
key="current-collabs"
4257
project={project}
4358
user_map={user_map}
4459
/>
45-
{!student.disableCollaborators && (
46-
<SettingBox title="Add New Collaborators" icon="UserAddOutlined">
47-
<AddCollaborators
48-
project_id={project.get("project_id")}
49-
where="project-settings"
50-
/>
51-
</SettingBox>
52-
)}
60+
<SettingBox title="Add New Collaborators" icon="UserAddOutlined">
61+
<AddCollaborators
62+
project_id={project.get("project_id")}
63+
where="project-settings"
64+
/>
65+
</SettingBox>
5366
</>
5467
);
5568
}

0 commit comments

Comments
 (0)