@finos/legend-application-marketplace 0.2.13 → 0.2.15
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__/LegendMarketplaceNavigation.d.ts +2 -0
- package/lib/__lib__/LegendMarketplaceNavigation.d.ts.map +1 -1
- package/lib/__lib__/LegendMarketplaceNavigation.js +4 -0
- package/lib/__lib__/LegendMarketplaceNavigation.js.map +1 -1
- package/lib/application/LegendMarketplaceApplicationConfig.d.ts +9 -0
- package/lib/application/LegendMarketplaceApplicationConfig.d.ts.map +1 -1
- package/lib/application/LegendMarketplaceApplicationConfig.js +40 -22
- package/lib/application/LegendMarketplaceApplicationConfig.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/application/__test-utils__/LegendMarketplaceApplicationTestUtils.d.ts.map +1 -1
- package/lib/application/__test-utils__/LegendMarketplaceApplicationTestUtils.js +7 -0
- package/lib/application/__test-utils__/LegendMarketplaceApplicationTestUtils.js.map +1 -1
- package/lib/application/providers/LegendMarketplaceAIChatStoreProvider.d.ts +21 -0
- package/lib/application/providers/LegendMarketplaceAIChatStoreProvider.d.ts.map +1 -0
- package/lib/application/providers/LegendMarketplaceAIChatStoreProvider.js +29 -0
- package/lib/application/providers/LegendMarketplaceAIChatStoreProvider.js.map +1 -0
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/pages/Agents/LegendMarketplaceAgents.d.ts.map +1 -1
- package/lib/pages/Agents/LegendMarketplaceAgents.js +49 -17
- package/lib/pages/Agents/LegendMarketplaceAgents.js.map +1 -1
- package/lib/pages/Agents/MarketplaceAIChatView.d.ts +21 -0
- package/lib/pages/Agents/MarketplaceAIChatView.d.ts.map +1 -0
- package/lib/pages/Agents/MarketplaceAIChatView.js +141 -0
- package/lib/pages/Agents/MarketplaceAIChatView.js.map +1 -0
- package/lib/pages/Agents/MarketplaceAIInputBar.d.ts +22 -0
- package/lib/pages/Agents/MarketplaceAIInputBar.d.ts.map +1 -0
- package/lib/pages/Agents/MarketplaceAIInputBar.js +40 -0
- package/lib/pages/Agents/MarketplaceAIInputBar.js.map +1 -0
- package/lib/pages/Agents/MarketplaceAIProductAutosuggest.d.ts +25 -0
- package/lib/pages/Agents/MarketplaceAIProductAutosuggest.d.ts.map +1 -0
- package/lib/pages/Agents/MarketplaceAIProductAutosuggest.js +86 -0
- package/lib/pages/Agents/MarketplaceAIProductAutosuggest.js.map +1 -0
- package/lib/pages/Agents/MarketplaceAIProductCards.d.ts +23 -0
- package/lib/pages/Agents/MarketplaceAIProductCards.d.ts.map +1 -0
- package/lib/pages/Agents/MarketplaceAIProductCards.js +20 -0
- package/lib/pages/Agents/MarketplaceAIProductCards.js.map +1 -0
- package/lib/pages/Agents/MarketplaceAIScopeSelector.d.ts +19 -0
- package/lib/pages/Agents/MarketplaceAIScopeSelector.d.ts.map +1 -0
- package/lib/pages/Agents/MarketplaceAIScopeSelector.js +46 -0
- package/lib/pages/Agents/MarketplaceAIScopeSelector.js.map +1 -0
- package/lib/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.d.ts.map +1 -1
- package/lib/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.js +74 -63
- 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 +85 -69
- 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 +7 -11
- package/lib/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.js.map +1 -1
- package/lib/pages/Lakehouse/entitlements/PermitDataAccessRequest.d.ts +17 -0
- package/lib/pages/Lakehouse/entitlements/PermitDataAccessRequest.d.ts.map +1 -0
- package/lib/pages/Lakehouse/entitlements/PermitDataAccessRequest.js +126 -0
- package/lib/pages/Lakehouse/entitlements/PermitDataAccessRequest.js.map +1 -0
- package/lib/pages/Lakehouse/entitlements/WorkflowDataAccessRequest.d.ts.map +1 -1
- package/lib/pages/Lakehouse/entitlements/WorkflowDataAccessRequest.js +23 -65
- package/lib/pages/Lakehouse/entitlements/WorkflowDataAccessRequest.js.map +1 -1
- package/lib/pages/Lakehouse/entitlements/showTaskActionAlert.d.ts +29 -0
- package/lib/pages/Lakehouse/entitlements/showTaskActionAlert.d.ts.map +1 -0
- package/lib/pages/Lakehouse/entitlements/showTaskActionAlert.js +60 -0
- package/lib/pages/Lakehouse/entitlements/showTaskActionAlert.js.map +1 -0
- package/lib/pages/Lakehouse/searchResults/LegendMarketplaceSearchResults.d.ts.map +1 -1
- package/lib/pages/Lakehouse/searchResults/LegendMarketplaceSearchResults.js +3 -8
- package/lib/pages/Lakehouse/searchResults/LegendMarketplaceSearchResults.js.map +1 -1
- package/lib/stores/LegendMarketplaceBaseStore.d.ts +2 -1
- package/lib/stores/LegendMarketplaceBaseStore.d.ts.map +1 -1
- package/lib/stores/LegendMarketplaceBaseStore.js +8 -1
- package/lib/stores/LegendMarketplaceBaseStore.js.map +1 -1
- package/lib/stores/ai/LegendMarketplaceAIChatStore.d.ts +109 -0
- package/lib/stores/ai/LegendMarketplaceAIChatStore.d.ts.map +1 -0
- package/lib/stores/ai/LegendMarketplaceAIChatStore.js +1106 -0
- package/lib/stores/ai/LegendMarketplaceAIChatStore.js.map +1 -0
- package/lib/stores/lakehouse/LegendMarketplaceProductViewerStore.d.ts.map +1 -1
- package/lib/stores/lakehouse/LegendMarketplaceProductViewerStore.js +3 -2
- package/lib/stores/lakehouse/LegendMarketplaceProductViewerStore.js.map +1 -1
- package/lib/stores/lakehouse/dataProducts/ProductCardState.d.ts +1 -1
- package/lib/stores/lakehouse/dataProducts/ProductCardState.d.ts.map +1 -1
- package/lib/stores/lakehouse/dataProducts/ProductCardState.js +1 -2
- package/lib/stores/lakehouse/dataProducts/ProductCardState.js.map +1 -1
- package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.d.ts +30 -3
- package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.d.ts.map +1 -1
- package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.js +94 -16
- package/lib/stores/lakehouse/entitlements/EntitlementsDashboardState.js.map +1 -1
- package/lib/utils/EntitlementsUtils.d.ts +36 -2
- package/lib/utils/EntitlementsUtils.d.ts.map +1 -1
- package/lib/utils/EntitlementsUtils.js +225 -46
- package/lib/utils/EntitlementsUtils.js.map +1 -1
- package/lib/utils/SearchUtils.d.ts.map +1 -1
- package/lib/utils/SearchUtils.js +7 -4
- package/lib/utils/SearchUtils.js.map +1 -1
- package/package.json +10 -10
- package/src/__lib__/LegendMarketplaceNavigation.ts +11 -0
- package/src/application/LegendMarketplaceApplicationConfig.ts +62 -24
- package/src/application/LegendMarketplaceWebApplication.tsx +15 -0
- package/src/application/__test-utils__/LegendMarketplaceApplicationTestUtils.ts +7 -0
- package/src/application/providers/LegendMarketplaceAIChatStoreProvider.tsx +47 -0
- package/src/pages/Agents/LegendMarketplaceAgents.tsx +145 -23
- package/src/pages/Agents/MarketplaceAIChatView.tsx +555 -0
- package/src/pages/Agents/MarketplaceAIInputBar.tsx +91 -0
- package/src/pages/Agents/MarketplaceAIProductAutosuggest.tsx +181 -0
- package/src/pages/Agents/MarketplaceAIProductCards.tsx +111 -0
- package/src/pages/Agents/MarketplaceAIScopeSelector.tsx +84 -0
- package/src/pages/Lakehouse/entitlements/EntitlementsClosedContractsDashboard.tsx +131 -136
- package/src/pages/Lakehouse/entitlements/EntitlementsPendingContractsDashboard.tsx +158 -165
- package/src/pages/Lakehouse/entitlements/EntitlementsPendingTasksDashboard.tsx +12 -17
- package/src/pages/Lakehouse/entitlements/PermitDataAccessRequest.tsx +245 -0
- package/src/pages/Lakehouse/entitlements/WorkflowDataAccessRequest.tsx +25 -94
- package/src/pages/Lakehouse/entitlements/showTaskActionAlert.tsx +101 -0
- package/src/pages/Lakehouse/searchResults/LegendMarketplaceSearchResults.tsx +27 -31
- package/src/stores/LegendMarketplaceBaseStore.ts +12 -0
- package/src/stores/ai/LegendMarketplaceAIChatStore.ts +1720 -0
- package/src/stores/lakehouse/LegendMarketplaceProductViewerStore.ts +6 -0
- package/src/stores/lakehouse/dataProducts/ProductCardState.ts +3 -4
- package/src/stores/lakehouse/entitlements/EntitlementsDashboardState.ts +181 -48
- package/src/utils/EntitlementsUtils.tsx +341 -86
- package/src/utils/SearchUtils.tsx +7 -4
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026-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 { useState, useRef, useEffect, useCallback, useMemo } from 'react';
|
|
18
|
+
import { observer } from 'mobx-react-lite';
|
|
19
|
+
import { SearchIcon, TimesIcon } from '@finos/legend-art';
|
|
20
|
+
import { debounce, noop } from '@finos/legend-shared';
|
|
21
|
+
import type { AutosuggestResult } from '@finos/legend-server-marketplace';
|
|
22
|
+
import { useLegendMarketplaceAIChatStore } from '../../application/providers/LegendMarketplaceAIChatStoreProvider.js';
|
|
23
|
+
|
|
24
|
+
const AUTOSUGGEST_DEBOUNCE_MS = 300;
|
|
25
|
+
const AUTOSUGGEST_LIMIT = 6;
|
|
26
|
+
|
|
27
|
+
export const MarketplaceAIProductAutosuggest = observer(
|
|
28
|
+
(props: {
|
|
29
|
+
onSelect: (result: AutosuggestResult) => void;
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
className?: string;
|
|
32
|
+
autoFocus?: boolean;
|
|
33
|
+
}): React.ReactNode => {
|
|
34
|
+
const {
|
|
35
|
+
onSelect,
|
|
36
|
+
placeholder = 'Search data products...',
|
|
37
|
+
className,
|
|
38
|
+
autoFocus,
|
|
39
|
+
} = props;
|
|
40
|
+
const store = useLegendMarketplaceAIChatStore();
|
|
41
|
+
const [searchText, setSearchText] = useState('');
|
|
42
|
+
const [results, setResults] = useState<AutosuggestResult[]>([]);
|
|
43
|
+
const [isSearching, setIsSearching] = useState(false);
|
|
44
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
45
|
+
const abortControllerRef = useRef<AbortController | undefined>(undefined);
|
|
46
|
+
|
|
47
|
+
const fetchResults = useCallback(
|
|
48
|
+
async (query: string, signal?: AbortSignal): Promise<void> => {
|
|
49
|
+
if (!query.trim()) {
|
|
50
|
+
setResults([]);
|
|
51
|
+
setIsSearching(false);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
setIsSearching(true);
|
|
55
|
+
try {
|
|
56
|
+
const response =
|
|
57
|
+
await store.baseStore.marketplaceServerClient.getAutosuggestions(
|
|
58
|
+
query,
|
|
59
|
+
store.baseStore.envState.lakehouseEnvironment,
|
|
60
|
+
AUTOSUGGEST_LIMIT,
|
|
61
|
+
signal,
|
|
62
|
+
);
|
|
63
|
+
if (!signal?.aborted) {
|
|
64
|
+
setResults(response.results);
|
|
65
|
+
setIsSearching(false);
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
if (!signal?.aborted) {
|
|
69
|
+
setResults([]);
|
|
70
|
+
setIsSearching(false);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
[store.baseStore],
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const debouncedFetch = useMemo(
|
|
78
|
+
() =>
|
|
79
|
+
debounce((query: string) => {
|
|
80
|
+
if (abortControllerRef.current) {
|
|
81
|
+
abortControllerRef.current.abort();
|
|
82
|
+
}
|
|
83
|
+
const controller = new AbortController();
|
|
84
|
+
abortControllerRef.current = controller;
|
|
85
|
+
fetchResults(query, controller.signal).catch(noop());
|
|
86
|
+
}, AUTOSUGGEST_DEBOUNCE_MS),
|
|
87
|
+
[fetchResults],
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const handleSearchChange = useCallback(
|
|
91
|
+
(value: string): void => {
|
|
92
|
+
setSearchText(value);
|
|
93
|
+
debouncedFetch(value);
|
|
94
|
+
},
|
|
95
|
+
[debouncedFetch],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const handleSelectResult = useCallback(
|
|
99
|
+
(result: AutosuggestResult): void => {
|
|
100
|
+
onSelect(result);
|
|
101
|
+
setSearchText('');
|
|
102
|
+
setResults([]);
|
|
103
|
+
},
|
|
104
|
+
[onSelect],
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
useEffect(
|
|
108
|
+
() => () => {
|
|
109
|
+
debouncedFetch.cancel();
|
|
110
|
+
if (abortControllerRef.current) {
|
|
111
|
+
abortControllerRef.current.abort();
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
[debouncedFetch],
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const rootClass = className
|
|
118
|
+
? `ai-product-autosuggest ${className}`
|
|
119
|
+
: 'ai-product-autosuggest';
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<div className={rootClass}>
|
|
123
|
+
<div className="ai-product-autosuggest__search">
|
|
124
|
+
<SearchIcon />
|
|
125
|
+
<input
|
|
126
|
+
ref={inputRef}
|
|
127
|
+
type="text"
|
|
128
|
+
className="ai-product-autosuggest__input"
|
|
129
|
+
placeholder={placeholder}
|
|
130
|
+
autoFocus={autoFocus}
|
|
131
|
+
value={searchText}
|
|
132
|
+
onChange={(e): void => handleSearchChange(e.target.value)}
|
|
133
|
+
/>
|
|
134
|
+
{searchText && (
|
|
135
|
+
<button
|
|
136
|
+
type="button"
|
|
137
|
+
className="ai-product-autosuggest__clear"
|
|
138
|
+
onClick={(): void => {
|
|
139
|
+
setSearchText('');
|
|
140
|
+
setResults([]);
|
|
141
|
+
inputRef.current?.focus();
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<TimesIcon />
|
|
145
|
+
</button>
|
|
146
|
+
)}
|
|
147
|
+
</div>
|
|
148
|
+
{(isSearching || results.length > 0 || searchText) && (
|
|
149
|
+
<div className="ai-product-autosuggest__results">
|
|
150
|
+
{isSearching && (
|
|
151
|
+
<div className="ai-product-autosuggest__status">Searching...</div>
|
|
152
|
+
)}
|
|
153
|
+
{!isSearching && searchText && results.length === 0 && (
|
|
154
|
+
<div className="ai-product-autosuggest__status">
|
|
155
|
+
No products found
|
|
156
|
+
</div>
|
|
157
|
+
)}
|
|
158
|
+
{!isSearching &&
|
|
159
|
+
results.map((r) => (
|
|
160
|
+
<button
|
|
161
|
+
key={`${r.dataProductDetails.groupId}:${r.dataProductDetails.artifactId}`}
|
|
162
|
+
type="button"
|
|
163
|
+
className="ai-product-autosuggest__item"
|
|
164
|
+
onClick={(): void => handleSelectResult(r)}
|
|
165
|
+
>
|
|
166
|
+
<div className="ai-product-autosuggest__item-name">
|
|
167
|
+
{r.dataProductName}
|
|
168
|
+
</div>
|
|
169
|
+
{r.dataProductDescription && (
|
|
170
|
+
<div className="ai-product-autosuggest__item-desc">
|
|
171
|
+
{r.dataProductDescription}
|
|
172
|
+
</div>
|
|
173
|
+
)}
|
|
174
|
+
</button>
|
|
175
|
+
))}
|
|
176
|
+
</div>
|
|
177
|
+
)}
|
|
178
|
+
</div>
|
|
179
|
+
);
|
|
180
|
+
},
|
|
181
|
+
);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026-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 type { DataProductSearchResult } from '@finos/legend-server-marketplace';
|
|
18
|
+
import { CheckIcon, TimesIcon, CaretRightIcon } from '@finos/legend-art';
|
|
19
|
+
import {
|
|
20
|
+
type ScoredProductCandidate,
|
|
21
|
+
unwrapProductDetails,
|
|
22
|
+
} from '../../stores/ai/LegendMarketplaceAIChatStore.js';
|
|
23
|
+
|
|
24
|
+
const DESCRIPTION_TRUNCATION_LENGTH = 120;
|
|
25
|
+
const UNKNOWN_PRODUCT_LABEL = 'Unknown Product';
|
|
26
|
+
|
|
27
|
+
export const MarketplaceAIProductCards = (props: {
|
|
28
|
+
products: DataProductSearchResult[];
|
|
29
|
+
scoredCandidates?: ScoredProductCandidate[];
|
|
30
|
+
onSelect: (product: DataProductSearchResult) => void;
|
|
31
|
+
}): React.ReactNode => {
|
|
32
|
+
const { products, scoredCandidates, onSelect } = props;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="legend-ai__product-cards">
|
|
36
|
+
{products.map((product, idx) => {
|
|
37
|
+
const candidate = scoredCandidates?.[idx];
|
|
38
|
+
const hasFieldInfo =
|
|
39
|
+
candidate &&
|
|
40
|
+
(candidate.matchedFields.length > 0 ||
|
|
41
|
+
candidate.missingFields.length > 0);
|
|
42
|
+
|
|
43
|
+
const { groupId, artifactId } = unwrapProductDetails(product);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<button
|
|
47
|
+
key={`${groupId}:${artifactId}`}
|
|
48
|
+
type="button"
|
|
49
|
+
className="legend-ai__product-card"
|
|
50
|
+
onClick={(): void => onSelect(product)}
|
|
51
|
+
>
|
|
52
|
+
<div className="legend-ai__product-card-title">
|
|
53
|
+
{product.dataProductTitle ?? UNKNOWN_PRODUCT_LABEL}
|
|
54
|
+
</div>
|
|
55
|
+
{product.dataProductDescription && (
|
|
56
|
+
<div className="legend-ai__product-card-desc">
|
|
57
|
+
{product.dataProductDescription.length >
|
|
58
|
+
DESCRIPTION_TRUNCATION_LENGTH
|
|
59
|
+
? `${product.dataProductDescription.slice(0, DESCRIPTION_TRUNCATION_LENGTH)}...`
|
|
60
|
+
: product.dataProductDescription}
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
63
|
+
|
|
64
|
+
{hasFieldInfo && (
|
|
65
|
+
<div className="legend-ai__product-card-fields">
|
|
66
|
+
{candidate.matchedFields.map((f) => (
|
|
67
|
+
<span
|
|
68
|
+
key={f}
|
|
69
|
+
className="legend-ai__product-card-field legend-ai__product-card-field--matched"
|
|
70
|
+
>
|
|
71
|
+
{f} <CheckIcon />
|
|
72
|
+
</span>
|
|
73
|
+
))}
|
|
74
|
+
{candidate.missingFields.map((f) => (
|
|
75
|
+
<span
|
|
76
|
+
key={f}
|
|
77
|
+
className="legend-ai__product-card-field legend-ai__product-card-field--missing"
|
|
78
|
+
>
|
|
79
|
+
{f} <TimesIcon />
|
|
80
|
+
</span>
|
|
81
|
+
))}
|
|
82
|
+
</div>
|
|
83
|
+
)}
|
|
84
|
+
|
|
85
|
+
<div className="legend-ai__product-card-meta">
|
|
86
|
+
{candidate ? (
|
|
87
|
+
<span className="legend-ai__product-card-score">
|
|
88
|
+
Score: {(candidate.compositeScore * 100).toFixed(0)}%
|
|
89
|
+
</span>
|
|
90
|
+
) : (
|
|
91
|
+
product.similarity > 0 && (
|
|
92
|
+
<span className="legend-ai__product-card-score">
|
|
93
|
+
Match: {(product.similarity * 100).toFixed(0)}%
|
|
94
|
+
</span>
|
|
95
|
+
)
|
|
96
|
+
)}
|
|
97
|
+
{product.tags1.length > 0 && (
|
|
98
|
+
<span className="legend-ai__product-card-tags">
|
|
99
|
+
{product.tags1.slice(0, 3).join(', ')}
|
|
100
|
+
</span>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
<div className="legend-ai__product-card-action">
|
|
104
|
+
Use this product <CaretRightIcon />
|
|
105
|
+
</div>
|
|
106
|
+
</button>
|
|
107
|
+
);
|
|
108
|
+
})}
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026-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 { useState, useRef, useEffect, useCallback } from 'react';
|
|
18
|
+
import { observer } from 'mobx-react-lite';
|
|
19
|
+
import { PlusIcon, DatabaseIcon } from '@finos/legend-art';
|
|
20
|
+
import type { AutosuggestResult } from '@finos/legend-server-marketplace';
|
|
21
|
+
import { useLegendMarketplaceAIChatStore } from '../../application/providers/LegendMarketplaceAIChatStoreProvider.js';
|
|
22
|
+
import { MarketplaceAIProductAutosuggest } from './MarketplaceAIProductAutosuggest.js';
|
|
23
|
+
|
|
24
|
+
const MAX_SCOPE_PRODUCTS = 3;
|
|
25
|
+
|
|
26
|
+
export const MarketplaceAIScopeSelector = observer(() => {
|
|
27
|
+
const store = useLegendMarketplaceAIChatStore();
|
|
28
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
29
|
+
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const handleClickOutside = (e: MouseEvent): void => {
|
|
33
|
+
if (
|
|
34
|
+
dropdownRef.current &&
|
|
35
|
+
e.target instanceof Node &&
|
|
36
|
+
!dropdownRef.current.contains(e.target)
|
|
37
|
+
) {
|
|
38
|
+
setIsOpen(false);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
if (isOpen) {
|
|
42
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
43
|
+
}
|
|
44
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
45
|
+
}, [isOpen]);
|
|
46
|
+
|
|
47
|
+
const handleSelectProduct = useCallback(
|
|
48
|
+
(result: AutosuggestResult): void => {
|
|
49
|
+
store.addScopeProduct(result);
|
|
50
|
+
setIsOpen(false);
|
|
51
|
+
},
|
|
52
|
+
[store],
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className="ai-scope-selector" ref={dropdownRef}>
|
|
57
|
+
{store.scopeProducts.length < MAX_SCOPE_PRODUCTS && (
|
|
58
|
+
<button
|
|
59
|
+
type="button"
|
|
60
|
+
className="ai-scope-selector__trigger"
|
|
61
|
+
title="Scope to a data product"
|
|
62
|
+
aria-label="Scope to a data product"
|
|
63
|
+
onClick={(): void => setIsOpen(true)}
|
|
64
|
+
>
|
|
65
|
+
<PlusIcon />
|
|
66
|
+
</button>
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
{isOpen && (
|
|
70
|
+
<div className="ai-scope-selector__dropdown">
|
|
71
|
+
<div className="ai-scope-selector__dropdown-header">
|
|
72
|
+
<DatabaseIcon />
|
|
73
|
+
<span>Select Data Product</span>
|
|
74
|
+
</div>
|
|
75
|
+
<MarketplaceAIProductAutosuggest
|
|
76
|
+
onSelect={handleSelectProduct}
|
|
77
|
+
className="ai-scope-selector__autosuggest"
|
|
78
|
+
autoFocus={true}
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
)}
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
});
|