added condition for select session

This commit is contained in:
Elyor Djalilov 2024-06-14 17:46:44 +05:00
parent 5e8b8a2981
commit b77e10bfec
4 changed files with 49 additions and 8 deletions

View File

@ -9,12 +9,11 @@ const DisableUserDialog = ({
t, t,
visible, visible,
onClose, onClose,
userIds,
isLoading, isLoading,
fetchData, fetchData,
selection,
updateUserStatus, updateUserStatus,
}) => { }) => {
const userIds = selection.map((user) => user.id);
const onlyOneUser = userIds.length === 1; const onlyOneUser = userIds.length === 1;
let headerText = ""; let headerText = "";

View File

@ -35,7 +35,7 @@ import ModalDialogContainer from "../ModalDialogContainer";
const LogoutAllSessionDialog = ({ const LogoutAllSessionDialog = ({
t, t,
selection, exceptId,
displayName, displayName,
visible, visible,
isLoading, isLoading,
@ -55,7 +55,6 @@ const LogoutAllSessionDialog = ({
}; };
const onClickLogout = () => { const onClickLogout = () => {
const exceptId = selection[0]?.connections[0]?.id;
if (!isChecked) { if (!isChecked) {
onLogoutAllSessions(t); onLogoutAllSessions(t);
onClose(); onClose();

View File

@ -83,6 +83,7 @@ const Sessions = ({
updateAllSessions, updateAllSessions,
platformData, platformData,
selection, selection,
bufferSelection,
fetchData, fetchData,
isLoading, isLoading,
viewAs, viewAs,
@ -131,6 +132,25 @@ const Sessions = ({
currentDeviceType, 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("allSessions", JSON.parse(JSON.stringify(allSessions)));
// console.log("sessionsData", JSON.parse(JSON.stringify(sessionsData))); // console.log("sessionsData", JSON.parse(JSON.stringify(sessionsData)));
// console.log("connections", JSON.parse(JSON.stringify(connections))); // console.log("connections", JSON.parse(JSON.stringify(connections)));
@ -163,7 +183,7 @@ const Sessions = ({
visible={disableDialogVisible} visible={disableDialogVisible}
onClose={() => setDisableDialogVisible(false)} onClose={() => setDisableDialogVisible(false)}
fetchData={fetchData} fetchData={fetchData}
selection={selection} userIds={userIds}
updateUserStatus={updateUserStatus} updateUserStatus={updateUserStatus}
/> />
)} )}
@ -184,7 +204,7 @@ const Sessions = ({
t={t} t={t}
visible={logoutAllDialogVisible} visible={logoutAllDialogVisible}
isLoading={isLoading} isLoading={isLoading}
selection={selection} exceptId={exceptId}
displayName={displayName} displayName={displayName}
onClose={() => setLogoutAllDialogVisible(false)} onClose={() => setLogoutAllDialogVisible(false)}
onLogoutAllSessions={onClickLogoutAllSessions} onLogoutAllSessions={onClickLogoutAllSessions}
@ -209,6 +229,7 @@ export default inject(({ settingsStore, setup, peopleStore }) => {
platformData, platformData,
fetchData, fetchData,
selection, selection,
bufferSelection,
isLoading, isLoading,
onClickLogoutAllSessions, onClickLogoutAllSessions,
onClickLogoutAllExceptThis, onClickLogoutAllExceptThis,
@ -236,6 +257,7 @@ export default inject(({ settingsStore, setup, peopleStore }) => {
updateAllSessions, updateAllSessions,
platformData, platformData,
selection, selection,
bufferSelection,
fetchData, fetchData,
viewAs, viewAs,
setViewAs, setViewAs,

View File

@ -529,7 +529,18 @@ class SelectionStore {
onClickLogoutAllSessions = async (t) => { onClickLogoutAllSessions = async (t) => {
const { removeAllActiveSessionsById } = this.settingsSetupStore; 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")); if (!userId) return toastr.error(t("The user is already logged out"));
@ -549,7 +560,17 @@ class SelectionStore {
onClickLogoutAllExceptThis = async (t, id) => { onClickLogoutAllExceptThis = async (t, id) => {
const { removeAllExceptThisEventId } = this.settingsSetupStore; 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")); if (!exceptId) return toastr.error(t("The user is already logged out"));