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) {
onDeleteAllGroups(t);
} else {
onDeleteGroup(t, bufferSelection?.id || selection[0].id);
onDeleteGroup(t, bufferSelection?.id || selection[0]?.id);
}
} catch (err) {
toastr.error(err.message);

View File

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

View File

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