@overmap-ai/core 1.0.31-org-switcher-and-bug-fixes.0 → 1.0.31
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 +85 -93
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +85 -93
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/MainService.d.ts +0 -1
- package/dist/sdk/services/OrganizationService.d.ts +1 -3
- package/dist/sdk/services/ProjectService.d.ts +1 -0
- package/dist/store/slices/organizationAccessSlice.d.ts +5 -1
- package/dist/store/slices/organizationSlice.d.ts +0 -1
- package/dist/store/slices/projectSlice.d.ts +5 -2
- package/dist/typings/models/organizations.d.ts +0 -10
- package/dist/typings/models/projects.d.ts +1 -0
- package/package.json +1 -1
package/dist/overmap-core.js
CHANGED
|
@@ -2357,7 +2357,8 @@ const selectUsersAsMapping = (state) => state.userReducer.users;
|
|
|
2357
2357
|
const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
|
|
2358
2358
|
const userReducer = userSlice.reducer;
|
|
2359
2359
|
const initialState$a = {
|
|
2360
|
-
organizationAccesses: {}
|
|
2360
|
+
organizationAccesses: {},
|
|
2361
|
+
activeOrganizationAccessId: null
|
|
2361
2362
|
};
|
|
2362
2363
|
const organizationAccessSlice = createSlice({
|
|
2363
2364
|
name: "organizationAccess",
|
|
@@ -2393,28 +2394,31 @@ const organizationAccessSlice = createSlice({
|
|
|
2393
2394
|
`Tried to remove organization access with ID that doesn't exist: ${action.payload.offline_id}`
|
|
2394
2395
|
);
|
|
2395
2396
|
}
|
|
2397
|
+
},
|
|
2398
|
+
setActiveOrganizationAccessId: (state, action) => {
|
|
2399
|
+
state.activeOrganizationAccessId = action.payload;
|
|
2396
2400
|
}
|
|
2397
2401
|
}
|
|
2398
2402
|
});
|
|
2399
|
-
const {
|
|
2403
|
+
const {
|
|
2404
|
+
setOrganizationAccesses,
|
|
2405
|
+
updateOrganizationAccess,
|
|
2406
|
+
removeOrganizationAccess,
|
|
2407
|
+
setActiveOrganizationAccessId
|
|
2408
|
+
} = organizationAccessSlice.actions;
|
|
2400
2409
|
const selectOrganizationAccesses = (state) => {
|
|
2401
2410
|
return state.organizationAccessReducer.organizationAccesses;
|
|
2402
2411
|
};
|
|
2403
2412
|
const selectOrganizationAccess = (organizationAccessId) => (state) => {
|
|
2404
2413
|
return state.organizationAccessReducer.organizationAccesses[organizationAccessId];
|
|
2405
2414
|
};
|
|
2406
|
-
const selectActiveOrganizationAccess =
|
|
2407
|
-
|
|
2408
|
-
(
|
|
2409
|
-
|
|
2410
|
-
(organizationAccess) => organizationAccess.user === currentUser.id
|
|
2411
|
-
);
|
|
2412
|
-
if (!activeOrganizationAccess) {
|
|
2413
|
-
return null;
|
|
2414
|
-
}
|
|
2415
|
-
return activeOrganizationAccess;
|
|
2415
|
+
const selectActiveOrganizationAccess = (state) => {
|
|
2416
|
+
const activeOrganizationAccessId = state.organizationAccessReducer.activeOrganizationAccessId;
|
|
2417
|
+
if (!activeOrganizationAccessId) {
|
|
2418
|
+
return null;
|
|
2416
2419
|
}
|
|
2417
|
-
|
|
2420
|
+
return state.organizationAccessReducer.organizationAccesses[activeOrganizationAccessId] ?? null;
|
|
2421
|
+
};
|
|
2418
2422
|
const selectOrganizationAccessForUser = (user) => (state) => {
|
|
2419
2423
|
return Object.values(state.organizationAccessReducer.organizationAccesses).find(
|
|
2420
2424
|
(organizationAccess) => organizationAccess.user === user.id
|
|
@@ -2463,11 +2467,6 @@ const selectActiveOrganizationId = (state) => {
|
|
|
2463
2467
|
const selectOrganizations = (state) => {
|
|
2464
2468
|
return Object.values(state.organizationReducer.organizations);
|
|
2465
2469
|
};
|
|
2466
|
-
const selectOrganizationsWithAccess = (state) => {
|
|
2467
|
-
return Object.values(state.organizationReducer.organizations).filter(
|
|
2468
|
-
(organization) => organization.has_access
|
|
2469
|
-
);
|
|
2470
|
-
};
|
|
2471
2470
|
const selectActiveOrganization = (state) => {
|
|
2472
2471
|
const id = selectActiveOrganizationId(state);
|
|
2473
2472
|
if (!id) {
|
|
@@ -2689,6 +2688,13 @@ const projectSlice = createSlice({
|
|
|
2689
2688
|
deleteProject: (state, action) => {
|
|
2690
2689
|
delete state.projects[action.payload.id];
|
|
2691
2690
|
state.recentProjectIds = state.recentProjectIds.filter((id) => id !== action.payload.id);
|
|
2691
|
+
},
|
|
2692
|
+
acceptProjectInvite: (state, action) => {
|
|
2693
|
+
if (action.payload in state.projects) {
|
|
2694
|
+
state.projects[action.payload].invited = false;
|
|
2695
|
+
} else {
|
|
2696
|
+
throw new Error("Accept project invite: user is not in this project");
|
|
2697
|
+
}
|
|
2692
2698
|
}
|
|
2693
2699
|
}
|
|
2694
2700
|
});
|
|
@@ -2698,7 +2704,8 @@ const {
|
|
|
2698
2704
|
updateOrCreateProjects: addOrReplaceProjects,
|
|
2699
2705
|
setActiveProjectId,
|
|
2700
2706
|
setCreateProjectType,
|
|
2701
|
-
deleteProject
|
|
2707
|
+
deleteProject,
|
|
2708
|
+
acceptProjectInvite
|
|
2702
2709
|
} = projectSlice.actions;
|
|
2703
2710
|
const selectProjects = (state) => state.projectReducer.projects;
|
|
2704
2711
|
const selectActiveProjectId = (state) => state.projectReducer.activeProjectId;
|
|
@@ -2712,21 +2719,6 @@ const selectActiveProject = (state) => {
|
|
|
2712
2719
|
const selectRecentProjects = (state) => {
|
|
2713
2720
|
return state.projectReducer.recentProjectIds;
|
|
2714
2721
|
};
|
|
2715
|
-
const selectSortedProjects = createSelector(
|
|
2716
|
-
[selectActiveProject, selectProjects],
|
|
2717
|
-
(activeProject, projects) => {
|
|
2718
|
-
return Object.values(projects).sort((projectA, projectB) => {
|
|
2719
|
-
if (activeProject) {
|
|
2720
|
-
if (activeProject.id === projectA.id) {
|
|
2721
|
-
return -1;
|
|
2722
|
-
} else if (activeProject.id === projectB.id) {
|
|
2723
|
-
return 1;
|
|
2724
|
-
}
|
|
2725
|
-
}
|
|
2726
|
-
return projectA.name.toLowerCase().localeCompare(projectB.name.toLowerCase(), void 0, { numeric: true });
|
|
2727
|
-
});
|
|
2728
|
-
}
|
|
2729
|
-
);
|
|
2730
2722
|
const selectCreateProjectType = (state) => state.projectReducer.createProjectType;
|
|
2731
2723
|
const projectReducer = projectSlice.reducer;
|
|
2732
2724
|
const selectProjectUsersIds = createSelector(
|
|
@@ -2737,6 +2729,10 @@ const selectProjectUsersAsMapping = createSelector(
|
|
|
2737
2729
|
[selectProjectUsersIds, selectUsersAsMapping],
|
|
2738
2730
|
(projectUserIds, users) => projectUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
|
|
2739
2731
|
);
|
|
2732
|
+
const selectProjectsWithAccess = createSelector(
|
|
2733
|
+
[selectProjects],
|
|
2734
|
+
(projects) => Object.values(projects).filter((project) => !project.invited)
|
|
2735
|
+
);
|
|
2740
2736
|
const selectSortedProjectUsers = createSelector(
|
|
2741
2737
|
[selectCurrentUser, selectProjectUsersAsMapping, selectProjectAccessUserMapping],
|
|
2742
2738
|
(currentUser, userMapping, projectAccessMapping) => {
|
|
@@ -4064,6 +4060,7 @@ class AuthService extends BaseApiService {
|
|
|
4064
4060
|
store.dispatch(setLoggedIn(false));
|
|
4065
4061
|
store.dispatch(clearTokens());
|
|
4066
4062
|
store.dispatch(setActiveProjectId(null));
|
|
4063
|
+
store.dispatch(setActiveOrganizationAccessId(null));
|
|
4067
4064
|
store.dispatch(setActiveWorkspaceId(null));
|
|
4068
4065
|
store.dispatch({ type: RESET_STATE });
|
|
4069
4066
|
store.dispatch({ type: resetStore });
|
|
@@ -4870,14 +4867,16 @@ class MainService extends BaseApiService {
|
|
|
4870
4867
|
// Don't accept updateStore in ComponentService.list. Just return the offline objects and promise. Here, if
|
|
4871
4868
|
// overwrite, use setComponents. Otherwise, use bulkAddComponents.
|
|
4872
4869
|
async _processInitialData(data, overwrite) {
|
|
4873
|
-
var _a2, _b;
|
|
4870
|
+
var _a2, _b, _c;
|
|
4874
4871
|
const workspaces = {};
|
|
4875
4872
|
const projects = [];
|
|
4876
4873
|
const categories = [];
|
|
4877
4874
|
const projectsData = data.projects;
|
|
4878
4875
|
const { store } = this.client;
|
|
4879
|
-
const oldProjectId =
|
|
4880
|
-
|
|
4876
|
+
const oldProjectId = (_a2 = projectsData.find(
|
|
4877
|
+
(projectData) => projectData.id === store.getState().projectReducer.activeProjectId && !projectData.invited
|
|
4878
|
+
)) == null ? void 0 : _a2.id;
|
|
4879
|
+
let currentProjectId = oldProjectId ?? ((_b = projectsData.find((projectData) => !projectData.invited)) == null ? void 0 : _b.id);
|
|
4881
4880
|
store.dispatch(setActiveProjectId(currentProjectId ?? null));
|
|
4882
4881
|
let isProjectIdValid = false;
|
|
4883
4882
|
for (const projectData of projectsData) {
|
|
@@ -4886,9 +4885,10 @@ class MainService extends BaseApiService {
|
|
|
4886
4885
|
name: projectData.name,
|
|
4887
4886
|
owner_organization: projectData.organization_owner,
|
|
4888
4887
|
owner_user: projectData.user_owner,
|
|
4889
|
-
bounds: projectData.bounds
|
|
4888
|
+
bounds: projectData.bounds,
|
|
4889
|
+
invited: projectData.invited || false
|
|
4890
4890
|
});
|
|
4891
|
-
if (currentProjectId === projectData.id) {
|
|
4891
|
+
if (currentProjectId === projectData.id && !projectData.invited) {
|
|
4892
4892
|
isProjectIdValid = true;
|
|
4893
4893
|
for (const workspaceData of projectData.workspaces) {
|
|
4894
4894
|
const workspace = { ...workspaceData, project: projectData.id };
|
|
@@ -4903,41 +4903,43 @@ class MainService extends BaseApiService {
|
|
|
4903
4903
|
}
|
|
4904
4904
|
}
|
|
4905
4905
|
store.dispatch(setCurrentUser(data.user));
|
|
4906
|
-
store.dispatch(addUsers(data.project_owners));
|
|
4907
4906
|
const organizationsData = data.organizations;
|
|
4908
4907
|
store.dispatch(setOrganizations(organizationsData));
|
|
4909
|
-
const
|
|
4910
|
-
const firstOrg = organizationsData
|
|
4908
|
+
const validProjects = projects.filter((project) => !project.invited);
|
|
4909
|
+
const firstOrg = organizationsData[0];
|
|
4911
4910
|
const currProjObj = projects.find((project) => project.id === currentProjectId);
|
|
4912
4911
|
const isOrgProject = !!(currProjObj == null ? void 0 : currProjObj.owner_organization);
|
|
4913
|
-
const userIsInProjectOrg = isOrgProject && organizationsData.some(
|
|
4914
|
-
(organization) => organization.has_access && organization.id === currProjObj.owner_organization
|
|
4915
|
-
);
|
|
4912
|
+
const userIsInProjectOrg = isOrgProject && organizationsData.some((organization) => organization.id === currProjObj.owner_organization);
|
|
4916
4913
|
let currentOrgId = null;
|
|
4917
|
-
if (
|
|
4918
|
-
currentOrgId = activeOrganizationId;
|
|
4919
|
-
} else if (userIsInProjectOrg) {
|
|
4914
|
+
if (userIsInProjectOrg) {
|
|
4920
4915
|
currentOrgId = currProjObj.owner_organization;
|
|
4921
4916
|
} else if (firstOrg) {
|
|
4922
4917
|
currentOrgId = firstOrg.id;
|
|
4923
4918
|
}
|
|
4924
4919
|
if (currentOrgId) {
|
|
4925
|
-
|
|
4920
|
+
store.dispatch(setActiveOrganizationId(currentOrgId));
|
|
4921
|
+
const orgUsersResultPromise = this.fetchOrganizationUsers(currentOrgId);
|
|
4922
|
+
const organizationAccessRefreshPromise = this.client.organizationAccess.refreshStore();
|
|
4923
|
+
const orgUsersResult = await orgUsersResultPromise;
|
|
4924
|
+
await organizationAccessRefreshPromise;
|
|
4925
|
+
store.dispatch(addUsers(orgUsersResult));
|
|
4926
4926
|
}
|
|
4927
4927
|
if (!isProjectIdValid) {
|
|
4928
|
-
if (
|
|
4929
|
-
currentProjectId =
|
|
4928
|
+
if (validProjects.length !== 0) {
|
|
4929
|
+
currentProjectId = validProjects[0].id;
|
|
4930
4930
|
store.dispatch(setActiveProjectId(currentProjectId));
|
|
4931
|
-
const projectData = projectsData
|
|
4932
|
-
|
|
4933
|
-
const
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4931
|
+
const projectData = projectsData.find((projectData2) => projectData2.id === currentProjectId);
|
|
4932
|
+
if (projectData) {
|
|
4933
|
+
for (const workspaceData of projectData.workspaces) {
|
|
4934
|
+
const workspace = { ...workspaceData, project: projectData.id };
|
|
4935
|
+
if (workspace.categories) {
|
|
4936
|
+
for (const category of workspace.categories) {
|
|
4937
|
+
categories.push(category);
|
|
4938
|
+
}
|
|
4937
4939
|
}
|
|
4940
|
+
delete workspace.categories;
|
|
4941
|
+
workspaces[workspace.offline_id] = workspace;
|
|
4938
4942
|
}
|
|
4939
|
-
delete workspace.categories;
|
|
4940
|
-
workspaces[workspace.offline_id] = workspace;
|
|
4941
4943
|
}
|
|
4942
4944
|
} else {
|
|
4943
4945
|
currentProjectId = null;
|
|
@@ -4954,7 +4956,7 @@ class MainService extends BaseApiService {
|
|
|
4954
4956
|
let currentWorkspaceId;
|
|
4955
4957
|
const oldWorkspaceId = this.client.store.getState().workspaceReducer.activeWorkspaceId;
|
|
4956
4958
|
if (overwrite || !oldWorkspaceId) {
|
|
4957
|
-
currentWorkspaceId = (
|
|
4959
|
+
currentWorkspaceId = (_c = Object.values(workspaces).at(0)) == null ? void 0 : _c.offline_id;
|
|
4958
4960
|
} else {
|
|
4959
4961
|
currentWorkspaceId = oldWorkspaceId;
|
|
4960
4962
|
}
|
|
@@ -4975,6 +4977,7 @@ class MainService extends BaseApiService {
|
|
|
4975
4977
|
void this.client.userForms.refreshStore().then(() => {
|
|
4976
4978
|
void this.client.userFormSubmissions.refreshStore().then();
|
|
4977
4979
|
});
|
|
4980
|
+
void this.client.emailDomains.refreshStore().then();
|
|
4978
4981
|
}
|
|
4979
4982
|
if (currentProjectId) {
|
|
4980
4983
|
const [_offlineAttachments, promise] = this.client.attachments.fetchAll(currentProjectId);
|
|
@@ -5264,6 +5267,17 @@ class ProjectService extends BaseApiService {
|
|
|
5264
5267
|
blocks: []
|
|
5265
5268
|
});
|
|
5266
5269
|
}
|
|
5270
|
+
async acceptInvite(projectId) {
|
|
5271
|
+
return this.enqueueRequest({
|
|
5272
|
+
description: "Accept project invite",
|
|
5273
|
+
method: HttpMethod.PATCH,
|
|
5274
|
+
url: `/projects/${projectId}/accept-invite/`,
|
|
5275
|
+
blockers: [projectId.toString()],
|
|
5276
|
+
blocks: [projectId.toString()]
|
|
5277
|
+
}).then(() => {
|
|
5278
|
+
this.client.store.dispatch(acceptProjectInvite(projectId));
|
|
5279
|
+
});
|
|
5280
|
+
}
|
|
5267
5281
|
}
|
|
5268
5282
|
class UserFormService extends BaseApiService {
|
|
5269
5283
|
add(state, initialRevision, url, ownerUser, ownerOrganization) {
|
|
@@ -5675,8 +5689,16 @@ class OrganizationAccessService extends BaseApiService {
|
|
|
5675
5689
|
blockers: [],
|
|
5676
5690
|
blocks: []
|
|
5677
5691
|
});
|
|
5692
|
+
const currentUser = state.userReducer.currentUser;
|
|
5678
5693
|
const organizationAccesses = result;
|
|
5694
|
+
const activeOrganizationAccess = organizationAccesses.find(
|
|
5695
|
+
(organizationAccess) => organizationAccess.user === currentUser.id
|
|
5696
|
+
);
|
|
5697
|
+
if (!activeOrganizationAccess) {
|
|
5698
|
+
throw new Error("Current user does not have an organization access instance");
|
|
5699
|
+
}
|
|
5679
5700
|
store.dispatch(setOrganizationAccesses(organizationAccesses));
|
|
5701
|
+
store.dispatch(setActiveOrganizationAccessId(activeOrganizationAccess.offline_id));
|
|
5680
5702
|
}
|
|
5681
5703
|
}
|
|
5682
5704
|
const cachedRequestPromises = {};
|
|
@@ -5944,37 +5966,6 @@ class EmailDomainsService extends BaseApiService {
|
|
|
5944
5966
|
}
|
|
5945
5967
|
}
|
|
5946
5968
|
class OrganizationService extends BaseApiService {
|
|
5947
|
-
async fetchInitialOrganizationData(organization_id, showLoading) {
|
|
5948
|
-
if (showLoading) {
|
|
5949
|
-
this.client.store.dispatch(setIsFetchingInitialData(true));
|
|
5950
|
-
}
|
|
5951
|
-
return this.enqueueRequest({
|
|
5952
|
-
description: "Get initial organization data",
|
|
5953
|
-
method: HttpMethod.GET,
|
|
5954
|
-
url: `/organizations/${organization_id}/initial-data/`,
|
|
5955
|
-
payload: {},
|
|
5956
|
-
isAuthNeeded: true,
|
|
5957
|
-
blockers: [],
|
|
5958
|
-
blocks: []
|
|
5959
|
-
}).then((result) => {
|
|
5960
|
-
this._processInitialOrganizationData(result, showLoading);
|
|
5961
|
-
return result;
|
|
5962
|
-
});
|
|
5963
|
-
}
|
|
5964
|
-
_processInitialOrganizationData(data, showLoading) {
|
|
5965
|
-
const { store } = this.client;
|
|
5966
|
-
const activeOrganization = data.organization;
|
|
5967
|
-
const organizationAccesses = data.organization_accesses;
|
|
5968
|
-
const email_domains = data.email_domains;
|
|
5969
|
-
const users = data.users;
|
|
5970
|
-
store.dispatch(addUsers(users));
|
|
5971
|
-
store.dispatch(setActiveOrganizationId(activeOrganization.id));
|
|
5972
|
-
store.dispatch(setOrganizationAccesses(organizationAccesses));
|
|
5973
|
-
store.dispatch(setEmailDomains(email_domains));
|
|
5974
|
-
if (showLoading) {
|
|
5975
|
-
store.dispatch(setIsFetchingInitialData(false));
|
|
5976
|
-
}
|
|
5977
|
-
}
|
|
5978
5969
|
async create(name) {
|
|
5979
5970
|
const result = await this.enqueueRequest({
|
|
5980
5971
|
description: "Create organization",
|
|
@@ -10749,6 +10740,7 @@ export {
|
|
|
10749
10740
|
WorkspaceService,
|
|
10750
10741
|
YELLOW,
|
|
10751
10742
|
_setLatestRetryTime,
|
|
10743
|
+
acceptProjectInvite,
|
|
10752
10744
|
addAttachment,
|
|
10753
10745
|
addAttachments,
|
|
10754
10746
|
addCategory,
|
|
@@ -10986,7 +10978,6 @@ export {
|
|
|
10986
10978
|
selectOrganizationUsersAsMapping,
|
|
10987
10979
|
selectOrganizationUsersIds,
|
|
10988
10980
|
selectOrganizations,
|
|
10989
|
-
selectOrganizationsWithAccess,
|
|
10990
10981
|
selectPermittedWorkspaceIds,
|
|
10991
10982
|
selectPhotoAttachmentsOfIssue,
|
|
10992
10983
|
selectProjectAccess,
|
|
@@ -10998,6 +10989,7 @@ export {
|
|
|
10998
10989
|
selectProjectUsersAsMapping,
|
|
10999
10990
|
selectProjectUsersIds,
|
|
11000
10991
|
selectProjects,
|
|
10992
|
+
selectProjectsWithAccess,
|
|
11001
10993
|
selectRecentIssueIds,
|
|
11002
10994
|
selectRecentIssuesAsSearchResults,
|
|
11003
10995
|
selectRecentProjects,
|
|
@@ -11007,7 +10999,6 @@ export {
|
|
|
11007
10999
|
selectSortedEmailDomains,
|
|
11008
11000
|
selectSortedOrganizationUsers,
|
|
11009
11001
|
selectSortedProjectUsers,
|
|
11010
|
-
selectSortedProjects,
|
|
11011
11002
|
selectStageMapping,
|
|
11012
11003
|
selectStages,
|
|
11013
11004
|
selectStagesFromComponentType,
|
|
@@ -11029,6 +11020,7 @@ export {
|
|
|
11029
11020
|
selectWorkspaceMapping,
|
|
11030
11021
|
selectWorkspaces,
|
|
11031
11022
|
setActiveIssueId,
|
|
11023
|
+
setActiveOrganizationAccessId,
|
|
11032
11024
|
setActiveOrganizationId,
|
|
11033
11025
|
setActiveProjectFileId,
|
|
11034
11026
|
setActiveProjectId,
|