Compare commits
No commits in common. "19a39bc4439ea11cd60c0c52b17a246278b45b78" and "b21fa78665d1cb027b896de8961b8d19a468488b" have entirely different histories.
19a39bc443
...
b21fa78665
3 changed files with 8 additions and 61 deletions
|
|
@ -9,7 +9,6 @@ import React, {
|
||||||
useRef,
|
useRef,
|
||||||
useEffect,
|
useEffect,
|
||||||
useImperativeHandle,
|
useImperativeHandle,
|
||||||
useMemo,
|
|
||||||
forwardRef,
|
forwardRef,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { ProviderMultiSelect } from '../../../components/ProviderSelector';
|
import { ProviderMultiSelect } from '../../../components/ProviderSelector';
|
||||||
|
|
@ -70,8 +69,6 @@ interface WorkspaceInputProps {
|
||||||
workflowId?: string | null;
|
workflowId?: string | null;
|
||||||
loadedAttachedDataSourceIds?: string[];
|
loadedAttachedDataSourceIds?: string[];
|
||||||
loadedAttachedFeatureDataSourceIds?: string[];
|
loadedAttachedFeatureDataSourceIds?: string[];
|
||||||
loadedDataSourceLabels?: Record<string, string>;
|
|
||||||
loadedFeatureDataSourceLabels?: Record<string, string>;
|
|
||||||
loadedNonce?: number;
|
loadedNonce?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,8 +135,6 @@ export const WorkspaceInput = forwardRef<WorkspaceInputHandle, WorkspaceInputPro
|
||||||
workflowId,
|
workflowId,
|
||||||
loadedAttachedDataSourceIds,
|
loadedAttachedDataSourceIds,
|
||||||
loadedAttachedFeatureDataSourceIds,
|
loadedAttachedFeatureDataSourceIds,
|
||||||
loadedDataSourceLabels,
|
|
||||||
loadedFeatureDataSourceLabels,
|
|
||||||
loadedNonce,
|
loadedNonce,
|
||||||
}, ref) {
|
}, ref) {
|
||||||
const { t } = useLanguage();
|
const { t } = useLanguage();
|
||||||
|
|
@ -159,34 +154,6 @@ export const WorkspaceInput = forwardRef<WorkspaceInputHandle, WorkspaceInputPro
|
||||||
const [neutralizeActive, setNeutralizeActive] = useState(false);
|
const [neutralizeActive, setNeutralizeActive] = useState(false);
|
||||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
const dsLabelCache = useRef<Map<string, string>>(new Map());
|
const dsLabelCache = useRef<Map<string, string>>(new Map());
|
||||||
const dsLabelMap = useMemo(() => {
|
|
||||||
const m = new Map<string, string>();
|
|
||||||
if (loadedDataSourceLabels) {
|
|
||||||
for (const [k, v] of Object.entries(loadedDataSourceLabels)) {
|
|
||||||
if (v) m.set(k, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dsLabelCache.current.forEach((v, k) => { if (!m.has(k)) m.set(k, v); });
|
|
||||||
for (const ds of dataSources) {
|
|
||||||
const lbl = ds.label || ds.path;
|
|
||||||
if (lbl) m.set(ds.id, lbl);
|
|
||||||
}
|
|
||||||
return m;
|
|
||||||
}, [dataSources, loadedDataSourceLabels]);
|
|
||||||
|
|
||||||
const fdsLabelMap = useMemo(() => {
|
|
||||||
const m = new Map<string, string>();
|
|
||||||
if (loadedFeatureDataSourceLabels) {
|
|
||||||
for (const [k, v] of Object.entries(loadedFeatureDataSourceLabels)) {
|
|
||||||
if (v) m.set(k, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const fds of featureDataSources) {
|
|
||||||
const lbl = fds.label || fds.tableName;
|
|
||||||
if (lbl) m.set(fds.id, lbl);
|
|
||||||
}
|
|
||||||
return m;
|
|
||||||
}, [featureDataSources, loadedFeatureDataSourceLabels]);
|
|
||||||
|
|
||||||
const _appendAttachment = useCallback((item: AttachmentItem) => {
|
const _appendAttachment = useCallback((item: AttachmentItem) => {
|
||||||
setAttachments(prev => prev.some(a => a.id === item.id) ? prev : [...prev, item]);
|
setAttachments(prev => prev.some(a => a.id === item.id) ? prev : [...prev, item]);
|
||||||
|
|
@ -267,32 +234,26 @@ export const WorkspaceInput = forwardRef<WorkspaceInputHandle, WorkspaceInputPro
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (loadedNonce === undefined) return;
|
if (loadedNonce === undefined) return;
|
||||||
if (_reconciledDsForNonce.current === loadedNonce) return;
|
if (_reconciledDsForNonce.current === loadedNonce) return;
|
||||||
if (dataSources.length === 0 && !loadedDataSourceLabels) return;
|
if (dataSources.length === 0) return;
|
||||||
_reconciledDsForNonce.current = loadedNonce;
|
_reconciledDsForNonce.current = loadedNonce;
|
||||||
for (const ds of dataSources) {
|
|
||||||
const lbl = ds.label || ds.path;
|
|
||||||
if (lbl) dsLabelCache.current.set(ds.id, lbl);
|
|
||||||
}
|
|
||||||
const validIds = new Set(dataSources.map(d => d.id));
|
const validIds = new Set(dataSources.map(d => d.id));
|
||||||
const labeledIds = new Set(Object.keys(loadedDataSourceLabels || {}));
|
|
||||||
setAttachedDataSourceIds(prev => {
|
setAttachedDataSourceIds(prev => {
|
||||||
const filtered = prev.filter(id => validIds.has(id) || labeledIds.has(id));
|
const filtered = prev.filter(id => validIds.has(id));
|
||||||
return filtered.length === prev.length ? prev : filtered;
|
return filtered.length === prev.length ? prev : filtered;
|
||||||
});
|
});
|
||||||
}, [loadedNonce, dataSources, loadedDataSourceLabels]);
|
}, [loadedNonce, dataSources]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (loadedNonce === undefined) return;
|
if (loadedNonce === undefined) return;
|
||||||
if (_reconciledFdsForNonce.current === loadedNonce) return;
|
if (_reconciledFdsForNonce.current === loadedNonce) return;
|
||||||
if (featureDataSources.length === 0 && !loadedFeatureDataSourceLabels) return;
|
if (featureDataSources.length === 0) return;
|
||||||
_reconciledFdsForNonce.current = loadedNonce;
|
_reconciledFdsForNonce.current = loadedNonce;
|
||||||
const validIds = new Set(featureDataSources.map(d => d.id));
|
const validIds = new Set(featureDataSources.map(d => d.id));
|
||||||
const labeledIds = new Set(Object.keys(loadedFeatureDataSourceLabels || {}));
|
|
||||||
setAttachedFeatureDataSourceIds(prev => {
|
setAttachedFeatureDataSourceIds(prev => {
|
||||||
const filtered = prev.filter(id => validIds.has(id) || labeledIds.has(id));
|
const filtered = prev.filter(id => validIds.has(id));
|
||||||
return filtered.length === prev.length ? prev : filtered;
|
return filtered.length === prev.length ? prev : filtered;
|
||||||
});
|
});
|
||||||
}, [loadedNonce, featureDataSources, loadedFeatureDataSourceLabels]);
|
}, [loadedNonce, featureDataSources]);
|
||||||
|
|
||||||
const promptBeforeVoiceRef = useRef('');
|
const promptBeforeVoiceRef = useRef('');
|
||||||
const finalizedTextRef = useRef('');
|
const finalizedTextRef = useRef('');
|
||||||
|
|
@ -702,7 +663,7 @@ export const WorkspaceInput = forwardRef<WorkspaceInputHandle, WorkspaceInputPro
|
||||||
background: '#e8f5e9', color: '#2e7d32', fontWeight: 500,
|
background: '#e8f5e9', color: '#2e7d32', fontWeight: 500,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
🔗 {ds?.label || ds?.path || dsLabelMap.get(dsId) || dsId}
|
🔗 {ds?.label || ds?.path || dsLabelCache.current.get(dsId) || dsId}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => _removeAttachedDataSource(dsId)}
|
onClick={() => _removeAttachedDataSource(dsId)}
|
||||||
|
|
@ -729,7 +690,7 @@ export const WorkspaceInput = forwardRef<WorkspaceInputHandle, WorkspaceInputPro
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span style={{ display: 'flex', alignItems: 'center', fontSize: 12 }}>{fdsIcon || '\uD83D\uDDC3\uFE0F'}</span>
|
<span style={{ display: 'flex', alignItems: 'center', fontSize: 12 }}>{fdsIcon || '\uD83D\uDDC3\uFE0F'}</span>
|
||||||
{fds?.label || fdsLabelMap.get(fdsId) || fdsId} – {fds?.tableName || ''}
|
{fds?.label || fdsId} – {fds?.tableName || ''}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => _toggleFeatureDataSource(fdsId)}
|
onClick={() => _toggleFeatureDataSource(fdsId)}
|
||||||
|
|
|
||||||
|
|
@ -571,8 +571,6 @@ export const WorkspacePage: React.FC<WorkspacePageProps> = ({ persistentInstance
|
||||||
workflowId={workspace.workflowId}
|
workflowId={workspace.workflowId}
|
||||||
loadedAttachedDataSourceIds={workspace.loadedAttachedDataSourceIds}
|
loadedAttachedDataSourceIds={workspace.loadedAttachedDataSourceIds}
|
||||||
loadedAttachedFeatureDataSourceIds={workspace.loadedAttachedFeatureDataSourceIds}
|
loadedAttachedFeatureDataSourceIds={workspace.loadedAttachedFeatureDataSourceIds}
|
||||||
loadedDataSourceLabels={workspace.loadedDataSourceLabels}
|
|
||||||
loadedFeatureDataSourceLabels={workspace.loadedFeatureDataSourceLabels}
|
|
||||||
loadedNonce={workspace.loadedNonce}
|
loadedNonce={workspace.loadedNonce}
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,6 @@ interface UseWorkspaceReturn {
|
||||||
*/
|
*/
|
||||||
loadedAttachedDataSourceIds: string[];
|
loadedAttachedDataSourceIds: string[];
|
||||||
loadedAttachedFeatureDataSourceIds: string[];
|
loadedAttachedFeatureDataSourceIds: string[];
|
||||||
loadedDataSourceLabels: Record<string, string>;
|
|
||||||
loadedFeatureDataSourceLabels: Record<string, string>;
|
|
||||||
loadedNonce: number;
|
loadedNonce: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,8 +138,6 @@ export function useWorkspace(instanceId: string): UseWorkspaceReturn {
|
||||||
const [dataSourceAccesses, setDataSourceAccesses] = useState<DataSourceAccessEvent[]>([]);
|
const [dataSourceAccesses, setDataSourceAccesses] = useState<DataSourceAccessEvent[]>([]);
|
||||||
const [loadedAttachedDataSourceIds, setLoadedAttachedDataSourceIds] = useState<string[]>([]);
|
const [loadedAttachedDataSourceIds, setLoadedAttachedDataSourceIds] = useState<string[]>([]);
|
||||||
const [loadedAttachedFeatureDataSourceIds, setLoadedAttachedFeatureDataSourceIds] = useState<string[]>([]);
|
const [loadedAttachedFeatureDataSourceIds, setLoadedAttachedFeatureDataSourceIds] = useState<string[]>([]);
|
||||||
const [loadedDataSourceLabels, setLoadedDataSourceLabels] = useState<Record<string, string>>({});
|
|
||||||
const [loadedFeatureDataSourceLabels, setLoadedFeatureDataSourceLabels] = useState<Record<string, string>>({});
|
|
||||||
const [loadedNonce, setLoadedNonce] = useState(0);
|
const [loadedNonce, setLoadedNonce] = useState(0);
|
||||||
const cleanupRef = useRef<(() => void) | null>(null);
|
const cleanupRef = useRef<(() => void) | null>(null);
|
||||||
|
|
||||||
|
|
@ -196,12 +192,8 @@ export function useWorkspace(instanceId: string): UseWorkspaceReturn {
|
||||||
const fdsIds: string[] = Array.isArray(res.data.attachedFeatureDataSourceIds)
|
const fdsIds: string[] = Array.isArray(res.data.attachedFeatureDataSourceIds)
|
||||||
? res.data.attachedFeatureDataSourceIds.map((x: unknown) => String(x))
|
? res.data.attachedFeatureDataSourceIds.map((x: unknown) => String(x))
|
||||||
: [];
|
: [];
|
||||||
const dsLabels: Record<string, string> = res.data.attachedDataSourceLabels || {};
|
|
||||||
const fdsLabels: Record<string, string> = res.data.attachedFeatureDataSourceLabels || {};
|
|
||||||
setLoadedAttachedDataSourceIds(dsIds);
|
setLoadedAttachedDataSourceIds(dsIds);
|
||||||
setLoadedAttachedFeatureDataSourceIds(fdsIds);
|
setLoadedAttachedFeatureDataSourceIds(fdsIds);
|
||||||
setLoadedDataSourceLabels(dsLabels);
|
|
||||||
setLoadedFeatureDataSourceLabels(fdsLabels);
|
|
||||||
setLoadedNonce(n => n + 1);
|
setLoadedNonce(n => n + 1);
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
@ -216,8 +208,6 @@ export function useWorkspace(instanceId: string): UseWorkspaceReturn {
|
||||||
setDataSourceAccesses([]);
|
setDataSourceAccesses([]);
|
||||||
setLoadedAttachedDataSourceIds([]);
|
setLoadedAttachedDataSourceIds([]);
|
||||||
setLoadedAttachedFeatureDataSourceIds([]);
|
setLoadedAttachedFeatureDataSourceIds([]);
|
||||||
setLoadedDataSourceLabels({});
|
|
||||||
setLoadedFeatureDataSourceLabels({});
|
|
||||||
setLoadedNonce(n => n + 1);
|
setLoadedNonce(n => n + 1);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
@ -538,8 +528,6 @@ export function useWorkspace(instanceId: string): UseWorkspaceReturn {
|
||||||
dataSourceAccesses,
|
dataSourceAccesses,
|
||||||
loadedAttachedDataSourceIds,
|
loadedAttachedDataSourceIds,
|
||||||
loadedAttachedFeatureDataSourceIds,
|
loadedAttachedFeatureDataSourceIds,
|
||||||
loadedDataSourceLabels,
|
|
||||||
loadedFeatureDataSourceLabels,
|
|
||||||
loadedNonce,
|
loadedNonce,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue