Fix Bug 69503: Can't remove opened group

This commit is contained in:
Aleksandr Lushkin 2024-08-01 15:47:36 +02:00
parent 285997a8ab
commit 915fbac03e
3 changed files with 17 additions and 4 deletions

View File

@ -66,7 +66,7 @@ const DeleteGroupDialog = (props) => {
if (hasMoreGroups) { if (hasMoreGroups) {
onDeleteAllGroups(t); onDeleteAllGroups(t);
} else { } else {
onDeleteGroup(t, bufferSelection?.id || selection[0].id); onDeleteGroup(t, bufferSelection?.id || selection[0]?.id);
} }
} catch (err) { } catch (err) {
toastr.error(err.message); toastr.error(err.message);

View File

@ -224,6 +224,7 @@ const SectionHeaderContent = (props) => {
onEmptyTrashAction, onEmptyTrashAction,
getHeaderOptions, getHeaderOptions,
setBufferSelection, setBufferSelection,
setGroupsBufferSelection,
} = props; } = props;
const location = useLocation(); const location = useLocation();
@ -259,9 +260,9 @@ const SectionHeaderContent = (props) => {
}; };
const onContextOptionsClick = () => { const onContextOptionsClick = () => {
if (isInsideGroup) return; isInsideGroup
? setGroupsBufferSelection(currentGroup)
setBufferSelection(selectedFolder); : setBufferSelection(selectedFolder);
}; };
const onSelect = (e) => { const onSelect = (e) => {
@ -657,6 +658,7 @@ export default inject(
currentGroup, currentGroup,
getGroupContextOptions, getGroupContextOptions,
setSelected: setGroupsSelected, setSelected: setGroupsSelected,
setBufferSelection: setGroupsBufferSelection,
insideGroupTempTitle, insideGroupTempTitle,
} = peopleStore.groupsStore; } = peopleStore.groupsStore;
@ -799,6 +801,7 @@ export default inject(
onEmptyTrashAction, onEmptyTrashAction,
getHeaderOptions, getHeaderOptions,
setBufferSelection, setBufferSelection,
setGroupsBufferSelection,
}; };
}, },
)( )(

View File

@ -432,6 +432,10 @@ class GroupsStore {
}; };
onDeleteGroup = async (t, groupId) => { onDeleteGroup = async (t, groupId) => {
const { getIsInsideGroup, setInfoPanelSelectedGroup } = this.infoPanelStore;
const isDeletingCurrentGroup =
getIsInsideGroup() && this.currentGroup?.id === groupId;
this.setIsLoading(true); this.setIsLoading(true);
if (!groupId) { if (!groupId) {
@ -447,6 +451,12 @@ class GroupsStore {
this.infoPanelStore.setInfoPanelSelection(null); this.infoPanelStore.setInfoPanelSelection(null);
this.setIsLoading(false); this.setIsLoading(false);
this.peopleStore.dialogStore.setDeleteGroupDialogVisible(false); this.peopleStore.dialogStore.setDeleteGroupDialogVisible(false);
if (isDeletingCurrentGroup) {
setInfoPanelSelectedGroup(null);
this.setBufferSelection(null);
window.DocSpace.navigate(`accounts/groups`);
}
} catch (err) { } catch (err) {
toastr.error(err.message); toastr.error(err.message);
console.error(err); console.error(err);