mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-05 22:38:48 +00:00
query switcher bug fixed along with sample data source addition (#13266)
This commit is contained in:
parent
6dc6c37b05
commit
3f3bc1046e
2 changed files with 57 additions and 2 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 62115dd4d18e7951c8742a65045fd43f9c33d3ac
|
||||
Subproject commit eb63fab1fdbd022ad0c7b8028c63a25293cfa4cf
|
||||
|
|
@ -16,7 +16,15 @@ import './../queryManager.theme.scss';
|
|||
import { DATA_SOURCE_TYPE } from '@/_helpers/constants';
|
||||
import { workflowDefaultSources } from '../constants';
|
||||
|
||||
function DataSourceSelect({ isDisabled, selectRef, closePopup, workflowDataSources, onNewNode, staticDataSources }) {
|
||||
function DataSourceSelect({
|
||||
isDisabled,
|
||||
selectRef,
|
||||
closePopup,
|
||||
workflowDataSources,
|
||||
onNewNode,
|
||||
staticDataSources,
|
||||
sampleDataSources = [],
|
||||
}) {
|
||||
const dataSources = useDataSources();
|
||||
const globalDataSources = useGlobalDataSources();
|
||||
const sampleDataSource = useSampleDataSource();
|
||||
|
|
@ -137,6 +145,37 @@ function DataSourceSelect({ isDisabled, selectRef, closePopup, workflowDataSourc
|
|||
...userDefinedSourcesOpts,
|
||||
];
|
||||
|
||||
// Group sample data sources by kind
|
||||
const groupedSampleDataSources =
|
||||
sampleDataSources && sampleDataSources.length > 0
|
||||
? Object.entries(groupBy(sampleDataSources, 'kind')).map(([kind, sources]) => ({
|
||||
label: (
|
||||
<div>
|
||||
<DataSourceIcon source={sources[0]} height={16} />
|
||||
<span className="ms-1 small">{dataSourcesKinds.find((dsk) => dsk.kind === kind)?.name || kind}</span>
|
||||
</div>
|
||||
),
|
||||
options: sources.map((source) => ({
|
||||
label: (
|
||||
<div
|
||||
key={source.id}
|
||||
className="py-2 px-2 rounded option-nested-datasource-selector small text-truncate"
|
||||
style={{ fontSize: '13px' }}
|
||||
data-tooltip-id="tooltip-for-add-query-dd-option"
|
||||
data-tooltip-content={decodeEntities(source.name)}
|
||||
data-cy={`ds-${source.name.toLowerCase()}`}
|
||||
>
|
||||
{decodeEntities(source.name)}
|
||||
<Tooltip id="tooltip-for-add-query-dd-option" className="tooltip query-manager-ds-select-tooltip" />
|
||||
</div>
|
||||
),
|
||||
value: source.id,
|
||||
isNested: true,
|
||||
source,
|
||||
})),
|
||||
}))
|
||||
: [];
|
||||
|
||||
const dataSourcesAvailable = [
|
||||
{
|
||||
label: (
|
||||
|
|
@ -159,6 +198,22 @@ function DataSourceSelect({ isDisabled, selectRef, closePopup, workflowDataSourc
|
|||
})),
|
||||
},
|
||||
...userDefinedSourcesOpts,
|
||||
// Sample data sources group header
|
||||
...(groupedSampleDataSources.length > 0
|
||||
? [
|
||||
{
|
||||
label: (
|
||||
<div>
|
||||
<span className="color-slate9" style={{ fontWeight: 500 }}>
|
||||
Sample data sources
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
isDisabled: true,
|
||||
},
|
||||
...groupedSampleDataSources,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
|
||||
const dataSourceList = workflowDataSources && workflowDataSources ? dataSourcesAvailable : DataSourceOptions;
|
||||
|
|
|
|||
Loading…
Reference in a new issue