Removing COllection + workspace usage
This commit is contained in:
@@ -3,7 +3,7 @@ import './parameters.scss';
|
|||||||
|
|
||||||
export default (props: { label: string; description: string; children: ReactNode }) => {
|
export default (props: { label: string; description: string; children: ReactNode }) => {
|
||||||
return (
|
return (
|
||||||
<div className={'parameters_attribute open'}>
|
<div className={'parameters_attribute open block'}>
|
||||||
<div className="label">
|
<div className="label">
|
||||||
<div className="label">{props.label}</div>
|
<div className="label">{props.label}</div>
|
||||||
<div className="description">{props.description}</div>
|
<div className="description">{props.description}</div>
|
||||||
|
|||||||
@@ -47,7 +47,6 @@
|
|||||||
|
|
||||||
& > .value {
|
& > .value {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
max-height: 0;
|
|
||||||
transition: max-height 0.2s, opacity 0.2s;
|
transition: max-height 0.2s, opacity 0.2s;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
|||||||
@@ -39,36 +39,7 @@ class Workspaces extends Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateCurrentWorkspaceId(workspaceId, notify = false) {
|
updateCurrentWorkspaceId(workspaceId, notify = false) {
|
||||||
if (this.currentWorkspaceId !== workspaceId && workspaceId) {
|
|
||||||
const workspace = DepreciatedCollections.get('workspaces').find(workspaceId);
|
|
||||||
if (!workspace) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentWorkspaceId = workspaceId;
|
|
||||||
this.currentWorkspaceIdByGroup[workspace.company_id] = workspaceId;
|
|
||||||
|
|
||||||
if (!this.getting_details[workspaceId]) {
|
|
||||||
this.getting_details[workspaceId] = true;
|
|
||||||
|
|
||||||
WorkspaceAPIClient.get(workspace.company_id, workspaceId)
|
|
||||||
.then(workspace => {
|
|
||||||
if (!workspace) {
|
|
||||||
this.removeFromUser(workspaceId);
|
|
||||||
}
|
|
||||||
DepreciatedCollections.get('workspaces').updateObject(workspace);
|
|
||||||
notify && this.notify();
|
|
||||||
|
|
||||||
// FIXME: What is this???
|
|
||||||
setTimeout(() => {
|
|
||||||
this.getting_details[workspaceId] = false;
|
|
||||||
}, 10000);
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.removeFromUser(workspaceId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCurrentCompanyId(companyId, notify = false) {
|
updateCurrentCompanyId(companyId, notify = false) {
|
||||||
@@ -224,10 +195,7 @@ class Workspaces extends Observable {
|
|||||||
name,
|
name,
|
||||||
});
|
});
|
||||||
this.logger.debug('Workspace updated', result);
|
this.logger.debug('Workspace updated', result);
|
||||||
DepreciatedCollections.get('workspaces').updateObject({
|
|
||||||
id: this.currentWorkspaceId,
|
|
||||||
name,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error('Can not update the workspace', err);
|
this.logger.error('Can not update the workspace', err);
|
||||||
}
|
}
|
||||||
@@ -272,7 +240,6 @@ class Workspaces extends Observable {
|
|||||||
that.notify();
|
that.notify();
|
||||||
} else {
|
} else {
|
||||||
var update = resp.data;
|
var update = resp.data;
|
||||||
DepreciatedCollections.get('workspaces').updateObject(update);
|
|
||||||
ws.publish('workspace/' + update.id, { workspace: update });
|
ws.publish('workspace/' + update.id, { workspace: update });
|
||||||
that.notify();
|
that.notify();
|
||||||
}
|
}
|
||||||
@@ -296,10 +263,6 @@ class Workspaces extends Observable {
|
|||||||
}
|
}
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentWorkspace() {
|
|
||||||
return DepreciatedCollections.get('workspaces').find(this.currentWorkspaceId) || {};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Workspaces();
|
export default new Workspaces();
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export const onChangeCompanyApplications = (companyId: string, _applications: Ap
|
|||||||
(applications || []).forEach(a => {
|
(applications || []).forEach(a => {
|
||||||
if (!_.isEqual(a, companyApplicationMap.get(a.id))) {
|
if (!_.isEqual(a, companyApplicationMap.get(a.id))) {
|
||||||
companyApplicationMap.set(a.id, a);
|
companyApplicationMap.set(a.id, a);
|
||||||
Collections.get('applications').updateObject(a);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ export const CompaniesState = atomFamily<CompanyType | null, string>({
|
|||||||
onSet(company => {
|
onSet(company => {
|
||||||
if (company?.id) {
|
if (company?.id) {
|
||||||
companies[company.id] = company;
|
companies[company.id] = company;
|
||||||
Collections.get('groups').updateObject(_.cloneDeep(company));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-147
@@ -54,35 +54,13 @@ class WorkspacesUsers extends Observable {
|
|||||||
(Globals.window as any).workspaceUserService = this;
|
(Globals.window as any).workspaceUserService = this;
|
||||||
}
|
}
|
||||||
getAdminLevel(idWorkspace = workspaceService.currentWorkspaceId) {
|
getAdminLevel(idWorkspace = workspaceService.currentWorkspaceId) {
|
||||||
const levels = Collections.get('workspaces').find(idWorkspace).levels;
|
|
||||||
if (levels) {
|
|
||||||
for (let i = 0; i < levels.length; i++) {
|
|
||||||
if (levels[i].admin) {
|
|
||||||
return levels[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
getDefaultLevel(idWorkspace = workspaceService.currentWorkspaceId) {
|
getDefaultLevel(idWorkspace = workspaceService.currentWorkspaceId) {
|
||||||
const levels = Collections.get('workspaces').find(idWorkspace).levels;
|
|
||||||
if (levels) {
|
|
||||||
for (let i = 0; i < levels.length; i++) {
|
|
||||||
if (levels[i].default) {
|
|
||||||
return levels[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
isGroupManager() {}
|
isGroupManager() {}
|
||||||
getLevel(idLevel: string) {
|
getLevel(idLevel: string) {
|
||||||
const levels = Collections.get('workspaces').find(workspaceService.currentWorkspaceId).levels;
|
|
||||||
for (let i = 0; i < levels.length; i++) {
|
|
||||||
if (idLevel === levels[i].id) {
|
|
||||||
return levels[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,109 +72,7 @@ class WorkspacesUsers extends Observable {
|
|||||||
ws.unsubscribe('workspace_users/' + workspace_id, null, null);
|
ws.unsubscribe('workspace_users/' + workspace_id, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
load(workspace_id: string, reset_offset: string, options: any) {
|
load(workspace_id: string, reset_offset: string, options: any) {}
|
||||||
if (!options) {
|
|
||||||
options = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const that = this;
|
|
||||||
const workspace = Collections.get('workspaces').find(workspace_id);
|
|
||||||
if (!workspace) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const group_id = workspace?.group?.id || workspace.company_id;
|
|
||||||
|
|
||||||
if (!this.users_by_group[group_id]) {
|
|
||||||
this.users_by_group[group_id] = {};
|
|
||||||
}
|
|
||||||
if (!this.users_by_workspace[workspace_id]) {
|
|
||||||
this.users_by_workspace[workspace_id] = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.offset_by_workspace_id[workspace_id] || reset_offset) {
|
|
||||||
this.offset_by_workspace_id[workspace_id] = [0, false];
|
|
||||||
}
|
|
||||||
if (!this.offset_by_group_id[group_id] || reset_offset) {
|
|
||||||
this.offset_by_group_id[group_id] = [0, false];
|
|
||||||
}
|
|
||||||
|
|
||||||
const loadMembers = (data: any) => {
|
|
||||||
if (!data) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (typeof data.members === 'object' && data.members.members) {
|
|
||||||
data = data.members;
|
|
||||||
}
|
|
||||||
if (data.members) {
|
|
||||||
(data.members || []).forEach((item: any) => {
|
|
||||||
if (
|
|
||||||
!that.offset_by_workspace_id[workspace_id][1] ||
|
|
||||||
Numbers.compareTimeuuid(item.user.id, that.offset_by_workspace_id[workspace_id][1]) > 0
|
|
||||||
) {
|
|
||||||
that.offset_by_workspace_id[workspace_id][1] = item.user.id;
|
|
||||||
}
|
|
||||||
that.offset_by_workspace_id[workspace_id][0]++;
|
|
||||||
|
|
||||||
Collections.get('users').completeObject(item.user, item.user.front_id);
|
|
||||||
|
|
||||||
that.users_by_group[group_id][item.user.id] = item;
|
|
||||||
that.users_by_workspace[workspace_id][item.user.id] = item;
|
|
||||||
});
|
|
||||||
that.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.mails) {
|
|
||||||
that.membersPending = data.mails || [];
|
|
||||||
that.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.stats.total_members > 1 && WorkspaceUserRights.hasWorkspacePrivilege()) {
|
|
||||||
CurrentUser.updateTutorialStatus('did_invite_collaborators');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const data = {
|
|
||||||
workspaceId: workspace_id,
|
|
||||||
max: this.offset_by_workspace_id[workspace_id][0] === 0 ? 100 : 40,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (options.members) {
|
|
||||||
loadMembers(options.members || []);
|
|
||||||
} else {
|
|
||||||
Api.post('/ajax/workspace/members/list', data, (res: any) => {
|
|
||||||
if (res.data) {
|
|
||||||
loadMembers({ members: res.data });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Api.post('/ajax/workspace/members/pending', data, (res: any) => {
|
|
||||||
if (res.data) {
|
|
||||||
loadMembers({ mails: res.data });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
loadMembers(options.members || []);
|
|
||||||
}
|
|
||||||
|
|
||||||
const loadGroupUsers = (data: any) => {
|
|
||||||
data.users.forEach((item: any) => {
|
|
||||||
if (
|
|
||||||
!that.offset_by_group_id[group_id][1] ||
|
|
||||||
Numbers.compareTimeuuid(item.user.id, that.offset_by_group_id[group_id][1]) > 0
|
|
||||||
) {
|
|
||||||
that.offset_by_group_id[group_id][1] = item.user.id;
|
|
||||||
}
|
|
||||||
that.offset_by_group_id[group_id][0]++;
|
|
||||||
|
|
||||||
Collections.get('users').completeObject(item.user, item.user.front_id);
|
|
||||||
|
|
||||||
that.users_by_group[group_id][item.user.id] = item;
|
|
||||||
});
|
|
||||||
that.notify();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (options.group_users) {
|
|
||||||
loadMembers(options.group_users);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
canShowUserInWorkspaceList(member: any) {
|
canShowUserInWorkspaceList(member: any) {
|
||||||
// if user is interne or wexterne => no restriction
|
// if user is interne or wexterne => no restriction
|
||||||
if (!WorkspaceUserRights.isInvite()) {
|
if (!WorkspaceUserRights.isInvite()) {
|
||||||
@@ -206,28 +82,6 @@ class WorkspacesUsers extends Observable {
|
|||||||
// if other user is interne or wexterne
|
// if other user is interne or wexterne
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check in all channel if 2 chavite are in the same channel
|
|
||||||
const channelsInWorkspace = Collections.get('channels').findBy({
|
|
||||||
direct: false,
|
|
||||||
application: false,
|
|
||||||
original_workspace: workspaceService.currentWorkspaceId,
|
|
||||||
});
|
|
||||||
for (let i = 0; i < channelsInWorkspace.length; i++) {
|
|
||||||
// check in all channel if 2 chavite are in the same channel
|
|
||||||
if (channelsInWorkspace[i].ext_members) {
|
|
||||||
let bothAreInChannel = 0; // if 1 : one of 2 users searched is in channel as chavite, 2 : both are in channel as chavite
|
|
||||||
const extMembers = channelsInWorkspace[i].ext_members;
|
|
||||||
for (let j = 0; j < extMembers.length; j++) {
|
|
||||||
if (extMembers[j] === member || extMembers[j] === CurrentUser.get().id) {
|
|
||||||
bothAreInChannel++;
|
|
||||||
if (bothAreInChannel >= 2) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,13 +44,6 @@ export const useWorkspacesCommons = (companyId = '') => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Retro compatibility
|
|
||||||
workspaces?.forEach(w => {
|
|
||||||
Collections.get('workspaces').updateObject(_.cloneDeep(w));
|
|
||||||
AccessRightsService.updateLevel(w.id, w.role as RightsOrNone);
|
|
||||||
});
|
|
||||||
//End
|
|
||||||
|
|
||||||
return { workspaces, loading, refresh };
|
return { workspaces, loading, refresh };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ export const WorkspaceListStateFamily = atomFamily<WorkspaceType[], string>({
|
|||||||
({ onSet }) => {
|
({ onSet }) => {
|
||||||
onSet(workspaces => {
|
onSet(workspaces => {
|
||||||
workspacesCompanyMap[companyId] = workspaces;
|
workspacesCompanyMap[companyId] = workspaces;
|
||||||
workspaces.map(w => {
|
|
||||||
Collections.get('workspaces').updateObject(_.cloneDeep(w));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user