@overmap-ai/core 1.0.29-org-switcher-and-bug-fixes.6 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/overmap-core.js +37 -60
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +37 -60
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/classes/OutboxCoordinator.d.ts +1 -0
- package/dist/sdk/services/MainService.d.ts +0 -1
- package/dist/sdk/services/OrganizationService.d.ts +1 -3
- package/dist/store/slices/categorySlice.d.ts +21 -21
- package/dist/store/slices/issueSlice.d.ts +19 -19
- package/dist/store/slices/organizationAccessSlice.d.ts +5 -1
- package/dist/store/slices/organizationSlice.d.ts +0 -1
- package/dist/store/slices/projectFileSlice.d.ts +20 -20
- package/dist/store/slices/userFormSlice.d.ts +10 -10
- package/dist/store/slices/workspaceSlice.d.ts +21 -21
- package/dist/store/store.d.ts +64 -63
- package/dist/typings/models/organizations.d.ts +0 -10
- package/dist/typings/models/store.d.ts +1 -0
- package/package.json +1 -1
package/dist/overmap-core.js
CHANGED
|
@@ -2348,7 +2348,8 @@ const selectUsersAsMapping = (state) => state.userReducer.users;
|
|
|
2348
2348
|
const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
|
|
2349
2349
|
const userReducer = userSlice.reducer;
|
|
2350
2350
|
const initialState$a = {
|
|
2351
|
-
organizationAccesses: {}
|
|
2351
|
+
organizationAccesses: {},
|
|
2352
|
+
activeOrganizationAccessId: null
|
|
2352
2353
|
};
|
|
2353
2354
|
const organizationAccessSlice = createSlice({
|
|
2354
2355
|
name: "organizationAccess",
|
|
@@ -2384,28 +2385,31 @@ const organizationAccessSlice = createSlice({
|
|
|
2384
2385
|
`Tried to remove organization access with ID that doesn't exist: ${action.payload.offline_id}`
|
|
2385
2386
|
);
|
|
2386
2387
|
}
|
|
2388
|
+
},
|
|
2389
|
+
setActiveOrganizationAccessId: (state, action) => {
|
|
2390
|
+
state.activeOrganizationAccessId = action.payload;
|
|
2387
2391
|
}
|
|
2388
2392
|
}
|
|
2389
2393
|
});
|
|
2390
|
-
const {
|
|
2394
|
+
const {
|
|
2395
|
+
setOrganizationAccesses,
|
|
2396
|
+
updateOrganizationAccess,
|
|
2397
|
+
removeOrganizationAccess,
|
|
2398
|
+
setActiveOrganizationAccessId
|
|
2399
|
+
} = organizationAccessSlice.actions;
|
|
2391
2400
|
const selectOrganizationAccesses = (state) => {
|
|
2392
2401
|
return state.organizationAccessReducer.organizationAccesses;
|
|
2393
2402
|
};
|
|
2394
2403
|
const selectOrganizationAccess = (organizationAccessId) => (state) => {
|
|
2395
2404
|
return state.organizationAccessReducer.organizationAccesses[organizationAccessId];
|
|
2396
2405
|
};
|
|
2397
|
-
const selectActiveOrganizationAccess =
|
|
2398
|
-
|
|
2399
|
-
(
|
|
2400
|
-
|
|
2401
|
-
(organizationAccess) => organizationAccess.user === currentUser.id
|
|
2402
|
-
);
|
|
2403
|
-
if (!activeOrganizationAccess) {
|
|
2404
|
-
return null;
|
|
2405
|
-
}
|
|
2406
|
-
return activeOrganizationAccess;
|
|
2406
|
+
const selectActiveOrganizationAccess = (state) => {
|
|
2407
|
+
const activeOrganizationAccessId = state.organizationAccessReducer.activeOrganizationAccessId;
|
|
2408
|
+
if (!activeOrganizationAccessId) {
|
|
2409
|
+
return null;
|
|
2407
2410
|
}
|
|
2408
|
-
|
|
2411
|
+
return state.organizationAccessReducer.organizationAccesses[activeOrganizationAccessId] ?? null;
|
|
2412
|
+
};
|
|
2409
2413
|
const selectOrganizationAccessForUser = (user) => (state) => {
|
|
2410
2414
|
return Object.values(state.organizationAccessReducer.organizationAccesses).find(
|
|
2411
2415
|
(organizationAccess) => organizationAccess.user === user.id
|
|
@@ -2454,11 +2458,6 @@ const selectActiveOrganizationId = (state) => {
|
|
|
2454
2458
|
const selectOrganizations = (state) => {
|
|
2455
2459
|
return Object.values(state.organizationReducer.organizations);
|
|
2456
2460
|
};
|
|
2457
|
-
const selectOrganizationsWithAccess = (state) => {
|
|
2458
|
-
return Object.values(state.organizationReducer.organizations).filter(
|
|
2459
|
-
(organization) => organization.has_access
|
|
2460
|
-
);
|
|
2461
|
-
};
|
|
2462
2461
|
const selectActiveOrganization = (state) => {
|
|
2463
2462
|
const id = selectActiveOrganizationId(state);
|
|
2464
2463
|
if (!id) {
|
|
@@ -4030,6 +4029,7 @@ class AuthService extends BaseApiService {
|
|
|
4030
4029
|
store.dispatch(setLoggedIn(false));
|
|
4031
4030
|
store.dispatch(clearTokens());
|
|
4032
4031
|
store.dispatch(setActiveProjectId(null));
|
|
4032
|
+
store.dispatch(setActiveOrganizationAccessId(null));
|
|
4033
4033
|
store.dispatch(setActiveWorkspaceId(null));
|
|
4034
4034
|
store.dispatch({ type: RESET_STATE });
|
|
4035
4035
|
store.dispatch({ type: resetStore });
|
|
@@ -4872,26 +4872,25 @@ class MainService extends BaseApiService {
|
|
|
4872
4872
|
}
|
|
4873
4873
|
}
|
|
4874
4874
|
store.dispatch(setCurrentUser(data.user));
|
|
4875
|
-
store.dispatch(addUsers(data.project_owners));
|
|
4876
4875
|
const organizationsData = data.organizations;
|
|
4877
4876
|
store.dispatch(setOrganizations(organizationsData));
|
|
4878
|
-
const
|
|
4879
|
-
const firstOrg = organizationsData.find((organization) => organization.has_access);
|
|
4877
|
+
const firstOrg = organizationsData[0];
|
|
4880
4878
|
const currProjObj = projects.find((project) => project.id === currentProjectId);
|
|
4881
4879
|
const isOrgProject = !!(currProjObj == null ? void 0 : currProjObj.owner_organization);
|
|
4882
|
-
const userIsInProjectOrg = isOrgProject && organizationsData.some(
|
|
4883
|
-
(organization) => organization.has_access && organization.id === currProjObj.owner_organization
|
|
4884
|
-
);
|
|
4880
|
+
const userIsInProjectOrg = isOrgProject && organizationsData.some((organization) => organization.id === currProjObj.owner_organization);
|
|
4885
4881
|
let currentOrgId = null;
|
|
4886
|
-
if (
|
|
4887
|
-
currentOrgId = activeOrganizationId;
|
|
4888
|
-
} else if (userIsInProjectOrg) {
|
|
4882
|
+
if (userIsInProjectOrg) {
|
|
4889
4883
|
currentOrgId = currProjObj.owner_organization;
|
|
4890
4884
|
} else if (firstOrg) {
|
|
4891
4885
|
currentOrgId = firstOrg.id;
|
|
4892
4886
|
}
|
|
4893
4887
|
if (currentOrgId) {
|
|
4894
|
-
|
|
4888
|
+
store.dispatch(setActiveOrganizationId(currentOrgId));
|
|
4889
|
+
const orgUsersResultPromise = this.fetchOrganizationUsers(currentOrgId);
|
|
4890
|
+
const organizationAccessRefreshPromise = this.client.organizationAccess.refreshStore();
|
|
4891
|
+
const orgUsersResult = await orgUsersResultPromise;
|
|
4892
|
+
await organizationAccessRefreshPromise;
|
|
4893
|
+
store.dispatch(addUsers(orgUsersResult));
|
|
4895
4894
|
}
|
|
4896
4895
|
if (!isProjectIdValid) {
|
|
4897
4896
|
if (projects.length !== 0) {
|
|
@@ -4944,6 +4943,7 @@ class MainService extends BaseApiService {
|
|
|
4944
4943
|
void this.client.userForms.refreshStore().then(() => {
|
|
4945
4944
|
void this.client.userFormSubmissions.refreshStore().then();
|
|
4946
4945
|
});
|
|
4946
|
+
void this.client.emailDomains.refreshStore().then();
|
|
4947
4947
|
}
|
|
4948
4948
|
if (currentProjectId) {
|
|
4949
4949
|
const [_offlineAttachments, promise] = this.client.attachments.fetchAll(currentProjectId);
|
|
@@ -5644,8 +5644,16 @@ class OrganizationAccessService extends BaseApiService {
|
|
|
5644
5644
|
blockers: [],
|
|
5645
5645
|
blocks: []
|
|
5646
5646
|
});
|
|
5647
|
+
const currentUser = state.userReducer.currentUser;
|
|
5647
5648
|
const organizationAccesses = result;
|
|
5649
|
+
const activeOrganizationAccess = organizationAccesses.find(
|
|
5650
|
+
(organizationAccess) => organizationAccess.user === currentUser.id
|
|
5651
|
+
);
|
|
5652
|
+
if (!activeOrganizationAccess) {
|
|
5653
|
+
throw new Error("Current user does not have an organization access instance");
|
|
5654
|
+
}
|
|
5648
5655
|
store.dispatch(setOrganizationAccesses(organizationAccesses));
|
|
5656
|
+
store.dispatch(setActiveOrganizationAccessId(activeOrganizationAccess.offline_id));
|
|
5649
5657
|
}
|
|
5650
5658
|
}
|
|
5651
5659
|
const cachedRequestPromises = {};
|
|
@@ -5913,37 +5921,6 @@ class EmailDomainsService extends BaseApiService {
|
|
|
5913
5921
|
}
|
|
5914
5922
|
}
|
|
5915
5923
|
class OrganizationService extends BaseApiService {
|
|
5916
|
-
async fetchInitialOrganizationData(organization_id, showLoading) {
|
|
5917
|
-
if (showLoading) {
|
|
5918
|
-
this.client.store.dispatch(setIsFetchingInitialData(true));
|
|
5919
|
-
}
|
|
5920
|
-
return this.enqueueRequest({
|
|
5921
|
-
description: "Get initial organization data",
|
|
5922
|
-
method: HttpMethod.GET,
|
|
5923
|
-
url: `/organizations/${organization_id}/initial-data/`,
|
|
5924
|
-
payload: {},
|
|
5925
|
-
isAuthNeeded: true,
|
|
5926
|
-
blockers: [],
|
|
5927
|
-
blocks: []
|
|
5928
|
-
}).then((result) => {
|
|
5929
|
-
this._processInitialOrganizationData(result, showLoading);
|
|
5930
|
-
return result;
|
|
5931
|
-
});
|
|
5932
|
-
}
|
|
5933
|
-
_processInitialOrganizationData(data, showLoading) {
|
|
5934
|
-
const { store } = this.client;
|
|
5935
|
-
const activeOrganization = data.organization;
|
|
5936
|
-
const organizationAccesses = data.organization_accesses;
|
|
5937
|
-
const email_domains = data.email_domains;
|
|
5938
|
-
const users = data.users;
|
|
5939
|
-
store.dispatch(addUsers(users));
|
|
5940
|
-
store.dispatch(setActiveOrganizationId(activeOrganization.id));
|
|
5941
|
-
store.dispatch(setOrganizationAccesses(organizationAccesses));
|
|
5942
|
-
store.dispatch(setEmailDomains(email_domains));
|
|
5943
|
-
if (showLoading) {
|
|
5944
|
-
store.dispatch(setIsFetchingInitialData(false));
|
|
5945
|
-
}
|
|
5946
|
-
}
|
|
5947
5924
|
async create(name) {
|
|
5948
5925
|
const result = await this.enqueueRequest({
|
|
5949
5926
|
description: "Create organization",
|
|
@@ -6312,7 +6289,6 @@ export {
|
|
|
6312
6289
|
selectOrganizationUsersAsMapping,
|
|
6313
6290
|
selectOrganizationUsersIds,
|
|
6314
6291
|
selectOrganizations,
|
|
6315
|
-
selectOrganizationsWithAccess,
|
|
6316
6292
|
selectPermittedWorkspaceIds,
|
|
6317
6293
|
selectPhotoAttachmentsOfIssue,
|
|
6318
6294
|
selectProjectAccess,
|
|
@@ -6354,6 +6330,7 @@ export {
|
|
|
6354
6330
|
selectWorkspaceMapping,
|
|
6355
6331
|
selectWorkspaces,
|
|
6356
6332
|
setActiveIssueId,
|
|
6333
|
+
setActiveOrganizationAccessId,
|
|
6357
6334
|
setActiveOrganizationId,
|
|
6358
6335
|
setActiveProjectFileId,
|
|
6359
6336
|
setActiveProjectId,
|