@finos/legend-extension-dsl-data-product 0.0.2

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.
Files changed (143) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/lib/__lib__/DSL_DataProduct_Event.d.ts +19 -0
  4. package/lib/__lib__/DSL_DataProduct_Event.d.ts.map +1 -0
  5. package/lib/__lib__/DSL_DataProduct_Event.js +20 -0
  6. package/lib/__lib__/DSL_DataProduct_Event.js.map +1 -0
  7. package/lib/components/Core_DataProductDataAccess_LegendApplicationPlugin.d.ts +25 -0
  8. package/lib/components/Core_DataProductDataAccess_LegendApplicationPlugin.d.ts.map +1 -0
  9. package/lib/components/Core_DataProductDataAccess_LegendApplicationPlugin.js +105 -0
  10. package/lib/components/Core_DataProductDataAccess_LegendApplicationPlugin.js.map +1 -0
  11. package/lib/components/DataProduct/DataContract/EntitlementsDataContractCreator.d.ts +27 -0
  12. package/lib/components/DataProduct/DataContract/EntitlementsDataContractCreator.d.ts.map +1 -0
  13. package/lib/components/DataProduct/DataContract/EntitlementsDataContractCreator.js +57 -0
  14. package/lib/components/DataProduct/DataContract/EntitlementsDataContractCreator.js.map +1 -0
  15. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.d.ts +29 -0
  16. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.d.ts.map +1 -0
  17. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.js +165 -0
  18. package/lib/components/DataProduct/DataContract/EntitlementsDataContractViewer.js.map +1 -0
  19. package/lib/components/DataProduct/DataProductDataAccess.d.ts +34 -0
  20. package/lib/components/DataProduct/DataProductDataAccess.d.ts.map +1 -0
  21. package/lib/components/DataProduct/DataProductDataAccess.js +336 -0
  22. package/lib/components/DataProduct/DataProductDataAccess.js.map +1 -0
  23. package/lib/components/DataProduct/DataProductSupportInfo.d.ts +22 -0
  24. package/lib/components/DataProduct/DataProductSupportInfo.d.ts.map +1 -0
  25. package/lib/components/DataProduct/DataProductSupportInfo.js +43 -0
  26. package/lib/components/DataProduct/DataProductSupportInfo.js.map +1 -0
  27. package/lib/components/DataProduct/Subscriptions/DataProductSubscriptionsViewer.d.ts +26 -0
  28. package/lib/components/DataProduct/Subscriptions/DataProductSubscriptionsViewer.d.ts.map +1 -0
  29. package/lib/components/DataProduct/Subscriptions/DataProductSubscriptionsViewer.js +219 -0
  30. package/lib/components/DataProduct/Subscriptions/DataProductSubscriptionsViewer.js.map +1 -0
  31. package/lib/components/ProductViewer.d.ts +33 -0
  32. package/lib/components/ProductViewer.d.ts.map +1 -0
  33. package/lib/components/ProductViewer.js +113 -0
  34. package/lib/components/ProductViewer.js.map +1 -0
  35. package/lib/components/ProductWiki.d.ts +39 -0
  36. package/lib/components/ProductWiki.d.ts.map +1 -0
  37. package/lib/components/ProductWiki.js +95 -0
  38. package/lib/components/ProductWiki.js.map +1 -0
  39. package/lib/components/TerminalProduct/TerminalProductPrice.d.ts +22 -0
  40. package/lib/components/TerminalProduct/TerminalProductPrice.d.ts.map +1 -0
  41. package/lib/components/TerminalProduct/TerminalProductPrice.js +39 -0
  42. package/lib/components/TerminalProduct/TerminalProductPrice.js.map +1 -0
  43. package/lib/components/UserRenderer/MultiUserRenderer.d.ts +24 -0
  44. package/lib/components/UserRenderer/MultiUserRenderer.d.ts.map +1 -0
  45. package/lib/components/UserRenderer/MultiUserRenderer.js +46 -0
  46. package/lib/components/UserRenderer/MultiUserRenderer.js.map +1 -0
  47. package/lib/components/UserRenderer/UserRenderer.d.ts +27 -0
  48. package/lib/components/UserRenderer/UserRenderer.d.ts.map +1 -0
  49. package/lib/components/UserRenderer/UserRenderer.js +57 -0
  50. package/lib/components/UserRenderer/UserRenderer.js.map +1 -0
  51. package/lib/components/__test-utils__/StateTestUtils.d.ts +36 -0
  52. package/lib/components/__test-utils__/StateTestUtils.d.ts.map +1 -0
  53. package/lib/components/__test-utils__/StateTestUtils.js +97 -0
  54. package/lib/components/__test-utils__/StateTestUtils.js.map +1 -0
  55. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.d.ts +25 -0
  56. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.d.ts.map +1 -0
  57. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.js +231 -0
  58. package/lib/components/__test-utils__/TEST_DATA__LakehouseContractData.js.map +1 -0
  59. package/lib/components/__test-utils__/TEST_DATA__LakehouseDataProducts.d.ts +71 -0
  60. package/lib/components/__test-utils__/TEST_DATA__LakehouseDataProducts.d.ts.map +1 -0
  61. package/lib/components/__test-utils__/TEST_DATA__LakehouseDataProducts.js +316 -0
  62. package/lib/components/__test-utils__/TEST_DATA__LakehouseDataProducts.js.map +1 -0
  63. package/lib/index.css +17 -0
  64. package/lib/index.css.map +1 -0
  65. package/lib/index.d.ts +32 -0
  66. package/lib/index.d.ts.map +1 -0
  67. package/lib/index.js +32 -0
  68. package/lib/index.js.map +1 -0
  69. package/lib/package.json +95 -0
  70. package/lib/stores/BaseLayoutState.d.ts +35 -0
  71. package/lib/stores/BaseLayoutState.d.ts.map +1 -0
  72. package/lib/stores/BaseLayoutState.js +166 -0
  73. package/lib/stores/BaseLayoutState.js.map +1 -0
  74. package/lib/stores/BaseViewerState.d.ts +33 -0
  75. package/lib/stores/BaseViewerState.d.ts.map +1 -0
  76. package/lib/stores/BaseViewerState.js +27 -0
  77. package/lib/stores/BaseViewerState.js.map +1 -0
  78. package/lib/stores/DataProduct/DataProductAPGState.d.ts +62 -0
  79. package/lib/stores/DataProduct/DataProductAPGState.d.ts.map +1 -0
  80. package/lib/stores/DataProduct/DataProductAPGState.js +222 -0
  81. package/lib/stores/DataProduct/DataProductAPGState.js.map +1 -0
  82. package/lib/stores/DataProduct/DataProductDataAccessState.d.ts +66 -0
  83. package/lib/stores/DataProduct/DataProductDataAccessState.d.ts.map +1 -0
  84. package/lib/stores/DataProduct/DataProductDataAccessState.js +191 -0
  85. package/lib/stores/DataProduct/DataProductDataAccessState.js.map +1 -0
  86. package/lib/stores/DataProduct/DataProductViewerState.d.ts +40 -0
  87. package/lib/stores/DataProduct/DataProductViewerState.d.ts.map +1 -0
  88. package/lib/stores/DataProduct/DataProductViewerState.js +60 -0
  89. package/lib/stores/DataProduct/DataProductViewerState.js.map +1 -0
  90. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.d.ts +31 -0
  91. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.d.ts.map +1 -0
  92. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.js +57 -0
  93. package/lib/stores/DataProduct/EntitlementsDataContractViewerState.js.map +1 -0
  94. package/lib/stores/DataProductDataAccess_LegendApplicationPlugin_Extension.d.ts +33 -0
  95. package/lib/stores/DataProductDataAccess_LegendApplicationPlugin_Extension.d.ts.map +1 -0
  96. package/lib/stores/DataProductDataAccess_LegendApplicationPlugin_Extension.js +17 -0
  97. package/lib/stores/DataProductDataAccess_LegendApplicationPlugin_Extension.js.map +1 -0
  98. package/lib/stores/ProductViewerNavigation.d.ts +29 -0
  99. package/lib/stores/ProductViewerNavigation.d.ts.map +1 -0
  100. package/lib/stores/ProductViewerNavigation.js +35 -0
  101. package/lib/stores/ProductViewerNavigation.js.map +1 -0
  102. package/lib/stores/TerminalProduct/TerminalProductViewerState.d.ts +25 -0
  103. package/lib/stores/TerminalProduct/TerminalProductViewerState.d.ts.map +1 -0
  104. package/lib/stores/TerminalProduct/TerminalProductViewerState.js +32 -0
  105. package/lib/stores/TerminalProduct/TerminalProductViewerState.js.map +1 -0
  106. package/lib/utils/DataContractUtils.d.ts +23 -0
  107. package/lib/utils/DataContractUtils.d.ts.map +1 -0
  108. package/lib/utils/DataContractUtils.js +76 -0
  109. package/lib/utils/DataContractUtils.js.map +1 -0
  110. package/lib/utils/LakehouseUtils.d.ts +21 -0
  111. package/lib/utils/LakehouseUtils.d.ts.map +1 -0
  112. package/lib/utils/LakehouseUtils.js +72 -0
  113. package/lib/utils/LakehouseUtils.js.map +1 -0
  114. package/package.json +95 -0
  115. package/src/__lib__/DSL_DataProduct_Event.ts +19 -0
  116. package/src/components/Core_DataProductDataAccess_LegendApplicationPlugin.tsx +233 -0
  117. package/src/components/DataProduct/DataContract/EntitlementsDataContractCreator.tsx +182 -0
  118. package/src/components/DataProduct/DataContract/EntitlementsDataContractViewer.tsx +586 -0
  119. package/src/components/DataProduct/DataProductDataAccess.tsx +767 -0
  120. package/src/components/DataProduct/DataProductSupportInfo.tsx +195 -0
  121. package/src/components/DataProduct/Subscriptions/DataProductSubscriptionsViewer.tsx +602 -0
  122. package/src/components/ProductViewer.tsx +287 -0
  123. package/src/components/ProductWiki.tsx +196 -0
  124. package/src/components/TerminalProduct/TerminalProductPrice.tsx +56 -0
  125. package/src/components/UserRenderer/MultiUserRenderer.tsx +89 -0
  126. package/src/components/UserRenderer/UserRenderer.tsx +100 -0
  127. package/src/components/__test-utils__/StateTestUtils.ts +170 -0
  128. package/src/components/__test-utils__/TEST_DATA__LakehouseContractData.ts +253 -0
  129. package/src/components/__test-utils__/TEST_DATA__LakehouseDataProducts.ts +343 -0
  130. package/src/index.ts +34 -0
  131. package/src/stores/BaseLayoutState.ts +220 -0
  132. package/src/stores/BaseViewerState.ts +75 -0
  133. package/src/stores/DataProduct/DataProductAPGState.ts +385 -0
  134. package/src/stores/DataProduct/DataProductDataAccessState.ts +354 -0
  135. package/src/stores/DataProduct/DataProductViewerState.ts +100 -0
  136. package/src/stores/DataProduct/EntitlementsDataContractViewerState.ts +83 -0
  137. package/src/stores/DataProductDataAccess_LegendApplicationPlugin_Extension.ts +38 -0
  138. package/src/stores/ProductViewerNavigation.ts +48 -0
  139. package/src/stores/TerminalProduct/TerminalProductViewerState.ts +43 -0
  140. package/src/utils/DataContractUtils.ts +121 -0
  141. package/src/utils/LakehouseUtils.ts +91 -0
  142. package/tsconfig.json +91 -0
  143. package/tsconfig.package.json +56 -0
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@finos/legend-extension-dsl-data-product",
3
+ "version": "0.0.2",
4
+ "description": "Legend data product viewer core",
5
+ "keywords": [
6
+ "legend",
7
+ "data product",
8
+ "viewer"
9
+ ],
10
+ "homepage": "https://github.com/finos/legend-studio/tree/master/packages/legend-extension-dsl-data-product",
11
+ "bugs": {
12
+ "url": "https://github.com/finos/legend-studio/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/finos/legend-studio.git",
17
+ "directory": "packages/legend-extension-dsl-data-product"
18
+ },
19
+ "license": "Apache-2.0",
20
+ "sideEffects": false,
21
+ "type": "module",
22
+ "exports": {
23
+ ".": "./lib/index.js",
24
+ "./test": "./lib/__test__.js",
25
+ "./lib/index.css": "./lib/index.css"
26
+ },
27
+ "module": "lib/index.js",
28
+ "types": "lib/index.d.ts",
29
+ "scripts": {
30
+ "build": "yarn clean && yarn build:sass && yarn build:ts",
31
+ "build:sass": "cross-env INIT_CWD=$INIT_CWD node ../../scripts/workflow/buildSass.js",
32
+ "build:ts": "tsc --project ./tsconfig.build.json",
33
+ "clean": "npm-run-all clean:cache clean:lib",
34
+ "clean:cache": "rimraf \"build\"",
35
+ "clean:lib": "rimraf \"lib\"",
36
+ "dev": "npm-run-all --parallel dev:sass dev:ts",
37
+ "dev:sass": "sass style:lib --watch --load-path=../../node_modules/@finos/legend-art/scss",
38
+ "dev:ts": "tsc --watch --preserveWatchOutput",
39
+ "lint:js": "cross-env NODE_ENV=production eslint --cache --cache-location ./build/.eslintcache --report-unused-disable-directives --parser-options=project:\"./tsconfig.json\" \"./src/**/*.{js,ts,tsx}\"",
40
+ "publish:prepare": "node ../../scripts/release/preparePublishContent.js",
41
+ "publish:snapshot": "node ../../scripts/release/publishDevSnapshot.js",
42
+ "test": "jest",
43
+ "test:watch": "jest --watch"
44
+ },
45
+ "dependencies": {
46
+ "@finos/legend-application": "16.0.70",
47
+ "@finos/legend-art": "7.1.123",
48
+ "@finos/legend-code-editor": "2.0.118",
49
+ "@finos/legend-graph": "32.2.8",
50
+ "@finos/legend-lego": "2.0.129",
51
+ "@finos/legend-server-depot": "6.1.1",
52
+ "@finos/legend-server-lakehouse": "0.2.8",
53
+ "@finos/legend-server-marketplace": "0.1.8",
54
+ "@finos/legend-shared": "11.0.20",
55
+ "@finos/legend-storage": "3.0.139",
56
+ "@mui/lab": "6.0.1-beta.34",
57
+ "@mui/material": "6.4.7",
58
+ "@testing-library/dom": "10.4.0",
59
+ "@testing-library/react": "16.2.0",
60
+ "@types/react": "19.0.10",
61
+ "@types/react-dom": "19.0.4",
62
+ "dompurify": "3.2.5",
63
+ "mobx": "6.13.6",
64
+ "mobx-react-lite": "4.1.0",
65
+ "mobx-utils": "6.1.0",
66
+ "node-diff3": "3.1.2",
67
+ "oidc-client-ts": "^3.2.0",
68
+ "react": "19.0.0",
69
+ "react-dnd": "16.0.1",
70
+ "react-dom": "19.0.0",
71
+ "react-oidc-context": "^3.3.0",
72
+ "serializr": "3.0.3",
73
+ "yaml": "2.7.0"
74
+ },
75
+ "devDependencies": {
76
+ "@finos/legend-dev-utils": "2.2.5",
77
+ "@jest/globals": "29.7.0",
78
+ "cross-env": "7.0.3",
79
+ "eslint": "9.20.1",
80
+ "jest": "29.7.0",
81
+ "npm-run-all": "4.1.5",
82
+ "rimraf": "6.0.1",
83
+ "sass": "1.85.0",
84
+ "typescript": "5.7.3"
85
+ },
86
+ "peerDependencies": {
87
+ "react": "^19.0.0"
88
+ },
89
+ "publishConfig": {
90
+ "directory": "build/publishContent"
91
+ },
92
+ "extensions": {
93
+ "dataProductDataAccessApplicationPlugin": "@finos/legend-application-plugin-dsl-data-product-data-access"
94
+ }
95
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export enum DSL_DATAPRODUCT_EVENT {
18
+ FETCH_INGEST_ENV_FAILURE = 'dataProduct.access.ingest-env.failure',
19
+ }
@@ -0,0 +1,233 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import packageJson from '../../package.json' with { type: 'json' };
18
+ import {
19
+ type V1_OrganizationalScope,
20
+ V1_UserType,
21
+ V1_AdhocTeam,
22
+ V1_User,
23
+ } from '@finos/legend-graph';
24
+ import { LegendUser } from '@finos/legend-shared';
25
+ import { useEffect, useState, type ChangeEvent } from 'react';
26
+ import {
27
+ type DataProductAPGState,
28
+ AccessPointGroupAccess,
29
+ } from '../stores/DataProduct/DataProductAPGState.js';
30
+ import type { ContractConsumerTypeRendererConfig } from '../stores/DataProduct/DataProductDataAccessState.js';
31
+ import type { DataProductDataAccess_LegendApplicationPlugin_Extension } from '../stores/DataProductDataAccess_LegendApplicationPlugin_Extension.js';
32
+ import { UserSearchInput } from '@finos/legend-art';
33
+ import { TextField } from '@mui/material';
34
+ import {
35
+ type LegendApplicationPluginManager,
36
+ LegendApplicationPlugin,
37
+ } from '@finos/legend-application';
38
+
39
+ export class Core_DataProductDataAccess_LegendApplicationPlugin
40
+ extends LegendApplicationPlugin
41
+ implements DataProductDataAccess_LegendApplicationPlugin_Extension
42
+ {
43
+ static NAME = packageJson.extensions.dataProductDataAccessApplicationPlugin;
44
+
45
+ constructor() {
46
+ super(
47
+ Core_DataProductDataAccess_LegendApplicationPlugin.NAME,
48
+ packageJson.version,
49
+ );
50
+ }
51
+
52
+ install(
53
+ pluginManager: LegendApplicationPluginManager<LegendApplicationPlugin>,
54
+ ): void {
55
+ pluginManager.registerApplicationPlugin(this);
56
+ }
57
+
58
+ getContractConsumerTypeRendererConfigs(): ContractConsumerTypeRendererConfig[] {
59
+ const buildAdhocUser = (
60
+ userName: string,
61
+ type?: V1_UserType,
62
+ ): V1_AdhocTeam => {
63
+ const _user = new V1_User();
64
+ _user.name = userName;
65
+ _user.userType = type ?? V1_UserType.WORKFORCE_USER;
66
+ const _adhocTeam = new V1_AdhocTeam();
67
+ _adhocTeam.users = [_user];
68
+ return _adhocTeam;
69
+ };
70
+
71
+ const CommonRenderer = (props: {
72
+ type: 'user' | 'system-account';
73
+ label: string;
74
+ apgState: DataProductAPGState;
75
+ handleOrganizationalScopeChange: (
76
+ consumer: V1_OrganizationalScope,
77
+ ) => void;
78
+ handleDescriptionChange: (description: string | undefined) => void;
79
+ handleIsValidChange: (isValid: boolean) => void;
80
+ enableUserSearch: boolean;
81
+ }): React.ReactElement => {
82
+ const {
83
+ type,
84
+ label,
85
+ apgState,
86
+ handleOrganizationalScopeChange,
87
+ handleDescriptionChange,
88
+ handleIsValidChange,
89
+ enableUserSearch,
90
+ } = props;
91
+ const [description, setDescription] = useState<string>('');
92
+ const [user, setUser] = useState<LegendUser>(new LegendUser());
93
+ const [loadingCurrentUser, setLoadingCurrentUser] = useState(false);
94
+
95
+ // Update parent state whenever local state changes
96
+ useEffect(() => {
97
+ handleOrganizationalScopeChange(
98
+ buildAdhocUser(
99
+ user.id,
100
+ type === 'system-account'
101
+ ? V1_UserType.SYSTEM_ACCOUNT
102
+ : V1_UserType.WORKFORCE_USER,
103
+ ),
104
+ );
105
+ handleDescriptionChange(description);
106
+ handleIsValidChange(user.id !== '' && description.trim() !== '');
107
+ }, [
108
+ type,
109
+ user,
110
+ description,
111
+ handleOrganizationalScopeChange,
112
+ handleDescriptionChange,
113
+ handleIsValidChange,
114
+ ]);
115
+
116
+ useEffect(() => {
117
+ const fetchCurrentUser = async () => {
118
+ if (apgState.dataProductViewerState.userSearchService) {
119
+ setLoadingCurrentUser(true);
120
+ try {
121
+ const currentUser =
122
+ await apgState.dataProductViewerState.userSearchService.getOrFetchUser(
123
+ apgState.applicationStore.identityService.currentUser,
124
+ );
125
+ if (currentUser instanceof LegendUser) {
126
+ setUser(currentUser);
127
+ }
128
+ } finally {
129
+ setLoadingCurrentUser(false);
130
+ }
131
+ }
132
+ };
133
+ // We should only fetch the current user if the current user is not already entitled.
134
+ // If the current user is already entitled, we can assume they are requesting access for another user or system account.
135
+ if (apgState.access === AccessPointGroupAccess.NO_ACCESS) {
136
+ // eslint-disable-next-line no-void
137
+ void fetchCurrentUser();
138
+ }
139
+ }, [
140
+ apgState.access,
141
+ apgState.applicationStore.identityService.currentUser,
142
+ apgState.dataProductViewerState.userSearchService,
143
+ ]);
144
+
145
+ return (
146
+ <>
147
+ {apgState.access === AccessPointGroupAccess.ENTERPRISE && (
148
+ <p className="marketplace-lakehouse-entitlements__data-contract-creator__enterprise-apg-notice">
149
+ Note: Enterprise APGs only require contracts for System Accounts.
150
+ Regular users do not need to request access.
151
+ </p>
152
+ )}
153
+ <UserSearchInput
154
+ className="marketplace-lakehouse-entitlements__data-contract-creator__user-input"
155
+ key={label}
156
+ userValue={user}
157
+ setUserValue={(_user: LegendUser): void => setUser(_user)}
158
+ userSearchService={
159
+ enableUserSearch
160
+ ? apgState.dataProductViewerState.userSearchService
161
+ : undefined
162
+ }
163
+ label={label}
164
+ required={true}
165
+ variant="outlined"
166
+ fullWidth={true}
167
+ initializing={loadingCurrentUser}
168
+ />
169
+ <TextField
170
+ className="marketplace-lakehouse-entitlements__data-contract-creator__business-justification-input"
171
+ required={true}
172
+ name="business-justification"
173
+ label="Business Justification"
174
+ variant="outlined"
175
+ fullWidth={true}
176
+ value={description}
177
+ onChange={(event: ChangeEvent<HTMLInputElement>) =>
178
+ setDescription(event.target.value)
179
+ }
180
+ />
181
+ </>
182
+ );
183
+ };
184
+
185
+ return [
186
+ {
187
+ type: 'User',
188
+ createContractRenderer: (
189
+ apgState: DataProductAPGState,
190
+ handleOrganizationalScopeChange: (
191
+ consumer: V1_OrganizationalScope,
192
+ ) => void,
193
+ handleDescriptionChange: (description: string | undefined) => void,
194
+ handleIsValidChange: (isValid: boolean) => void,
195
+ ) => (
196
+ <CommonRenderer
197
+ key="user"
198
+ type="user"
199
+ label="User"
200
+ apgState={apgState}
201
+ handleOrganizationalScopeChange={handleOrganizationalScopeChange}
202
+ handleDescriptionChange={handleDescriptionChange}
203
+ handleIsValidChange={handleIsValidChange}
204
+ enableUserSearch={true}
205
+ />
206
+ ),
207
+ },
208
+ {
209
+ type: 'System Account',
210
+ enableForEnterpriseAPGs: true,
211
+ createContractRenderer: (
212
+ apgState: DataProductAPGState,
213
+ handleOrganizationalScopeChange: (
214
+ consumer: V1_OrganizationalScope,
215
+ ) => void,
216
+ handleDescriptionChange: (description: string | undefined) => void,
217
+ handleIsValidChange: (isValid: boolean) => void,
218
+ ) => (
219
+ <CommonRenderer
220
+ key="system-account"
221
+ type="system-account"
222
+ label="System Account"
223
+ apgState={apgState}
224
+ handleOrganizationalScopeChange={handleOrganizationalScopeChange}
225
+ handleDescriptionChange={handleDescriptionChange}
226
+ handleIsValidChange={handleIsValidChange}
227
+ enableUserSearch={false}
228
+ />
229
+ ),
230
+ },
231
+ ];
232
+ }
233
+ }
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ ELEMENT_PATH_DELIMITER,
19
+ type V1_OrganizationalScope,
20
+ } from '@finos/legend-graph';
21
+ import { observer } from 'mobx-react-lite';
22
+ import { useMemo, useState } from 'react';
23
+ import { flowResult } from 'mobx';
24
+ import {
25
+ Button,
26
+ ButtonGroup,
27
+ Dialog,
28
+ DialogActions,
29
+ DialogContent,
30
+ DialogTitle,
31
+ } from '@mui/material';
32
+ import {
33
+ CubesLoadingIndicator,
34
+ CubesLoadingIndicatorIcon,
35
+ } from '@finos/legend-art';
36
+ import { guaranteeNonNullable, isNonNullable } from '@finos/legend-shared';
37
+ import type {
38
+ ContractConsumerTypeRendererConfig,
39
+ DataProductDataAccessState,
40
+ } from '../../../stores/DataProduct/DataProductDataAccessState.js';
41
+ import {
42
+ AccessPointGroupAccess,
43
+ type DataProductAPGState,
44
+ } from '../../../stores/DataProduct/DataProductAPGState.js';
45
+
46
+ export const EntitlementsDataContractCreator = observer(
47
+ (props: {
48
+ open: boolean;
49
+ onClose: () => void;
50
+ token: string | undefined;
51
+ apgState: DataProductAPGState;
52
+ dataAccessState: DataProductDataAccessState;
53
+ }) => {
54
+ const { open, onClose, token, apgState, dataAccessState } = props;
55
+ const viewerState = dataAccessState.dataProductViewerState;
56
+ const accessPointGroup = guaranteeNonNullable(
57
+ dataAccessState.dataContractAccessPointGroup,
58
+ 'Cannot show DataContractCreator. No access point group is selected.',
59
+ );
60
+ const consumerTypeRendererConfigs: ContractConsumerTypeRendererConfig[] =
61
+ useMemo(
62
+ () =>
63
+ dataAccessState.dataAccessPlugins
64
+ .map((plugin) => plugin.getContractConsumerTypeRendererConfigs?.())
65
+ .flat()
66
+ .filter(isNonNullable)
67
+ .filter(
68
+ (rendererConfig: ContractConsumerTypeRendererConfig) =>
69
+ apgState.access !== AccessPointGroupAccess.ENTERPRISE ||
70
+ rendererConfig.enableForEnterpriseAPGs,
71
+ ),
72
+ [apgState.access, dataAccessState.dataAccessPlugins],
73
+ );
74
+ const [selectedConsumerType, setSelectedConsumerType] = useState<string>(
75
+ consumerTypeRendererConfigs[0]?.type ?? '',
76
+ );
77
+ const [consumer, setConsumer] = useState<
78
+ V1_OrganizationalScope | undefined
79
+ >();
80
+ const [description, setDescription] = useState<string | undefined>();
81
+ const [isValid, setIsValid] = useState<boolean>(false);
82
+
83
+ const currentConsumerTypeComponent = useMemo(
84
+ () =>
85
+ consumerTypeRendererConfigs
86
+ .find((config) => config.type === selectedConsumerType)
87
+ ?.createContractRenderer(
88
+ apgState,
89
+ setConsumer,
90
+ setDescription,
91
+ setIsValid,
92
+ ),
93
+ [apgState, consumerTypeRendererConfigs, selectedConsumerType],
94
+ );
95
+
96
+ const onCreate = (): void => {
97
+ if (isValid && consumer && description) {
98
+ flowResult(
99
+ dataAccessState.createContract(
100
+ consumer,
101
+ description,
102
+ accessPointGroup,
103
+ token,
104
+ ),
105
+ ).catch(viewerState.applicationStore.alertUnhandledError);
106
+ }
107
+ };
108
+
109
+ const dataProductTitle =
110
+ viewerState.product.title ??
111
+ viewerState.product.path.split(ELEMENT_PATH_DELIMITER).pop();
112
+
113
+ return (
114
+ <Dialog open={open} onClose={onClose} fullWidth={true} maxWidth="md">
115
+ <DialogTitle>Data Contract Request</DialogTitle>
116
+ <DialogContent className="marketplace-lakehouse-entitlements__data-contract-creator__content">
117
+ <CubesLoadingIndicator
118
+ isLoading={dataAccessState.creatingContractState.isInProgress}
119
+ >
120
+ <CubesLoadingIndicatorIcon />
121
+ </CubesLoadingIndicator>
122
+ {!dataAccessState.creatingContractState.isInProgress && (
123
+ <>
124
+ <div>
125
+ Submit access request for{' '}
126
+ <span className="marketplace-lakehouse-text__emphasis">
127
+ {accessPointGroup.id}
128
+ </span>{' '}
129
+ Access Point Group in{' '}
130
+ <span className="marketplace-lakehouse-text__emphasis">
131
+ {dataProductTitle}
132
+ </span>{' '}
133
+ Data Product
134
+ </div>
135
+ <ButtonGroup
136
+ className="marketplace-lakehouse-entitlements__data-contract-creator__consumer-type-btn-group"
137
+ variant="contained"
138
+ >
139
+ {consumerTypeRendererConfigs.map((config) => (
140
+ <Button
141
+ key={config.type}
142
+ variant={
143
+ selectedConsumerType === config.type
144
+ ? 'contained'
145
+ : 'outlined'
146
+ }
147
+ onClick={(): void => {
148
+ if (config.type !== selectedConsumerType) {
149
+ setSelectedConsumerType(config.type);
150
+ }
151
+ }}
152
+ >
153
+ {config.type}
154
+ </Button>
155
+ ))}
156
+ </ButtonGroup>
157
+ {currentConsumerTypeComponent}
158
+ </>
159
+ )}
160
+ </DialogContent>
161
+ <DialogActions>
162
+ <Button
163
+ onClick={onCreate}
164
+ variant="contained"
165
+ disabled={
166
+ dataAccessState.creatingContractState.isInProgress || !isValid
167
+ }
168
+ >
169
+ Create
170
+ </Button>
171
+ <Button
172
+ onClick={onClose}
173
+ variant="outlined"
174
+ disabled={dataAccessState.creatingContractState.isInProgress}
175
+ >
176
+ Cancel
177
+ </Button>
178
+ </DialogActions>
179
+ </Dialog>
180
+ );
181
+ },
182
+ );