mirror of https://github.com/vector-im/riot-web
don't force height if the height can't change (no children edge)
parent
bc87dc3c56
commit
880dc26847
|
@ -24,11 +24,14 @@ limitations under the License.
|
|||
|
||||
.mx_LeaveSpaceDialog {
|
||||
width: 440px;
|
||||
height: 500px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
|
||||
&.mx_LeaveSpaceDialog_hasChildren {
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
.mx_Dialog_content {
|
||||
flex-grow: 1;
|
||||
margin: 0 0 24px;
|
||||
|
|
|
@ -27,6 +27,7 @@ import AutoHideScrollbar from "../../structures/AutoHideScrollbar";
|
|||
import { Entry } from "./AddExistingToSpaceDialog";
|
||||
import SearchBox from "../../structures/SearchBox";
|
||||
import QueryMatcher from "../../../autocomplete/QueryMatcher";
|
||||
import classNames from "classnames";
|
||||
|
||||
enum RoomsToLeave {
|
||||
All = "All",
|
||||
|
@ -78,9 +79,8 @@ const SpaceChildPicker = ({ filterPlaceholder, rooms, selected, onChange }) => {
|
|||
</div>;
|
||||
};
|
||||
|
||||
const LeaveRoomsPicker = ({ space, roomsToLeave, setRoomsToLeave }) => {
|
||||
const LeaveRoomsPicker = ({ space, spaceChildren, roomsToLeave, setRoomsToLeave }) => {
|
||||
const selected = useMemo(() => new Set(roomsToLeave), [roomsToLeave]);
|
||||
const spaceChildren = useMemo(() => SpaceStore.instance.getChildren(space.roomId), [space.roomId]);
|
||||
const [state, setState] = useState<RoomsToLeave>(RoomsToLeave.All);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -108,10 +108,6 @@ const LeaveRoomsPicker = ({ space, roomsToLeave, setRoomsToLeave }) => {
|
|||
break;
|
||||
}
|
||||
|
||||
if (spaceChildren.length < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <div className="mx_LeaveSpaceDialog_section">
|
||||
<Dropdown
|
||||
id="mx_LeaveSpaceDialog_leaveRoomPickerDropdown"
|
||||
|
@ -160,6 +156,7 @@ const isOnlyAdmin = (room: Room): boolean => {
|
|||
};
|
||||
|
||||
const LeaveSpaceDialog: React.FC<IProps> = ({ space, onFinished }) => {
|
||||
const spaceChildren = useMemo(() => SpaceStore.instance.getChildren(space.roomId), [space.roomId]);
|
||||
const [roomsToLeave, setRoomsToLeave] = useState<Room[]>([]);
|
||||
|
||||
let rejoinWarning;
|
||||
|
@ -181,7 +178,9 @@ const LeaveSpaceDialog: React.FC<IProps> = ({ space, onFinished }) => {
|
|||
|
||||
return <BaseDialog
|
||||
title={_t("Leave %(spaceName)s", { spaceName: space.name })}
|
||||
className="mx_LeaveSpaceDialog"
|
||||
className={classNames("mx_LeaveSpaceDialog", {
|
||||
mx_LeaveSpaceDialog_hasChildren: spaceChildren.length > 0,
|
||||
})}
|
||||
contentId="mx_LeaveSpaceDialog"
|
||||
onFinished={() => onFinished(false)}
|
||||
fixedWidth={false}
|
||||
|
@ -195,7 +194,12 @@ const LeaveSpaceDialog: React.FC<IProps> = ({ space, onFinished }) => {
|
|||
{ rejoinWarning }
|
||||
</p>
|
||||
|
||||
<LeaveRoomsPicker space={space} roomsToLeave={roomsToLeave} setRoomsToLeave={setRoomsToLeave} />
|
||||
{ spaceChildren.length > 0 && <LeaveRoomsPicker
|
||||
space={space}
|
||||
spaceChildren={spaceChildren}
|
||||
roomsToLeave={roomsToLeave}
|
||||
setRoomsToLeave={setRoomsToLeave}
|
||||
/> }
|
||||
|
||||
{ onlyAdminWarning && <div className="mx_LeaveSpaceDialog_section_warning">
|
||||
{ onlyAdminWarning }
|
||||
|
|
Loading…
Reference in New Issue