Skip to content

Commit

Permalink
feat(spaces): remove public spaces and subspaces creation
Browse files Browse the repository at this point in the history
  • Loading branch information
marc.sirisak committed Jul 15, 2024
1 parent 3a78d49 commit 479624d
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ const SpaceLandingAddButton: React.FC<{ space: Room }> = ({ space }) => {
showAddExistingRooms(space);
}}
/>
{canCreateSpace && (
{/* :TCHAP: space-remove-public-and-subspace */}
{/* {canCreateSpace && (
<IconizedContextMenuOption
label={_t("room_list|add_space_label")}
iconClassName="mx_RoomList_iconPlus"
Expand All @@ -186,7 +187,8 @@ const SpaceLandingAddButton: React.FC<{ space: Room }> = ({ space }) => {
>
<BetaPill />
</IconizedContextMenuOption>
)}
)} */}
{/* end :TCHAP: */}
</IconizedContextMenuOptionList>
</IconizedContextMenu>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ const SpaceContextMenu: React.FC<IProps> = ({ space, hideHeader, onFinished, ...
<BetaPill />
</IconizedContextMenuOption>
)}
{canAddSubSpaces && (
{/* :TCHAP: space-remove-public-and-subspace */}
{/* {canAddSubSpaces && (
<IconizedContextMenuOption
data-testid="new-subspace-option"
iconClassName="mx_SpacePanel_iconPlus"
Expand All @@ -202,7 +203,8 @@ const SpaceContextMenu: React.FC<IProps> = ({ space, hideHeader, onFinished, ...
>
<BetaPill />
</IconizedContextMenuOption>
)}
)} */}
{/* end :TCHAP: */}
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ const RoomListHeader: React.FC<IProps> = ({ onVisibilityChange }) => {
disabled={!canAddSubRooms}
title={!canAddSubRooms ? _t("spaces|error_no_permission_add_room") : undefined}
/>
{canCreateSpaces && (
{/* :TCHAP: space-remove-public-and-subspace */}
{/* {canCreateSpaces && (
<IconizedContextMenuOption
label={_t("room_list|add_space_label")}
iconClassName="mx_RoomListHeader_iconPlus"
Expand All @@ -284,7 +285,8 @@ const RoomListHeader: React.FC<IProps> = ({ onVisibilityChange }) => {
>
<BetaPill />
</IconizedContextMenuOption>
)}
)} */}
{/* end :TCHAP: */}
</IconizedContextMenuOptionList>
</IconizedContextMenu>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ const SpaceCreateMenu: React.FC<{
onFinished(): void;
}> = ({ onFinished }) => {
const cli = useMatrixClientContext();
const [visibility, setVisibility] = useState<Visibility | null>(null);
// const [visibility, setVisibility] = useState<Visibility | null>(null);
const [visibility, setVisibility] = useState<Visibility | null>(Visibility.Private); // :TCHAP: space-remove-public-and-subspace
const [busy, setBusy] = useState<boolean>(false);

const [name, setName] = useState("");
Expand Down Expand Up @@ -280,71 +281,109 @@ const SpaceCreateMenu: React.FC<{
};

let body;
if (visibility === null) {
body = (
<React.Fragment>
<h2>{_t("create_space|label")}</h2>
<p>{_t("create_space|explainer")}</p>

<SpaceCreateMenuType
title={_t("common|public")}
description={_t("create_space|public_description")}
className="mx_SpaceCreateMenuType_public"
onClick={() => setVisibility(Visibility.Public)}
/>
<SpaceCreateMenuType
title={_t("common|private")}
description={_t("create_space|private_description")}
className="mx_SpaceCreateMenuType_private"
onClick={() => setVisibility(Visibility.Private)}
/>

{supportsSpaceFiltering && (
<AccessibleButton kind="primary_outline" onClick={onSearchClick}>
{_t("create_space|search_public_button")}
</AccessibleButton>
)}
</React.Fragment>
);
} else {
body = (
<React.Fragment>
<AccessibleButton
className="mx_SpaceCreateMenu_back"
onClick={() => setVisibility(null)}
title={_t("action|go_back")}
/>

<h2>
{visibility === Visibility.Public
? _t("create_space|public_heading")
: _t("create_space|private_heading")}
</h2>
<p>
{_t("create_space|add_details_prompt")} {_t("create_space|add_details_prompt_2")}
</p>

<SpaceCreateForm
busy={busy}
onSubmit={onSpaceCreateClick}
setAvatar={setAvatar}
name={name}
setName={setName}
nameFieldRef={spaceNameField}
topic={topic}
setTopic={setTopic}
alias={alias}
setAlias={setAlias}
showAliasField={visibility === Visibility.Public}
aliasFieldRef={spaceAliasField}
/>
// :TCHAP: space-remove-public-and-subspace
// if (visibility === null) {
// body = (
// <React.Fragment>
// <h2>{_t("create_space|label")}</h2>
// <p>{_t("create_space|explainer")}</p>

// <SpaceCreateMenuType
// title={_t("common|public")}
// description={_t("create_space|public_description")}
// className="mx_SpaceCreateMenuType_public"
// onClick={() => setVisibility(Visibility.Public)}
// />
// <SpaceCreateMenuType
// title={_t("common|private")}
// description={_t("create_space|private_description")}
// className="mx_SpaceCreateMenuType_private"
// onClick={() => setVisibility(Visibility.Private)}
// />

// {supportsSpaceFiltering && (
// <AccessibleButton kind="primary_outline" onClick={onSearchClick}>
// {_t("create_space|search_public_button")}
// </AccessibleButton>
// )}
// </React.Fragment>
// );
// } else {
// body = (
// <React.Fragment>
// <AccessibleButton
// className="mx_SpaceCreateMenu_back"
// onClick={() => setVisibility(null)}
// title={_t("action|go_back")}
// />

// <h2>
// {visibility === Visibility.Public
// ? _t("create_space|public_heading")
// : _t("create_space|private_heading")}
// </h2>
// <p>
// {_t("create_space|add_details_prompt")} {_t("create_space|add_details_prompt_2")}
// </p>

// <SpaceCreateForm
// busy={busy}
// onSubmit={onSpaceCreateClick}
// setAvatar={setAvatar}
// name={name}
// setName={setName}
// nameFieldRef={spaceNameField}
// topic={topic}
// setTopic={setTopic}
// alias={alias}
// setAlias={setAlias}
// showAliasField={visibility === Visibility.Public}
// aliasFieldRef={spaceAliasField}
// />

// <AccessibleButton kind="primary" onClick={onSpaceCreateClick} disabled={busy}>
// {busy ? _t("create_space|creating") : _t("action|create")}
// </AccessibleButton>
// </React.Fragment>
// );
// }
body = (
<React.Fragment>
<h2>
{_t("create_space|private_heading")}
</h2>
<p>
{_t("create_space|add_details_prompt")} {_t("create_space|add_details_prompt_2", {}, {
a: (sub) => (
<AccessibleButton kind="link_inline" onClick={() => {window.open("https://aide.tchap.beta.gouv.fr/","_blank")}}>
{sub}
</AccessibleButton>
),
})
}
</p>

<SpaceCreateForm
busy={busy}
onSubmit={onSpaceCreateClick}
setAvatar={setAvatar}
name={name}
setName={setName}
nameFieldRef={spaceNameField}
topic={topic}
setTopic={setTopic}
alias={alias}
setAlias={setAlias}
showAliasField={visibility === Visibility.Public}
aliasFieldRef={spaceAliasField}
/>

<AccessibleButton kind="primary" onClick={onSpaceCreateClick} disabled={busy}>
{busy ? _t("create_space|creating") : _t("action|create")}
</AccessibleButton>
</React.Fragment>
);
}
<AccessibleButton kind="primary" onClick={onSpaceCreateClick} disabled={busy}>
{busy ? _t("create_space|creating") : _t("action|create")}
</AccessibleButton>
</React.Fragment>
);
// end :TCHAP:

return (
<ContextMenu
Expand Down
8 changes: 8 additions & 0 deletions modules/tchap-translations/tchap_translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -757,5 +757,13 @@
"lasuite_numerique": {
"en": "La suite numérique",
"fr": "La suite numérique"
},
"create_space|add_details_prompt": {
"en": "A space is a dedicated folder in which you can organize your discussions by themes.",
"fr": "Un espace est un dossier privé dans lequel vous pouvez organiser vos conversations par thèmes."
},
"create_space|add_details_prompt_2": {
"en": "<a>Learn more </a>",
"fr": "<a>En savoir plus</a>"
}
}
10 changes: 9 additions & 1 deletion modules/tchap-translations/tchap_translations_removed.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,13 @@
"onboarding|enable_notifications",
"onboarding|enable_notifications_action",
"onboarding|enable_notifications_description",
"onboarding|you_made_it"
"onboarding|you_made_it",
"create_space|search_public_button",
"create_space|private_description",
"create_space|public_description",
"create_space|explainer",
"create_space|public_heading",
"common|private",
"room_list|add_space_label",
"spaces|error_no_permission_add_space"
]
9 changes: 9 additions & 0 deletions patches/subtree-modifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,14 @@
"files": [
"src/components/views/dialogs/InviteDialog.tsx"
]
},
"space-remove-public-and-subspace": {
"issue": "https://github.com/tchapgouv/tchap-web-v4/issues/878",
"files": [
"src/components/views/spaces/SpaceCreateMenu.tsx",
"src/components/views/rooms/RoomListHeader.tsx",
"src/components/views/context_menus/SpaceContextMenu.tsx",
"src/components/structures/SpaceRoomView.tsx"
]
}
}
5 changes: 3 additions & 2 deletions res/themes/tchap-common/css/_tchap_custom.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
}
}

.mx_ThreadsActivityCentreButton .mx_ThreadsActivityCentreButton_Icon {
color: white;
.mx_ThreadsActivityCentreButton .mx_ThreadsActivityCentreButton_Icon,
.mx_ThreadsActivityCentreButton .mx_ThreadsActivityCentreButton_Text {
color: white !important;
}

0 comments on commit 479624d

Please sign in to comment.