@overmap-ai/core 1.0.35-projects-licensing.3 → 1.0.35-projects-licensing.5

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.
@@ -2658,28 +2658,10 @@ const licenseSlice = createSlice({
2658
2658
  throw new Error("Tried to update license that does not exist.");
2659
2659
  }
2660
2660
  state.licenses[action.payload.offline_id] = action.payload;
2661
- },
2662
- resumeLicense: (state, action) => {
2663
- if (!(action.payload in state.licenses)) {
2664
- throw new Error("Tried to resume license that does not exist.");
2665
- }
2666
- state.licenses[action.payload].is_paused = false;
2667
- },
2668
- pauseLicense: (state, action) => {
2669
- if (!(action.payload in state.licenses)) {
2670
- throw new Error("Tried to pause license that does not exist.");
2671
- }
2672
- state.licenses[action.payload].is_paused = true;
2673
- },
2674
- cancelLicense: (state, action) => {
2675
- if (!(action.payload in state.licenses)) {
2676
- throw new Error("Tried to cancel license that does not exist.");
2677
- }
2678
- state.licenses[action.payload].is_cancelled = true;
2679
2661
  }
2680
2662
  }
2681
2663
  });
2682
- const { setLicenses, updateLicense, pauseLicense, resumeLicense, cancelLicense } = licenseSlice.actions;
2664
+ const { setLicenses, updateLicense } = licenseSlice.actions;
2683
2665
  const selectLicenses = (state) => {
2684
2666
  return state.licenseReducer.licenses;
2685
2667
  };
@@ -2779,6 +2761,10 @@ const selectOrganizationUsersIds = createSelector(
2779
2761
  [selectOrganizationAccesses],
2780
2762
  (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
2781
2763
  );
2764
+ const selectOrganizationProjects = createSelector(
2765
+ [selectProjects, selectActiveOrganizationId],
2766
+ (projects, activeOrganizationId) => activeOrganizationId ? Object.values(projects).filter((project) => project.owner_organization === activeOrganizationId) : []
2767
+ );
2782
2768
  const selectOrganizationUsersAsMapping = createSelector(
2783
2769
  [selectOrganizationUsersIds, selectUsersAsMapping],
2784
2770
  (organizationUserIds, users) => organizationUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
@@ -6146,10 +6132,12 @@ class LicenseService extends BaseApiService {
6146
6132
  method: HttpMethod.DELETE,
6147
6133
  url: `/billing/${license.offline_id}/suspend/`,
6148
6134
  isAuthNeeded: true,
6149
- blockers: [license.organization_owner ? license.organization_owner.toString() : ""],
6135
+ blockers: [
6136
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6137
+ ],
6150
6138
  blocks: []
6151
6139
  }).then((result) => {
6152
- this.client.store.dispatch(pauseLicense(license.offline_id));
6140
+ this.client.store.dispatch(updateLicense(result));
6153
6141
  return result;
6154
6142
  });
6155
6143
  }
@@ -6159,10 +6147,12 @@ class LicenseService extends BaseApiService {
6159
6147
  method: HttpMethod.PATCH,
6160
6148
  url: `/billing/${license.offline_id}/suspend/`,
6161
6149
  isAuthNeeded: true,
6162
- blockers: [license.organization_owner ? license.organization_owner.toString() : ""],
6150
+ blockers: [
6151
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6152
+ ],
6163
6153
  blocks: []
6164
6154
  }).then((result) => {
6165
- this.client.store.dispatch(resumeLicense(license.offline_id));
6155
+ this.client.store.dispatch(updateLicense(result));
6166
6156
  return result;
6167
6157
  });
6168
6158
  }
@@ -6172,10 +6162,44 @@ class LicenseService extends BaseApiService {
6172
6162
  method: HttpMethod.DELETE,
6173
6163
  url: `/billing/${license.offline_id}/`,
6174
6164
  isAuthNeeded: true,
6175
- blockers: [license.organization_owner ? license.organization_owner.toString() : ""],
6165
+ blockers: [
6166
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6167
+ ],
6168
+ blocks: []
6169
+ }).then((result) => {
6170
+ this.client.store.dispatch(updateLicense(result));
6171
+ return result;
6172
+ });
6173
+ }
6174
+ async attachLicenseToProject(license, project) {
6175
+ return this.enqueueRequest({
6176
+ description: "Attach license",
6177
+ method: HttpMethod.PATCH,
6178
+ url: `/billing/${license.offline_id}/project/`,
6179
+ isAuthNeeded: true,
6180
+ payload: { project: project.id },
6181
+ blockers: [
6182
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : "",
6183
+ project.id ? project.id.toString() : ""
6184
+ ],
6185
+ blocks: []
6186
+ }).then((result) => {
6187
+ this.client.store.dispatch(updateLicense(result));
6188
+ return result;
6189
+ });
6190
+ }
6191
+ async detachLicenseFromProject(license) {
6192
+ return this.enqueueRequest({
6193
+ description: "Detach license",
6194
+ method: HttpMethod.DELETE,
6195
+ url: `/billing/${license.offline_id}/project/`,
6196
+ isAuthNeeded: true,
6197
+ blockers: [
6198
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6199
+ ],
6176
6200
  blocks: []
6177
6201
  }).then((result) => {
6178
- this.client.store.dispatch(cancelLicense(license.offline_id));
6202
+ this.client.store.dispatch(updateLicense(result));
6179
6203
  return result;
6180
6204
  });
6181
6205
  }
@@ -11467,7 +11491,6 @@ export {
11467
11491
  authSlice,
11468
11492
  blobToBase64,
11469
11493
  boundsContainPoint,
11470
- cancelLicense,
11471
11494
  categoryReducer,
11472
11495
  categorySlice,
11473
11496
  classNames$1 as classNames,
@@ -11570,7 +11593,6 @@ export {
11570
11593
  overmapReducer,
11571
11594
  overmapReducers,
11572
11595
  patchCategory,
11573
- pauseLicense,
11574
11596
  performRequest,
11575
11597
  primaryColor,
11576
11598
  projectAccessReducer,
@@ -11606,7 +11628,6 @@ export {
11606
11628
  resetRecentIssues,
11607
11629
  resetStore,
11608
11630
  restructureCreateSelectorWithArgs,
11609
- resumeLicense,
11610
11631
  rootReducer,
11611
11632
  saveActiveProjectFileBounds,
11612
11633
  searchIssues,
@@ -11688,6 +11709,7 @@ export {
11688
11709
  selectOrganizationAccessForUser,
11689
11710
  selectOrganizationAccessUserMapping,
11690
11711
  selectOrganizationAccesses,
11712
+ selectOrganizationProjects,
11691
11713
  selectOrganizationUsersAsMapping,
11692
11714
  selectOrganizationUsersIds,
11693
11715
  selectOrganizations,