@finos/legend-application-marketplace 0.1.55 → 0.1.57
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/lib/__lib__/LegendMarketplaceAppEvent.d.ts +1 -0
- package/lib/__lib__/LegendMarketplaceAppEvent.d.ts.map +1 -1
- package/lib/__lib__/LegendMarketplaceAppEvent.js +1 -0
- package/lib/__lib__/LegendMarketplaceAppEvent.js.map +1 -1
- package/lib/__lib__/LegendMarketplaceNavigation.d.ts +9 -2
- package/lib/__lib__/LegendMarketplaceNavigation.d.ts.map +1 -1
- package/lib/__lib__/LegendMarketplaceNavigation.js +7 -1
- package/lib/__lib__/LegendMarketplaceNavigation.js.map +1 -1
- package/lib/__lib__/LegendMarketplaceTelemetryHelper.d.ts +11 -1
- package/lib/__lib__/LegendMarketplaceTelemetryHelper.d.ts.map +1 -1
- package/lib/__lib__/LegendMarketplaceTelemetryHelper.js +57 -3
- package/lib/__lib__/LegendMarketplaceTelemetryHelper.js.map +1 -1
- package/lib/application/LegendMarketplaceWebApplication.d.ts.map +1 -1
- package/lib/application/LegendMarketplaceWebApplication.js +4 -1
- package/lib/application/LegendMarketplaceWebApplication.js.map +1 -1
- package/lib/components/Header/LegendMarketplaceIconToolbar.d.ts.map +1 -1
- package/lib/components/Header/LegendMarketplaceIconToolbar.js +11 -2
- package/lib/components/Header/LegendMarketplaceIconToolbar.js.map +1 -1
- package/lib/components/SearchBar/LegendMarketplaceSearchBar.d.ts.map +1 -1
- package/lib/components/SearchBar/LegendMarketplaceSearchBar.js +4 -0
- package/lib/components/SearchBar/LegendMarketplaceSearchBar.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/pages/Lakehouse/MarketplaceLakehouseHome.d.ts.map +1 -1
- package/lib/pages/Lakehouse/MarketplaceLakehouseHome.js +5 -19
- package/lib/pages/Lakehouse/MarketplaceLakehouseHome.js.map +1 -1
- package/lib/pages/Lakehouse/admin/LakehouseAdminContractsDashboard.js +2 -2
- package/lib/pages/Lakehouse/admin/LakehouseAdminContractsDashboard.js.map +1 -1
- package/lib/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.d.ts.map +1 -1
- package/lib/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.js +38 -132
- package/lib/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.js.map +1 -1
- package/lib/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.d.ts.map +1 -1
- package/lib/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.js +36 -160
- package/lib/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.js.map +1 -1
- package/lib/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.d.ts.map +1 -1
- package/lib/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.js +60 -40
- package/lib/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.js.map +1 -1
- package/lib/pages/Lakehouse/entitlements/LakehouseDataContract.d.ts +17 -0
- package/lib/pages/Lakehouse/entitlements/LakehouseDataContract.d.ts.map +1 -0
- package/lib/pages/Lakehouse/entitlements/LakehouseDataContract.js +124 -0
- package/lib/pages/Lakehouse/entitlements/LakehouseDataContract.js.map +1 -0
- package/lib/stores/lakehouse/LegendMarketplaceProductViewerStore.js +2 -2
- package/lib/stores/lakehouse/LegendMarketplaceProductViewerStore.js.map +1 -1
- package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.d.ts +22 -11
- package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.d.ts.map +1 -1
- package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.js +145 -74
- package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.js.map +1 -1
- package/lib/stores/orders/OrderHelpers.d.ts +1 -1
- package/lib/stores/orders/OrderHelpers.d.ts.map +1 -1
- package/lib/stores/orders/OrderHelpers.js +7 -6
- package/lib/stores/orders/OrderHelpers.js.map +1 -1
- package/lib/utils/EntitlementsUtils.d.ts +20 -0
- package/lib/utils/EntitlementsUtils.d.ts.map +1 -0
- package/lib/utils/EntitlementsUtils.js +107 -0
- package/lib/utils/EntitlementsUtils.js.map +1 -0
- package/package.json +10 -10
- package/src/__lib__/LegendMarketplaceAppEvent.ts +1 -0
- package/src/__lib__/LegendMarketplaceNavigation.ts +19 -3
- package/src/__lib__/LegendMarketplaceTelemetryHelper.ts +80 -4
- package/src/application/LegendMarketplaceWebApplication.tsx +15 -0
- package/src/components/Header/LegendMarketplaceIconToolbar.tsx +29 -0
- package/src/components/SearchBar/LegendMarketplaceSearchBar.tsx +7 -0
- package/src/pages/Lakehouse/MarketplaceLakehouseHome.tsx +4 -54
- package/src/pages/Lakehouse/admin/LakehouseAdminContractsDashboard.tsx +3 -3
- package/src/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.tsx +91 -244
- package/src/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.tsx +91 -298
- package/src/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.tsx +87 -52
- package/src/pages/Lakehouse/entitlements/LakehouseDataContract.tsx +284 -0
- package/src/stores/lakehouse/LegendMarketplaceProductViewerStore.ts +3 -3
- package/src/stores/lakehouse/entitlements/EntitlementsDashboardState.ts +234 -109
- package/src/stores/orders/OrderHelpers.ts +8 -7
- package/src/utils/EntitlementsUtils.tsx +207 -0
- package/tsconfig.json +2 -0
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import {
|
|
18
18
|
ActionState,
|
|
19
19
|
assertErrorThrown,
|
|
20
|
+
guaranteeNonNullable,
|
|
20
21
|
isNonNullable,
|
|
21
22
|
type GeneratorFn,
|
|
22
23
|
type PlainObject,
|
|
@@ -24,34 +25,82 @@ import {
|
|
|
24
25
|
import { deserialize } from 'serializr';
|
|
25
26
|
import {
|
|
26
27
|
type V1_ContractUserEventRecord,
|
|
28
|
+
type V1_DataContract,
|
|
29
|
+
type V1_EnrichedUserApprovalStatus,
|
|
27
30
|
type V1_LiteDataContract,
|
|
28
|
-
type V1_LiteDataContractsResponse,
|
|
29
31
|
type V1_LiteDataContractWithUserStatus,
|
|
30
32
|
type V1_PendingTasksResponse,
|
|
31
33
|
type V1_TaskStatus,
|
|
32
34
|
type V1_TaskStatusChangeResponse,
|
|
33
|
-
|
|
34
|
-
type V1_UserPendingContractsResponse,
|
|
35
|
-
V1_liteDataContractsResponseModelSchemaToContracts,
|
|
35
|
+
V1_dataContractsResponseModelSchema,
|
|
36
36
|
V1_liteDataContractWithUserStatusModelSchema,
|
|
37
37
|
V1_pendingTasksResponseModelSchema,
|
|
38
38
|
V1_TaskStatusChangeResponseModelSchema,
|
|
39
|
+
V1_transformDataContractToLiteDatacontract,
|
|
39
40
|
} from '@finos/legend-graph';
|
|
40
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
makeObservable,
|
|
43
|
+
flow,
|
|
44
|
+
observable,
|
|
45
|
+
flowResult,
|
|
46
|
+
action,
|
|
47
|
+
computed,
|
|
48
|
+
} from 'mobx';
|
|
41
49
|
import {
|
|
42
50
|
TEST_USER,
|
|
43
|
-
TEST_USER2,
|
|
44
51
|
type LakehouseEntitlementsStore,
|
|
45
52
|
} from './LakehouseEntitlementsStore.js';
|
|
46
53
|
|
|
54
|
+
export class ContractCreatedByUserDetails {
|
|
55
|
+
readonly contractResultLite: V1_LiteDataContract;
|
|
56
|
+
assignees: Set<string> = new Set();
|
|
57
|
+
members: Map<string, V1_EnrichedUserApprovalStatus> = new Map();
|
|
58
|
+
|
|
59
|
+
constructor(contract: V1_LiteDataContract) {
|
|
60
|
+
this.contractResultLite = contract;
|
|
61
|
+
|
|
62
|
+
makeObservable(this, {
|
|
63
|
+
assignees: observable,
|
|
64
|
+
members: observable,
|
|
65
|
+
sortedAssigneeIds: computed,
|
|
66
|
+
sortedMemberIds: computed,
|
|
67
|
+
addAssignees: action,
|
|
68
|
+
addMember: action,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get sortedAssigneeIds(): string[] {
|
|
73
|
+
return Array.from(this.assignees).toSorted();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get sortedMemberIds(): string[] {
|
|
77
|
+
return Array.from(this.members.keys()).toSorted();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
addAssignees(assignees: string[]): void {
|
|
81
|
+
assignees.forEach((assignee) => this.assignees.add(assignee));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
addMember(id: string, status: V1_EnrichedUserApprovalStatus): void {
|
|
85
|
+
this.members.set(id, status);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
47
89
|
export class EntitlementsDashboardState {
|
|
48
90
|
readonly lakehouseEntitlementsStore: LakehouseEntitlementsStore;
|
|
49
91
|
pendingTasks: V1_ContractUserEventRecord[] | undefined;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
92
|
+
pendingTaskContractMap: Map<string, V1_LiteDataContract> = new Map();
|
|
93
|
+
allContractsForUser: V1_LiteDataContractWithUserStatus[] | undefined;
|
|
94
|
+
// The contracts createdBy user API returns an entry for each task, not just for each contract.
|
|
95
|
+
// To consolidate this information, we store a map of contract ID to the contract details + the
|
|
96
|
+
// consolidated user information from the tasks.
|
|
97
|
+
allContractsCreatedByUserMap: Map<string, ContractCreatedByUserDetails> =
|
|
98
|
+
new Map();
|
|
53
99
|
|
|
54
100
|
readonly initializationState = ActionState.create();
|
|
101
|
+
readonly fetchingPendingTasksState = ActionState.create();
|
|
102
|
+
readonly fetchingContractsForUserState = ActionState.create();
|
|
103
|
+
readonly fetchingContractsByUserState = ActionState.create();
|
|
55
104
|
readonly changingState = ActionState.create();
|
|
56
105
|
|
|
57
106
|
constructor(state: LakehouseEntitlementsStore) {
|
|
@@ -59,38 +108,52 @@ export class EntitlementsDashboardState {
|
|
|
59
108
|
|
|
60
109
|
makeObservable(this, {
|
|
61
110
|
pendingTasks: observable,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
setMyContracts: action,
|
|
111
|
+
allContractsForUser: observable,
|
|
112
|
+
allContractsCreatedByUserMap: observable,
|
|
113
|
+
pendingTaskContractMap: observable,
|
|
114
|
+
pendingTaskContracts: computed,
|
|
115
|
+
allContractsCreatedByUser: computed,
|
|
116
|
+
init: flow,
|
|
69
117
|
approve: flow,
|
|
70
|
-
|
|
118
|
+
deny: flow,
|
|
71
119
|
fetchPendingTasks: flow,
|
|
72
|
-
|
|
73
|
-
|
|
120
|
+
fetchPendingTaskContracts: flow,
|
|
121
|
+
fetchContractsForUser: flow,
|
|
122
|
+
fetchContractsCreatedByUser: flow,
|
|
74
123
|
updateContract: flow,
|
|
75
|
-
init: flow,
|
|
76
|
-
deny: flow,
|
|
77
124
|
});
|
|
78
125
|
}
|
|
79
126
|
|
|
127
|
+
get pendingTaskContracts(): V1_LiteDataContract[] {
|
|
128
|
+
return Array.from(this.pendingTaskContractMap.values());
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
get allContractsCreatedByUser(): ContractCreatedByUserDetails[] {
|
|
132
|
+
return Array.from(this.allContractsCreatedByUserMap.values());
|
|
133
|
+
}
|
|
134
|
+
|
|
80
135
|
*init(token: string | undefined): GeneratorFn<void> {
|
|
81
136
|
this.initializationState.inProgress();
|
|
82
137
|
try {
|
|
83
138
|
yield Promise.all([
|
|
84
|
-
|
|
139
|
+
(async () => {
|
|
140
|
+
this.fetchingPendingTasksState.inProgress();
|
|
141
|
+
try {
|
|
142
|
+
await flowResult(this.fetchPendingTasks(token));
|
|
143
|
+
await flowResult(this.fetchPendingTaskContracts(token));
|
|
144
|
+
} catch (error) {
|
|
145
|
+
assertErrorThrown(error);
|
|
146
|
+
this.lakehouseEntitlementsStore.applicationStore.alertUnhandledError(
|
|
147
|
+
error,
|
|
148
|
+
);
|
|
149
|
+
} finally {
|
|
150
|
+
this.fetchingPendingTasksState.complete();
|
|
151
|
+
}
|
|
152
|
+
})(),
|
|
153
|
+
flowResult(this.fetchContractsForUser(token)).catch(
|
|
85
154
|
this.lakehouseEntitlementsStore.applicationStore.alertUnhandledError,
|
|
86
155
|
),
|
|
87
|
-
flowResult(this.
|
|
88
|
-
this.lakehouseEntitlementsStore.applicationStore.alertUnhandledError,
|
|
89
|
-
),
|
|
90
|
-
flowResult(this.fetchAllContracts(token)).catch(
|
|
91
|
-
this.lakehouseEntitlementsStore.applicationStore.alertUnhandledError,
|
|
92
|
-
),
|
|
93
|
-
flowResult(this.fetchMyContracts(token)).catch(
|
|
156
|
+
flowResult(this.fetchContractsCreatedByUser(token)).catch(
|
|
94
157
|
this.lakehouseEntitlementsStore.applicationStore.alertUnhandledError,
|
|
95
158
|
),
|
|
96
159
|
]);
|
|
@@ -104,33 +167,16 @@ export class EntitlementsDashboardState {
|
|
|
104
167
|
}
|
|
105
168
|
}
|
|
106
169
|
|
|
107
|
-
*fetchPendingContracts(token: string | undefined): GeneratorFn<void> {
|
|
108
|
-
try {
|
|
109
|
-
this.setPendingContracts(undefined);
|
|
110
|
-
const pendingContracts =
|
|
111
|
-
(yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.getPendingContracts(
|
|
112
|
-
TEST_USER2,
|
|
113
|
-
token,
|
|
114
|
-
)) as V1_UserPendingContractsResponse;
|
|
115
|
-
this.setPendingContracts(pendingContracts.records ?? []);
|
|
116
|
-
} catch (error) {
|
|
117
|
-
assertErrorThrown(error);
|
|
118
|
-
this.lakehouseEntitlementsStore.applicationStore.notificationService.notifyError(
|
|
119
|
-
`Error fetching pending contracts: ${error.message}`,
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
170
|
*fetchPendingTasks(token: string | undefined): GeneratorFn<void> {
|
|
125
171
|
try {
|
|
126
|
-
this.
|
|
172
|
+
this.pendingTasks = undefined;
|
|
127
173
|
const rawTasks =
|
|
128
174
|
(yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.getPendingTasks(
|
|
129
175
|
TEST_USER,
|
|
130
176
|
token,
|
|
131
177
|
)) as PlainObject<V1_PendingTasksResponse>;
|
|
132
178
|
const tasks = deserialize(V1_pendingTasksResponseModelSchema, rawTasks);
|
|
133
|
-
this.
|
|
179
|
+
this.pendingTasks = [...tasks.dataOwner, ...tasks.privilegeManager];
|
|
134
180
|
} catch (error) {
|
|
135
181
|
assertErrorThrown(error);
|
|
136
182
|
this.lakehouseEntitlementsStore.applicationStore.notificationService.notifyError(
|
|
@@ -139,31 +185,74 @@ export class EntitlementsDashboardState {
|
|
|
139
185
|
}
|
|
140
186
|
}
|
|
141
187
|
|
|
142
|
-
*
|
|
188
|
+
*fetchPendingTaskContracts(token: string | undefined): GeneratorFn<void> {
|
|
189
|
+
const pendingTaskContractIds = Array.from(
|
|
190
|
+
new Set(this.pendingTasks?.map((t) => t.dataContractId) ?? []),
|
|
191
|
+
);
|
|
192
|
+
const pendingTaskContracts = (
|
|
193
|
+
(yield Promise.all(
|
|
194
|
+
pendingTaskContractIds.map(async (contractId) => {
|
|
195
|
+
const rawContractResponse =
|
|
196
|
+
await this.lakehouseEntitlementsStore.lakehouseContractServerClient.getDataContract(
|
|
197
|
+
contractId,
|
|
198
|
+
false,
|
|
199
|
+
token,
|
|
200
|
+
);
|
|
201
|
+
const contractResponse = deserialize(
|
|
202
|
+
V1_dataContractsResponseModelSchema(
|
|
203
|
+
this.lakehouseEntitlementsStore.applicationStore.pluginManager.getPureProtocolProcessorPlugins(),
|
|
204
|
+
),
|
|
205
|
+
rawContractResponse,
|
|
206
|
+
);
|
|
207
|
+
return contractResponse.dataContracts?.[0]?.dataContract;
|
|
208
|
+
}),
|
|
209
|
+
)) as (V1_DataContract | undefined)[]
|
|
210
|
+
)
|
|
211
|
+
.filter(isNonNullable)
|
|
212
|
+
.map(V1_transformDataContractToLiteDatacontract);
|
|
213
|
+
pendingTaskContractIds.forEach((contractId) => {
|
|
214
|
+
const contract = pendingTaskContracts.find((c) => c.guid === contractId);
|
|
215
|
+
if (contract) {
|
|
216
|
+
this.pendingTaskContractMap.set(contractId, contract);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
*fetchContractsForUser(token: string | undefined): GeneratorFn<void> {
|
|
222
|
+
this.fetchingContractsForUserState.inProgress();
|
|
143
223
|
try {
|
|
144
|
-
this.
|
|
224
|
+
this.allContractsForUser = undefined;
|
|
145
225
|
const rawContracts =
|
|
146
|
-
(yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.
|
|
226
|
+
(yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.getContractsForUser(
|
|
227
|
+
this.lakehouseEntitlementsStore.applicationStore.identityService
|
|
228
|
+
.currentUser,
|
|
147
229
|
token,
|
|
148
|
-
)) as PlainObject<
|
|
149
|
-
const contracts =
|
|
150
|
-
|
|
151
|
-
|
|
230
|
+
)) as PlainObject<V1_LiteDataContractWithUserStatus>[];
|
|
231
|
+
const contracts = rawContracts.map((rawContract) =>
|
|
232
|
+
deserialize(
|
|
233
|
+
V1_liteDataContractWithUserStatusModelSchema(
|
|
234
|
+
this.lakehouseEntitlementsStore.applicationStore.pluginManager.getPureProtocolProcessorPlugins(),
|
|
235
|
+
),
|
|
236
|
+
rawContract,
|
|
237
|
+
),
|
|
152
238
|
);
|
|
153
|
-
this.
|
|
239
|
+
this.allContractsForUser = [...contracts];
|
|
154
240
|
} catch (error) {
|
|
155
241
|
assertErrorThrown(error);
|
|
156
242
|
this.lakehouseEntitlementsStore.applicationStore.notificationService.notifyError(
|
|
157
|
-
`Error fetching
|
|
243
|
+
`Error fetching data contracts for user: ${error.message}`,
|
|
158
244
|
);
|
|
245
|
+
} finally {
|
|
246
|
+
this.fetchingContractsForUserState.complete();
|
|
159
247
|
}
|
|
160
248
|
}
|
|
161
249
|
|
|
162
|
-
*
|
|
250
|
+
*fetchContractsCreatedByUser(token: string | undefined): GeneratorFn<void> {
|
|
251
|
+
this.fetchingContractsByUserState.inProgress();
|
|
163
252
|
try {
|
|
164
|
-
this.
|
|
253
|
+
this.allContractsCreatedByUserMap = new Map();
|
|
165
254
|
const rawContracts =
|
|
166
|
-
(yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.
|
|
255
|
+
(yield this.lakehouseEntitlementsStore.lakehouseContractServerClient.getContractsCreatedByUser(
|
|
167
256
|
this.lakehouseEntitlementsStore.applicationStore.identityService
|
|
168
257
|
.currentUser,
|
|
169
258
|
token,
|
|
@@ -176,73 +265,109 @@ export class EntitlementsDashboardState {
|
|
|
176
265
|
rawContract,
|
|
177
266
|
),
|
|
178
267
|
);
|
|
179
|
-
|
|
268
|
+
contracts.forEach((contract) => {
|
|
269
|
+
if (
|
|
270
|
+
!this.allContractsCreatedByUserMap.has(
|
|
271
|
+
contract.contractResultLite.guid,
|
|
272
|
+
)
|
|
273
|
+
) {
|
|
274
|
+
this.allContractsCreatedByUserMap.set(
|
|
275
|
+
contract.contractResultLite.guid,
|
|
276
|
+
new ContractCreatedByUserDetails(contract.contractResultLite),
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
const entry = guaranteeNonNullable(
|
|
280
|
+
this.allContractsCreatedByUserMap.get(
|
|
281
|
+
contract.contractResultLite.guid,
|
|
282
|
+
),
|
|
283
|
+
);
|
|
284
|
+
entry.addAssignees(contract.pendingTaskWithAssignees?.assignees ?? []);
|
|
285
|
+
entry.addMember(contract.user, contract.status);
|
|
286
|
+
});
|
|
180
287
|
} catch (error) {
|
|
181
288
|
assertErrorThrown(error);
|
|
182
289
|
this.lakehouseEntitlementsStore.applicationStore.notificationService.notifyError(
|
|
183
|
-
`Error fetching
|
|
290
|
+
`Error fetching data contracts created by user: ${error.message}`,
|
|
184
291
|
);
|
|
292
|
+
} finally {
|
|
293
|
+
this.fetchingContractsByUserState.complete();
|
|
185
294
|
}
|
|
186
295
|
}
|
|
187
296
|
|
|
188
|
-
setPendingTasks(val: V1_ContractUserEventRecord[] | undefined): void {
|
|
189
|
-
this.pendingTasks = val;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
setPendingContracts(val: V1_UserPendingContractsRecord[] | undefined): void {
|
|
193
|
-
this.pendingContracts = val;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
setAllContracts(val: V1_LiteDataContract[] | undefined): void {
|
|
197
|
-
this.allContracts = val;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
setMyContracts(val: V1_LiteDataContractWithUserStatus[] | undefined): void {
|
|
201
|
-
this.myContracts = val;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
297
|
*updateContract(
|
|
205
298
|
contractId: string,
|
|
206
299
|
token: string | undefined,
|
|
207
300
|
): GeneratorFn<void> {
|
|
208
|
-
const [
|
|
209
|
-
(async () =>
|
|
210
|
-
|
|
211
|
-
await this.lakehouseEntitlementsStore.lakehouseContractServerClient.
|
|
212
|
-
|
|
301
|
+
const [newUserContracts, newCreatedByUserContracts] = (yield Promise.all([
|
|
302
|
+
(async () => {
|
|
303
|
+
const rawContracts =
|
|
304
|
+
await this.lakehouseEntitlementsStore.lakehouseContractServerClient.getContractsForUser(
|
|
305
|
+
this.lakehouseEntitlementsStore.applicationStore.identityService
|
|
306
|
+
.currentUser,
|
|
213
307
|
token,
|
|
214
|
-
)
|
|
215
|
-
|
|
308
|
+
);
|
|
309
|
+
return rawContracts.map((rawContract) =>
|
|
310
|
+
deserialize(
|
|
311
|
+
V1_liteDataContractWithUserStatusModelSchema(
|
|
312
|
+
this.lakehouseEntitlementsStore.applicationStore.pluginManager.getPureProtocolProcessorPlugins(),
|
|
313
|
+
),
|
|
314
|
+
rawContract,
|
|
315
|
+
),
|
|
316
|
+
);
|
|
317
|
+
})(),
|
|
216
318
|
(async () => {
|
|
217
319
|
const rawContracts =
|
|
218
|
-
await this.lakehouseEntitlementsStore.lakehouseContractServerClient.
|
|
320
|
+
await this.lakehouseEntitlementsStore.lakehouseContractServerClient.getContractsCreatedByUser(
|
|
321
|
+
this.lakehouseEntitlementsStore.applicationStore.identityService
|
|
322
|
+
.currentUser,
|
|
219
323
|
token,
|
|
220
324
|
);
|
|
221
|
-
return
|
|
222
|
-
|
|
223
|
-
|
|
325
|
+
return rawContracts.map((rawContract) =>
|
|
326
|
+
deserialize(
|
|
327
|
+
V1_liteDataContractWithUserStatusModelSchema(
|
|
328
|
+
this.lakehouseEntitlementsStore.applicationStore.pluginManager.getPureProtocolProcessorPlugins(),
|
|
329
|
+
),
|
|
330
|
+
rawContract,
|
|
331
|
+
),
|
|
224
332
|
);
|
|
225
333
|
})(),
|
|
226
|
-
])) as [
|
|
334
|
+
])) as [
|
|
335
|
+
V1_LiteDataContractWithUserStatus[],
|
|
336
|
+
V1_LiteDataContractWithUserStatus[],
|
|
337
|
+
];
|
|
227
338
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
)
|
|
244
|
-
.filter(isNonNullable),
|
|
339
|
+
// Update the contract for the user
|
|
340
|
+
this.allContractsForUser = this.allContractsForUser
|
|
341
|
+
?.map((contract) =>
|
|
342
|
+
contract.contractResultLite.guid === contractId
|
|
343
|
+
? newUserContracts.find(
|
|
344
|
+
(c) => c.contractResultLite.guid === contractId,
|
|
345
|
+
)
|
|
346
|
+
: contract,
|
|
347
|
+
)
|
|
348
|
+
.filter(isNonNullable);
|
|
349
|
+
|
|
350
|
+
// Update the contract + all related data for contract created by the user
|
|
351
|
+
this.allContractsCreatedByUserMap.delete(contractId);
|
|
352
|
+
const updatedCreatedByUserContracts = newCreatedByUserContracts.filter(
|
|
353
|
+
(c) => c.contractResultLite.guid === contractId,
|
|
245
354
|
);
|
|
355
|
+
|
|
356
|
+
updatedCreatedByUserContracts.forEach((contract) => {
|
|
357
|
+
if (
|
|
358
|
+
!this.allContractsCreatedByUserMap.has(contract.contractResultLite.guid)
|
|
359
|
+
) {
|
|
360
|
+
this.allContractsCreatedByUserMap.set(
|
|
361
|
+
contract.contractResultLite.guid,
|
|
362
|
+
new ContractCreatedByUserDetails(contract.contractResultLite),
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
const entry = guaranteeNonNullable(
|
|
366
|
+
this.allContractsCreatedByUserMap.get(contract.contractResultLite.guid),
|
|
367
|
+
);
|
|
368
|
+
entry.addAssignees(contract.pendingTaskWithAssignees?.assignees ?? []);
|
|
369
|
+
entry.addMember(contract.user, contract.status);
|
|
370
|
+
});
|
|
246
371
|
}
|
|
247
372
|
|
|
248
373
|
*approve(
|
|
@@ -267,7 +392,7 @@ export class EntitlementsDashboardState {
|
|
|
267
392
|
);
|
|
268
393
|
}
|
|
269
394
|
task.status = change.status;
|
|
270
|
-
this.
|
|
395
|
+
this.pendingTasks = [...(this.pendingTasks ?? [])];
|
|
271
396
|
this.lakehouseEntitlementsStore.applicationStore.notificationService.notifySuccess(
|
|
272
397
|
`Task has been Approved`,
|
|
273
398
|
);
|
|
@@ -305,7 +430,7 @@ export class EntitlementsDashboardState {
|
|
|
305
430
|
);
|
|
306
431
|
}
|
|
307
432
|
task.status = change.status;
|
|
308
|
-
this.
|
|
433
|
+
this.pendingTasks = [...(this.pendingTasks ?? [])];
|
|
309
434
|
this.lakehouseEntitlementsStore.applicationStore.notificationService.notifySuccess(
|
|
310
435
|
`Task has been denied`,
|
|
311
436
|
);
|
|
@@ -146,13 +146,14 @@ export const isStageRejected = (
|
|
|
146
146
|
return false;
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
export const formatOrderDate = (dateString
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
export const formatOrderDate = (dateString?: string): string | undefined => {
|
|
150
|
+
return dateString
|
|
151
|
+
? new Date(dateString).toLocaleDateString('en-US', {
|
|
152
|
+
year: 'numeric',
|
|
153
|
+
month: 'short',
|
|
154
|
+
day: 'numeric',
|
|
155
|
+
})
|
|
156
|
+
: undefined;
|
|
156
157
|
};
|
|
157
158
|
|
|
158
159
|
export const formatTimestamp = (timestamp: string): string => {
|