ToolJet/frontend/src/Editor/LeftSidebar/SidebarDatasources.jsx
Gandharv 2f3b441c0a
Move plugins to root (#1728)
* feat: move plugins to root

* modify tsconfig

* add .gitignore

* delete old plugins file

* add parcel

* docker compose volume mount

* add gcs

* add typescript to plugins folder

* gcs to ts

* add dynamodb

* add elastic search

* add firestore

* add gsheets

* add graphql

* add mongodb

* mssql

* add mysql

* add postgresql

* add redis

* add s3

* add slack

* add stripe

* remove plugin related packages from pkgjson

* add lib folder

* add gitignore

* remove typescript generated files

* remove generated file

* remove generated files

* add twilio

* add dist to docker compose cache binding

* add dist prefix

* cleanup - 1

* delete dist

* rename to index.ts + add jest config

* add it.todo in tests

* test fixes

* test file changes

* fix type checks

* add @tooljet/plugins to server package json

* esm vs commonjs bug, reduce got to 11.8.2 from 12.0.0

* docker file npm package version fix

* add typesense

* cleaup - 2

* add sendgrid

* add lerna build and clean script for all packages + tsconfig

* cleanup -3

* add plugins build step

* add missing plugins build step in npm run build

* add mssql, mysql & postgres as singleton classes

* add db connection to cache only if datasourceId is available

* client: add data source schema/manifest files

* add query operations files

* logic for wrapping form with schema

* add script to create index file

* add @tooljet/plugins to frontend folder

* cleanup 1 -frontend

* cleanup - 2 // frontend // data queries

* add client and index to gitignore

* update gitignore

* fix lint & test

* update ci

* fix unit, e2e

* cleanup -3

* fix test

* fix tests

* fix indent

* try npm ci

* fix tests

* fix typo

* fix

* rename file for server entry

* heroku fix

* add main and types entry points in pkg json

* move common to root

* cleanup - 4: remove redundant $ sign prefix

* cleanup - 4: remove redundant $ sign prefix

* update options in-sync before DOM is painted

* change type cloud to cloud storage

* update readme

* update ci.yml

* update ci yml

* add pkg-lock.json

* rename index.ts to server.ts

* update lock files

* add server package.lock

* remove unused import

* revert commit: add minio

* add root dep

* import server.ts

* remove plugins build step

* add npm shrinkwrap

* update version - plugins

* add new version - 0.0.8

* upgrade version

* move to symlinked package

* add lock file

* feat: add icon inside package

* add plugin creation docs

* Remove seed

* move icons to plugins folder

* install pg dep

* add react to packages

* add seed cmd

* revert change

* add plugins build in lint, e2e, unit

* e2e, lint use npm ci

* update dockerfile for plugins

* try combining release with web

* limit memory on release

* try executing seed script post transpile

* try executing seed from server directory

* update seed execution

* add minio

* add correct type

* add minio to pkg json

* remove old file

* fix provider key

* add python installable + npm ^7.2.0 (#1752)

* add python installable + npm ^7.2.0

* add py to prod file

* pin npm version to 7.20.0

* pin npm version to 7.20.0

* split into multi stage build and remove python for buildx

* copy plugins from buider stage

* update dependencies

* add freetds dependency

* update server dockerfile

* update client dockerfile

* update dev dockerfile and compose file

* fix entrypoint

* fix server dev dockerfile

* update docker-compose

* remove npm install on root dir on docker build

* fix heroku script

* make lerna prod dependency to enable prod builds

* remove redundant env setup

Co-authored-by: Akshay Sasidharan <akshaysasidharan93@gmail.com>
Co-authored-by: navaneeth <navaneethpk@outlook.com>
2022-01-17 12:38:17 +05:30

108 lines
3.8 KiB
JavaScript

import React from 'react';
import usePopover from '../../_hooks/use-popover';
import { LeftSidebarItem } from './SidebarItem';
import { DataSourceManager } from '../DataSourceManager';
import { DataSourceTypes } from '../DataSourceManager/SourceComponents';
import OverlayTrigger from 'react-bootstrap/esm/OverlayTrigger';
import Tooltip from 'react-bootstrap/esm/Tooltip';
import { allSvgs } from '@tooljet/plugins/client';
export const LeftSidebarDataSources = ({ appId, editingVersionId, darkMode, dataSources = [], dataSourcesChanged }) => {
const [open, trigger, content] = usePopover(false);
const [showDataSourceManagerModal, toggleDataSourceManagerModal] = React.useState(false);
const [selectedDataSource, setSelectedDataSource] = React.useState(null);
// TODO: move this to a react component
// TODO: add falback svg icon if icon not found
const getSvgIcon = (key, height = 50, width = 50) => {
const Icon = allSvgs[key];
return <Icon style={{ height, width }} />;
};
const renderDataSource = (dataSource, idx) => {
const sourceMeta = DataSourceTypes.find((source) => source.kind === dataSource.kind);
return (
<div className="row py-1" key={idx}>
<div
role="button"
onClick={() => {
setSelectedDataSource(dataSource);
toggleDataSourceManagerModal(true);
}}
className="col"
>
{getSvgIcon(sourceMeta.kind.toLowerCase(), 25, 25)}
<span className="p-2 font-500">{dataSource.name}</span>
</div>
</div>
);
};
return (
<>
<LeftSidebarItem
tip="Add or edit datasources"
{...trigger}
icon="database"
className={`left-sidebar-item ${open && 'active'}`}
/>
<div {...content} className={`card popover datasources-popover ${open ? 'show' : 'hide'}`}>
<LeftSidebarDataSources.Container
renderDataSource={renderDataSource}
dataSources={dataSources}
toggleDataSourceManagerModal={toggleDataSourceManagerModal}
/>
</div>
<DataSourceManager
appId={appId}
showDataSourceManagerModal={showDataSourceManagerModal}
darkMode={darkMode}
hideModal={() => {
setSelectedDataSource(null);
toggleDataSourceManagerModal(false);
}}
editingVersionId={editingVersionId}
dataSourcesChanged={dataSourcesChanged}
selectedDataSource={selectedDataSource}
/>
</>
);
};
const LeftSidebarDataSourcesContainer = ({ renderDataSource, dataSources = [], toggleDataSourceManagerModal }) => {
return (
<div className="card-body">
<div>
<div className="row">
<div className="col">
<h5 className="text-muted">Data sources</h5>
</div>
<div className="col-auto">
<OverlayTrigger
trigger={['hover', 'focus']}
placement="top"
delay={{ show: 800, hide: 100 }}
overlay={<Tooltip id="button-tooltip">{'Add datasource'}</Tooltip>}
>
<button onClick={() => toggleDataSourceManagerModal(true)} className="btn btn-sm add-btn">
<img className="" src="/assets/images/icons/plus.svg" width="12" height="12" />
</button>
</OverlayTrigger>
</div>
</div>
<div className="d-flex">
{dataSources.length === 0 ? (
<center onClick={() => toggleDataSourceManagerModal(true)} className="p-2 color-primary cursor-pointer">
+ add data source
</center>
) : (
<div className="mt-2">{dataSources?.map((source, idx) => renderDataSource(source, idx))}</div>
)}
</div>
</div>
</div>
);
};
LeftSidebarDataSources.Container = LeftSidebarDataSourcesContainer;