mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-21 21:47:17 +00:00
* add: columns and migrations for data queries and sources * add: migrations for app environments * fix: datasources and queries api * fix: import apis * add: radixui colors * create: global datasource page * fix: version creation not including global datasources queries * fix: version deletion failure * fix: ui and other bugs * add: check for abilities on global ds * fix: bugs * fix: existing test cases * fix: migration and bugs * fix: rest api oauthorize bugs * hide: add button for local ds * fix: query bugs * fix: new organization environment creation * fix: local ds label showing for new apps * fix: on page load queries for preview app and published app * fix: import bugs from v1 * fix: merge conflicts * fix: import apis * fix: apss with mulit envs * fix: ui bugs * fix: environments not being created on db:seed * fix: ui bugs * fix: route settings for global datasources * fix: customer dashboard template * fix: local ds queries not being saved * fix: runpy issues * changes: ui * fix: migration issues * fix: ui * hide datasources when no local datasources * fix: test cases * fix: unit test cases and global queries on app import/export * cleanup * add: package-lock file * undo: migration rename * cleanup * fix: ui bugs * migration fixes * fix: dark mode issues * fix: change datasource failing on query create mode * fix: workspace selector issues * fix: clickoutside for change scope option * migration changes * fix: open api issue * reverting configs changes * [Fix] Global datasources & Environment Id issue (#5830) * fix: oauth env id issue * code changes --------- Co-authored-by: gsmithun4 <gsmithun4@gmail.com> Co-authored-by: Muhsin Shah <muhsinshah21@gmail.com>
57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
import React, { useContext } from 'react';
|
|
import cx from 'classnames';
|
|
import { GlobalDataSourcesContext } from '..';
|
|
import { DataSourceTypes } from '../../Editor/DataSourceManager/SourceComponents';
|
|
import { getSvgIcon } from '@/_helpers/appUtils';
|
|
import DeleteIcon from '../Icons/DeleteIcon.svg';
|
|
|
|
export const ListItem = ({ dataSource, key, active, onDelete }) => {
|
|
const { setSelectedDataSource, toggleDataSourceManagerModal } = useContext(GlobalDataSourcesContext);
|
|
|
|
const getSourceMetaData = (dataSource) => {
|
|
if (dataSource.plugin_id) {
|
|
return dataSource.plugin?.manifest_file?.data.source;
|
|
}
|
|
|
|
return DataSourceTypes.find((source) => source.kind === dataSource.kind);
|
|
};
|
|
|
|
const sourceMeta = getSourceMetaData(dataSource);
|
|
const icon = getSvgIcon(sourceMeta.kind.toLowerCase(), 24, 24, dataSource?.plugin?.icon_file?.data);
|
|
|
|
const focusModal = () => {
|
|
const element = document.getElementsByClassName('form-control-plaintext form-control-plaintext-sm')[0];
|
|
element.focus();
|
|
};
|
|
|
|
return (
|
|
<div
|
|
key={key}
|
|
className={cx('tj-text-sm mx-3 p-2 rounded-3 mb-2 datasources-list', {
|
|
'datasources-list-item': active,
|
|
})}
|
|
>
|
|
<div
|
|
role="button"
|
|
onClick={() => {
|
|
setSelectedDataSource(dataSource);
|
|
toggleDataSourceManagerModal(true);
|
|
focusModal();
|
|
}}
|
|
className="col d-flex align-items-center"
|
|
>
|
|
{icon}
|
|
<span className="font-400" style={{ paddingLeft: 5 }}>
|
|
{dataSource.name}
|
|
</span>
|
|
</div>
|
|
<div className="col-auto">
|
|
<button className="btn btn-sm ds-delete-btn" onClick={() => onDelete(dataSource)}>
|
|
<div>
|
|
<DeleteIcon width="14" height="14" />
|
|
</div>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|