added condition for select session
This commit is contained in:
parent
5e8b8a2981
commit
b77e10bfec
@ -9,12 +9,11 @@ const DisableUserDialog = ({
|
||||
t,
|
||||
visible,
|
||||
onClose,
|
||||
userIds,
|
||||
isLoading,
|
||||
fetchData,
|
||||
selection,
|
||||
updateUserStatus,
|
||||
}) => {
|
||||
const userIds = selection.map((user) => user.id);
|
||||
const onlyOneUser = userIds.length === 1;
|
||||
|
||||
let headerText = "";
|
||||
|
@ -35,7 +35,7 @@ import ModalDialogContainer from "../ModalDialogContainer";
|
||||
|
||||
const LogoutAllSessionDialog = ({
|
||||
t,
|
||||
selection,
|
||||
exceptId,
|
||||
displayName,
|
||||
visible,
|
||||
isLoading,
|
||||
@ -55,7 +55,6 @@ const LogoutAllSessionDialog = ({
|
||||
};
|
||||
|
||||
const onClickLogout = () => {
|
||||
const exceptId = selection[0]?.connections[0]?.id;
|
||||
if (!isChecked) {
|
||||
onLogoutAllSessions(t);
|
||||
onClose();
|
||||
|
@ -83,6 +83,7 @@ const Sessions = ({
|
||||
updateAllSessions,
|
||||
platformData,
|
||||
selection,
|
||||
bufferSelection,
|
||||
fetchData,
|
||||
isLoading,
|
||||
viewAs,
|
||||
@ -131,6 +132,25 @@ const Sessions = ({
|
||||
currentDeviceType,
|
||||
});
|
||||
|
||||
const getIdFromConnections = (connections) => connections?.[0]?.id;
|
||||
|
||||
const idFromSelection =
|
||||
selection.length > 0
|
||||
? getIdFromConnections(selection[0].connections)
|
||||
: undefined;
|
||||
|
||||
const idFromBufferSelection = bufferSelection
|
||||
? getIdFromConnections(bufferSelection.connections)
|
||||
: undefined;
|
||||
|
||||
const exceptId = idFromSelection || idFromBufferSelection;
|
||||
const userIdsFromSelection = selection.map((user) => user.id);
|
||||
|
||||
const userIds =
|
||||
bufferSelection?.id !== undefined
|
||||
? [bufferSelection.id, ...userIdsFromSelection]
|
||||
: [...userIdsFromSelection];
|
||||
|
||||
// console.log("allSessions", JSON.parse(JSON.stringify(allSessions)));
|
||||
// console.log("sessionsData", JSON.parse(JSON.stringify(sessionsData)));
|
||||
// console.log("connections", JSON.parse(JSON.stringify(connections)));
|
||||
@ -163,7 +183,7 @@ const Sessions = ({
|
||||
visible={disableDialogVisible}
|
||||
onClose={() => setDisableDialogVisible(false)}
|
||||
fetchData={fetchData}
|
||||
selection={selection}
|
||||
userIds={userIds}
|
||||
updateUserStatus={updateUserStatus}
|
||||
/>
|
||||
)}
|
||||
@ -184,7 +204,7 @@ const Sessions = ({
|
||||
t={t}
|
||||
visible={logoutAllDialogVisible}
|
||||
isLoading={isLoading}
|
||||
selection={selection}
|
||||
exceptId={exceptId}
|
||||
displayName={displayName}
|
||||
onClose={() => setLogoutAllDialogVisible(false)}
|
||||
onLogoutAllSessions={onClickLogoutAllSessions}
|
||||
@ -209,6 +229,7 @@ export default inject(({ settingsStore, setup, peopleStore }) => {
|
||||
platformData,
|
||||
fetchData,
|
||||
selection,
|
||||
bufferSelection,
|
||||
isLoading,
|
||||
onClickLogoutAllSessions,
|
||||
onClickLogoutAllExceptThis,
|
||||
@ -236,6 +257,7 @@ export default inject(({ settingsStore, setup, peopleStore }) => {
|
||||
updateAllSessions,
|
||||
platformData,
|
||||
selection,
|
||||
bufferSelection,
|
||||
fetchData,
|
||||
viewAs,
|
||||
setViewAs,
|
||||
|
@ -529,7 +529,18 @@ class SelectionStore {
|
||||
|
||||
onClickLogoutAllSessions = async (t) => {
|
||||
const { removeAllActiveSessionsById } = this.settingsSetupStore;
|
||||
const userId = this.selection[0]?.connections[0]?.userId;
|
||||
|
||||
const userIdFromBufferSelection =
|
||||
this.selection.length > 0 && this.selection[0].connections.length > 0
|
||||
? this.selection[0].connections[0].userId
|
||||
: undefined;
|
||||
|
||||
const userIdFromSelection =
|
||||
this.bufferSelection && this.bufferSelection.connections.length > 0
|
||||
? this.bufferSelection.connections[0].userId
|
||||
: undefined;
|
||||
|
||||
const userId = userIdFromSelection || userIdFromBufferSelection;
|
||||
|
||||
if (!userId) return toastr.error(t("The user is already logged out"));
|
||||
|
||||
@ -549,7 +560,17 @@ class SelectionStore {
|
||||
onClickLogoutAllExceptThis = async (t, id) => {
|
||||
const { removeAllExceptThisEventId } = this.settingsSetupStore;
|
||||
|
||||
const exceptId = this.selection[0]?.connections[0]?.id;
|
||||
const idFromBufferSelection =
|
||||
this.selection.length > 0 && this.selection[0].connections.length > 0
|
||||
? this.selection[0].connections[0].id
|
||||
: undefined;
|
||||
|
||||
const idFromSelection =
|
||||
this.bufferSelection && this.bufferSelection.connections.length > 0
|
||||
? this.bufferSelection.connections[0].id
|
||||
: undefined;
|
||||
|
||||
const exceptId = idFromSelection || idFromBufferSelection;
|
||||
|
||||
if (!exceptId) return toastr.error(t("The user is already logged out"));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user