ToolJet/frontend/src/Editor/QueryManager/QueryManager.jsx

615 lines
22 KiB
React
Raw Normal View History

import React from 'react';
import { dataqueryService } from '@/_services';
2021-12-30 11:57:02 +00:00
import { toast } from 'react-hot-toast';
import Select from 'react-select';
import ReactTooltip from 'react-tooltip';
import { allSources } from './QueryEditors';
import { Transformation } from './Transformation';
2021-05-22 11:29:27 +00:00
import ReactJson from 'react-json-view';
import { previewQuery } from '@/_helpers/appUtils';
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
import { allSvgs } from '@tooljet/plugins/client';
import { EventManager } from '../Inspector/EventManager';
import { CodeHinter } from '../CodeBuilder/CodeHinter';
import { DataSourceTypes } from '../DataSourceManager/SourceComponents';
import RunjsIcon from '../Icons/runjs.svg';
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
2021-04-30 06:31:32 +00:00
const queryNameRegex = new RegExp('^[A-Za-z0-9_-]*$');
const staticDataSources = [
{ kind: 'restapi', id: 'null', name: 'REST API' },
{ kind: 'runjs', id: 'runjs', name: 'Run JavaScript code' },
];
2021-04-04 17:07:03 +00:00
let QueryManager = class QueryManager extends React.Component {
2021-04-30 06:31:32 +00:00
constructor(props) {
super(props);
this.state = {
options: {},
selectedQuery: null,
selectedDataSource: null,
dataSourceMeta: {},
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
dataQueries: [],
};
this.previewPanelRef = React.createRef();
2021-04-30 06:31:32 +00:00
}
setStateFromProps = (props) => {
const selectedQuery = props.selectedQuery;
const dataSourceId = selectedQuery?.data_source_id;
const source = props.dataSources.find((datasource) => datasource.id === dataSourceId);
let dataSourceMeta = DataSourceTypes.find((source) => source.kind === selectedQuery?.kind);
const paneHeightChanged = this.state.queryPaneHeight !== props.queryPaneHeight;
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
const dataQueries = props.dataQueries?.length ? props.dataQueries : this.state.dataQueries;
2021-04-30 06:31:32 +00:00
this.setState(
{
appId: props.appId,
dataSources: props.dataSources,
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
dataQueries: dataQueries,
2021-04-30 06:31:32 +00:00
mode: props.mode,
currentTab: 1,
addingQuery: props.addingQuery,
editingQuery: props.editingQuery,
queryPaneHeight: props.queryPaneHeight,
2021-05-22 11:29:27 +00:00
currentState: props.currentState,
selectedSource: source,
dataSourceMeta,
selectedDataSource: paneHeightChanged ? this.state.selectedDataSource : props.selectedDataSource,
2021-04-30 06:31:32 +00:00
},
() => {
if (this.props.mode === 'edit') {
let source = props.dataSources.find((datasource) => datasource.id === selectedQuery.data_source_id);
if (selectedQuery.kind === 'restapi') {
if (!selectedQuery.data_source_id) {
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
source = { kind: 'restapi', id: 'null', name: 'REST API' };
}
}
if (selectedQuery.kind === 'runjs') {
if (!selectedQuery.data_source_id) {
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
source = { kind: 'runjs', id: 'runjs', name: 'Run JavaScript code' };
}
}
2021-04-30 06:31:32 +00:00
this.setState({
options:
paneHeightChanged || this.state.selectedQuery?.id === selectedQuery?.id
? this.state.options
: selectedQuery.options,
2021-04-30 06:31:32 +00:00
selectedDataSource: source,
selectedQuery,
queryName: selectedQuery.name,
2021-04-30 06:31:32 +00:00
});
}
// } else {
// this.setState({
// options: {},
// selectedQuery: null,
// selectedDataSource: paneHeightChanged ? this.state.selectedDataSource : props.selectedDataSource,
// });
// }
2021-04-30 06:31:32 +00:00
}
);
};
componentWillReceiveProps(nextProps) {
this.setStateFromProps(nextProps);
}
componentDidMount() {
this.setStateFromProps(this.props);
}
isJson = (maybeJson) => {
if (typeof maybeJson === 'object') return true;
return false;
};
2021-04-30 06:31:32 +00:00
changeDataSource = (sourceId) => {
const source = [...this.state.dataSources, ...staticDataSources].find((datasource) => datasource.id === sourceId);
const isSchemaUnavailable = ['restapi', 'stripe', 'runjs'].includes(source.kind);
const schemaUnavailableOptions = {
restapi: {
method: 'get',
url: null,
url_params: [],
headers: [],
body: [],
},
stripe: {},
runjs: {},
};
2021-04-30 06:31:32 +00:00
this.setState({
selectedDataSource: source,
selectedSource: source,
queryName: this.computeQueryName(source.kind),
...(isSchemaUnavailable && {
options: schemaUnavailableOptions[source.kind],
}),
2021-04-30 06:31:32 +00:00
});
};
switchCurrentTab = (tab) => {
this.setState({
currentTab: tab,
2021-04-30 06:31:32 +00:00
});
};
validateQueryName = () => {
const { queryName, dataQueries, mode, selectedQuery } = this.state;
2021-04-30 06:31:32 +00:00
if (mode === 'create') {
return dataQueries.find((query) => query.name === queryName) === undefined && queryNameRegex.test(queryName);
}
const existingQuery = dataQueries.find((query) => query.name === queryName);
if (existingQuery) {
return existingQuery.id === selectedQuery.id && queryNameRegex.test(queryName);
}
return queryNameRegex.test(queryName);
2021-04-30 06:31:32 +00:00
};
computeQueryName = (kind) => {
const { dataQueries } = this.state;
const currentQueriesForKind = dataQueries.filter((query) => query.kind === kind);
let found = false;
let newName = '';
2021-04-30 06:31:32 +00:00
let currentNumber = currentQueriesForKind.length + 1;
while (!found) {
newName = `${kind}${currentNumber}`;
if (dataQueries.find((query) => query.name === newName) === undefined) {
2021-04-30 06:31:32 +00:00
found = true;
}
currentNumber += 1;
2021-04-04 06:26:23 +00:00
}
return newName;
2021-04-30 06:31:32 +00:00
};
createOrUpdateDataQuery = () => {
const { appId, options, selectedDataSource, mode, queryName } = this.state;
const appVersionId = this.props.editingVersionId;
2021-04-30 06:31:32 +00:00
const kind = selectedDataSource.kind;
2021-07-24 06:13:21 +00:00
const dataSourceId = selectedDataSource.id === 'null' ? null : selectedDataSource.id;
2021-04-30 06:31:32 +00:00
const isQueryNameValid = this.validateQueryName();
if (!isQueryNameValid) {
toast.error('Invalid query name. Should be unique and only include letters, numbers and underscore.');
2021-04-30 06:31:32 +00:00
return;
}
2021-04-30 06:31:32 +00:00
if (mode === 'edit') {
this.setState({ isUpdating: true });
dataqueryService
.update(this.state.selectedQuery.id, queryName, options)
.then(() => {
toast.success('Query Updated');
this.setState({ isUpdating: false });
this.props.dataQueriesChanged();
})
.catch(({ error }) => {
this.setState({ isUpdating: false });
toast.error(error);
});
2021-04-30 06:31:32 +00:00
} else {
this.setState({ isCreating: true });
dataqueryService
.create(appId, appVersionId, queryName, kind, options, dataSourceId)
.then(() => {
toast.success('Query Added');
this.setState({ isCreating: false });
this.props.dataQueriesChanged();
})
.catch(({ error }) => {
this.setState({ isCreating: false });
toast.error(error);
});
}
2021-04-30 06:31:32 +00:00
};
optionchanged = (option, value) => {
this.setState({ options: { ...this.state.options, [option]: value } });
};
optionsChanged = (newOptions) => {
this.setState({ options: newOptions });
};
toggleOption = (option) => {
const currentValue = this.state.options[option] ? this.state.options[option] : false;
this.optionchanged(option, !currentValue);
};
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
renderDataSourceOption = (props) => {
const Icon = allSvgs[props.kind];
2021-04-30 06:31:32 +00:00
return (
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
<div>
{props.kind === 'runjs' ? (
<RunjsIcon style={{ height: 25, width: 25, marginTop: '-3px' }} />
) : (
Icon && <Icon style={{ height: 25, width: 25 }} />
)}
<span
style={{ height: '25px', display: 'inline-block', marginTop: '3.5px' }}
className={`mx-2 ${this.props.darkMode ? 'text-white' : 'text-muted'}`}
>
{props.label}
</span>
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
</div>
2021-04-30 06:31:32 +00:00
);
};
// Here we have mocked data query in format of a component to be usable by event manager
// TODO: Refactor EventManager to be generic
mockDataQueryAsComponent = () => {
const dataQueryEvents = this.state.options?.events || [];
return {
component: { component: { definition: { events: dataQueryEvents } } },
componentMeta: {
events: {
onDataQuerySuccess: { displayName: 'Query Success' },
onDataQueryFailure: { displayName: 'Query Failure' },
},
},
};
};
eventsChanged = (events) => {
this.optionchanged('events', events);
};
2021-04-30 06:31:32 +00:00
render() {
const {
dataSources,
selectedDataSource,
mode,
2021-05-22 11:50:55 +00:00
options,
2021-04-30 06:31:32 +00:00
currentTab,
isUpdating,
isCreating,
addingQuery,
editingQuery,
selectedQuery,
currentState,
2021-05-22 11:29:27 +00:00
queryName,
previewLoading,
queryPreviewData,
dataSourceMeta,
2021-04-30 06:31:32 +00:00
} = this.state;
let ElementToRender = '';
if (selectedDataSource) {
const sourcecomponentName = selectedDataSource.kind.charAt(0).toUpperCase() + selectedDataSource.kind.slice(1);
ElementToRender = allSources[sourcecomponentName];
2021-04-04 17:07:03 +00:00
}
2021-04-30 06:31:32 +00:00
let buttonText = mode === 'edit' ? 'Save' : 'Create';
const buttonDisabled = isUpdating || isCreating;
const mockDataQueryComponent = this.mockDataQueryAsComponent();
2021-04-07 07:03:03 +00:00
const selectStyles = {
container: (provided) => ({
...provided,
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
width: 224,
height: 32,
}),
control: (provided) => ({
...provided,
borderColor: 'hsl(0, 0%, 80%)',
boxShadow: 'none',
'&:hover': {
borderColor: 'hsl(0, 0%, 80%)',
},
backgroundColor: this.props.darkMode ? '#2b3547' : '#fff',
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
height: '32px!important',
minHeight: '32px!important',
}),
valueContainer: (provided, _state) => ({
...provided,
height: 32,
marginBottom: '4px',
}),
indicatorsContainer: (provided, _state) => ({
...provided,
height: 32,
}),
indicatorSeparator: (_state) => ({
display: 'none',
}),
input: (provided) => ({
...provided,
color: this.props.darkMode ? '#fff' : '#232e3c',
}),
menu: (provided) => ({
...provided,
zIndex: 2,
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
backgroundColor: this.props.darkMode ? 'rgb(31,40,55)' : 'white',
}),
option: (provided) => ({
...provided,
backgroundColor: this.props.darkMode ? '#2b3547' : '#fff',
color: this.props.darkMode ? '#fff' : '#232e3c',
':hover': {
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
backgroundColor: this.props.darkMode ? '#323C4B' : '#d8dce9',
},
}),
placeholder: (provided) => ({
...provided,
color: this.props.darkMode ? '#fff' : '#808080',
}),
singleValue: (provided) => ({
...provided,
color: this.props.darkMode ? '#fff' : '#232e3c',
}),
};
2021-04-30 06:31:32 +00:00
return (
<div className="query-manager" key={selectedQuery ? selectedQuery.id : ''}>
<ReactTooltip type="dark" effect="solid" delayShow={250} />
<div className="row header">
<div className="col">
{(addingQuery || editingQuery) && (
<div className="nav-header">
<ul className="nav nav-tabs query-manager-header" data-bs-toggle="tabs">
2021-04-30 06:31:32 +00:00
<li className="nav-item">
<a
onClick={() => this.switchCurrentTab(1)}
className={currentTab === 1 ? 'nav-link active' : 'nav-link'}
>
&nbsp; General
</a>
</li>
<li className="nav-item">
<a
onClick={() => this.switchCurrentTab(2)}
className={currentTab === 2 ? 'nav-link active' : 'nav-link'}
>
&nbsp; Advanced
</a>
</li>
</ul>
</div>
)}
</div>
{(addingQuery || editingQuery) && selectedDataSource && (
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
<div className="col-2 query-name-field">
<input
type="text"
onChange={(e) => this.setState({ queryName: e.target.value })}
className="form-control-plaintext form-control-plaintext-sm mt-1"
value={queryName}
autoFocus={false}
/>
2021-04-30 06:31:32 +00:00
</div>
)}
<div className="col-auto px-1 m-auto">
2021-05-22 11:50:55 +00:00
{(addingQuery || editingQuery) && (
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
<button
onClick={() => {
const _options = { ...options };
const query = {
data_source_id: selectedDataSource.id === 'null' ? null : selectedDataSource.id,
options: _options,
kind: selectedDataSource.kind,
};
previewQuery(this, query)
.then(() => {
this.previewPanelRef.current.scrollIntoView();
})
.catch(({ error, data }) => {
console.log(error, data);
});
}}
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
className={`btn button-family-secondary m-1 float-right1 ${previewLoading ? 'button-loading' : ''} ${
this.props.darkMode ? 'dark' : ''
} ${this.state.selectedDataSource ? '' : 'disabled'}`}
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
style={{ width: '72px', height: '28px' }}
2021-05-22 11:29:27 +00:00
>
Preview
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
</button>
2021-05-22 11:29:27 +00:00
)}
2021-04-30 06:31:32 +00:00
{(addingQuery || editingQuery) && (
<button
onClick={this.createOrUpdateDataQuery}
disabled={buttonDisabled}
className={`btn btn-primary m-1 float-right ${isUpdating || isCreating ? 'btn-loading' : ''} ${
this.state.selectedDataSource ? '' : 'disabled'
}`}
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
style={{ width: '72px', height: '28px' }}
2021-04-30 06:31:32 +00:00
>
{buttonText}
</button>
)}
<span onClick={this.props.toggleQueryEditor} className="cursor-pointer m-3" data-tip="Hide query editor">
<svg width="18" height="10" viewBox="0 0 18 10" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1 1L9 9L17 1" stroke="#61656F" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</span>
2021-04-30 06:31:32 +00:00
</div>
</div>
{(addingQuery || editingQuery) && (
<div className="py-2">
2021-04-30 06:31:32 +00:00
{currentTab === 1 && (
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
<div className="row row-deck px-2 mt-0 query-details">
2021-04-30 06:31:32 +00:00
{dataSources && mode === 'create' && (
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
<div className="datasource-picker mt-1 mb-2">
2021-04-30 06:31:32 +00:00
<label className="form-label col-md-2">Datasource</label>
<Select
2021-04-30 06:31:32 +00:00
options={[
...dataSources.map((source) => {
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
return { label: source.name, value: source.id, kind: source.kind };
2021-04-30 06:31:32 +00:00
}),
...staticDataSources.map((source) => {
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
return { label: source.name, value: source.id, kind: source.kind };
}),
2021-04-30 06:31:32 +00:00
]}
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
formatOptionLabel={this.renderDataSourceOption}
onChange={(newValue) => this.changeDataSource(newValue.value)}
2021-04-30 06:31:32 +00:00
placeholder="Select a data source"
styles={selectStyles}
2021-04-30 06:31:32 +00:00
/>
</div>
)}
{selectedDataSource && (
<div>
<ElementToRender
selectedDataSource={this.state.selectedSource}
options={this.state.options}
optionsChanged={this.optionsChanged}
optionchanged={this.optionchanged}
currentState={currentState}
darkMode={this.props.darkMode}
isEditMode={this.props.mode === 'edit'}
queryName={this.state.queryName}
/>
{!dataSourceMeta?.disableTransformations && (
<div>
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
<div className="mb-3 mt-4">
<Transformation
changeOption={this.optionchanged}
options={this.props.selectedQuery.options ?? {}}
currentState={currentState}
darkMode={this.props.darkMode}
/>
</div>
</div>
)}
2021-05-24 16:13:02 +00:00
<div className="row preview-header border-top" ref={this.previewPanelRef}>
[improvement] Query panel redesign (#1947) * query panel headers styles * create query button style update * create query button style update * create query button style update: mixins * querypanel header nav-links updated * querypanel header buttons * restapi: url hinter styles * fixes querypane header width, undo prev styles applied * querypanel header icons margin fix * restapi: header tab * restapi: params tab * restapi: body tab * base url style fixed * added alert component to @/_ui * adds margin top to query-panel tabs * bumped font weight of preview * on hover query style updated * selected query style update and along with dark themed * adds new searchbox component, added search queries * fixes query panel query lists icons margin * query selected hover bg * back icon should not be render if callback is a function * airtable: queries redesigned * stripe: queries redesigned * fixed query-pane header responsiveness * fixes tab title typo * undp/redo select datasource only when mode='create' * removes comments * refactor restapi url codehinter styles * fixes white spaces in query pane and query pane header * minor updates for restapi query options styles * removes tool-tip for lens svg icon for search: query-pane header * adds button loading spinner with primary color * fixes hover bg color for queries * update: query hover bg color to lighter tint * update query list icons: trash and play svgs * adds icons to the selection component * fixes tabs alignments restapi * fixes codehonter text margin: restapi url * fixes advanced-options-container margintop * new UI query: dynamodb * new UI query: elasticsearch * new UI query: firestore * new UI query: mongodb * new UI query: mysql * new UI query: psql * new UI query: typesenseapi * new UI query: gsheet * new UI query: sendgrid * new UI query: twillio * new UI query: gcs * new UI query: minio * new UI query: aws * update query bg color and hover bg color * fixes run query icon for dark theme * fixes input query title text alignment * update query header title * adds search queries placeholder and add icon when search box is displayed * updated No results query text * undo/redo rest-api tabs: fixes whote spaces * undo/redo: rest-api tabs conde hinter placeholder paddinleft * adding new queries when search box component is mounted:fix * fixes creating a new query after filtering queries * fixes dark theme for select search components * reverts query pane header search box with add icon * fixes input left margin * fixes bottom padding rest api tabs * fixes toggle button:not selected in dark theme * fixes typos * fixes preview button spinner size * undo/redo: query-trash-icon.svg for queries and trash.svg for components * query icons badge bg update[options] * icon badge fix * move static styles to theme.scss * restapi: url field height increment * fixes query name when adding a new query with filtered querylist * fixes alignment issues of the query header icon * revert back to 32px code hinter height * adds apdding to code mirror line * updates to react-select * remove component unmounts and mounts side effect
2022-02-02 16:59:57 +00:00
<div className="py-2" style={{ fontWeight: 600 }}>
Preview
</div>
2021-05-22 11:29:27 +00:00
</div>
<div className="mb-3 mt-2">
{previewLoading && (
<center>
<div className="spinner-border text-azure mt-5" role="status"></div>
</center>
)}
{previewLoading === false &&
(this.isJson(queryPreviewData) ? (
<div>
<ReactJson
name={false}
style={{ fontSize: '0.7rem' }}
enableClipboard={false}
src={queryPreviewData}
theme={this.props.darkMode ? 'shapeshifter' : 'rjv-default'}
displayDataTypes={true}
collapsed={false}
displayObjectSize={true}
quotesOnKeys={false}
sortKeys={true}
indentWidth={1}
/>
</div>
) : (
<div>{queryPreviewData}</div>
))}
2021-05-22 11:29:27 +00:00
</div>
2021-04-30 06:31:32 +00:00
</div>
)}
</div>
)}
{currentTab === 2 && (
<div className="advanced-options-container m-2">
<div className="form-check form-switch">
2021-04-30 06:31:32 +00:00
<input
className="form-check-input"
type="checkbox"
onClick={() => this.toggleOption('runOnPageLoad')}
checked={this.state.options.runOnPageLoad}
/>
<span className="form-check-label">Run this query on page load?</span>
</div>
<div className="form-check form-switch">
2021-04-30 06:31:32 +00:00
<input
className="form-check-input"
type="checkbox"
onClick={() => this.toggleOption('requestConfirmation')}
checked={this.state.options.requestConfirmation}
/>
<span className="form-check-label">Request confirmation before running query?</span>
</div>
2021-04-30 06:31:32 +00:00
<div className="form-check form-switch">
2021-04-30 06:31:32 +00:00
<input
className="form-check-input"
type="checkbox"
onClick={() => this.toggleOption('showSuccessNotification')}
checked={this.state.options.showSuccessNotification}
/>
<span className="form-check-label">Show notification on success?</span>
</div>
{this.state.options.showSuccessNotification && (
<div>
<div className="row mt-3">
<div className="col-auto">
<label className="form-label p-2">Success Message</label>
</div>
<div className="col">
<CodeHinter
currentState={this.props.currentState}
initialValue={this.state.options.successMessage}
height="36px"
className="form-control"
theme={'default'}
onChange={(value) => this.optionchanged('successMessage', value)}
placeholder="Query ran successfully"
/>
</div>
</div>
2021-04-30 06:31:32 +00:00
<div className="row mt-3">
<div className="col-auto">
<label className="form-label p-2">Notification duration (s)</label>
</div>
<div className="col">
<input
type="number"
disabled={!this.state.options.showSuccessNotification}
onChange={(e) => this.optionchanged('notificationDuration', e.target.value)}
placeholder={5}
className="form-control"
value={this.state.options.notificationDuration}
/>
</div>
</div>
2021-04-30 06:31:32 +00:00
</div>
)}
<div className="hr-text hr-text-left">Events</div>
<div className="query-manager-events">
<EventManager
eventsChanged={this.eventsChanged}
component={mockDataQueryComponent.component}
componentMeta={mockDataQueryComponent.componentMeta}
currentState={this.props.currentState}
dataQueries={this.props.dataQueries}
components={this.props.allComponents}
apps={this.props.apps}
popoverPlacement="top"
/>
</div>
2021-04-30 06:31:32 +00:00
</div>
)}
</div>
)}
</div>
);
}
};
QueryManager = React.memo(QueryManager);
2021-04-04 06:46:53 +00:00
export { QueryManager };