ToolJet/frontend/src/_stores/dataSourcesStore.js

60 lines
2.1 KiB
JavaScript
Raw Normal View History

import { create, zustandDevTools } from './utils';
import { datasourceService, globalDatasourceService } from '@/_services';
Release Platform v17 (v2.39.0) (#9502) * bump version * Sample data source (#9501) * Added sample data populating script * added expand-collapse in add data soure menu * Sample database * Design changes * Added CTA to buttons and added design changes * Added code sanity fix for some services * changed configration for create sampke db and code sanity fix * Removed logs * Added xlsx in dependency * added migration for sample db * Added loggin for testing * Added await in migration * Replace excel sheet with JSON files * reverted package-lock file * Fixed issues * dependecy deletion * Added schedular * Added changes for bug fixes and typeorm query for creating sample db * Removed color.scss file import * Add logo in sample application * add documentation link for sample db * fixed migration issue for data queries creation * removed sample db intergration * bump version * Remove .env file and code sanity * deleted migration file --------- Co-authored-by: Kritagya <[email protected]> Co-authored-by: Kritagya Kumar <[email protected]> Co-authored-by: kriks7raptor <[email protected]> Co-authored-by: gsmithun4 <[email protected]> * Add data-cy for drag drop empty canvas card (#9513) * Add sample db condition on all components (#9516) * Add sample db condition on all components * Changed empty state for container * Condiiton on sample data source --------- Co-authored-by: kriks7raptor <[email protected]> * Release fix: subpath (#9535) * Add sample db condition on all components * Changed empty state for container * Condiiton on sample data source * fixed subpath issue for workspace setting and folders * Folder change handler in subpath --------- Co-authored-by: kriks7raptor <[email protected]> * fixed version * fixed version * fixed version * update server version * Bump version to v2.39.0 --------- Co-authored-by: kriks7iitk <34170719+[email protected]> Co-authored-by: Kritagya <[email protected]> Co-authored-by: Kritagya Kumar <[email protected]> Co-authored-by: kriks7raptor <[email protected]> Co-authored-by: Ajith KV <[email protected]> Co-authored-by: kriks7iitk <[email protected]> Co-authored-by: Adish M <44204658+[email protected]> Co-authored-by: Muhsin Shah <[email protected]>
2024-04-30 16:19:37 +00:00
import { DATA_SOURCE_TYPE } from '@/_helpers/constants';
const initialState = {
dataSources: [],
loadingDataSources: true,
globalDataSources: [],
Release Platform v17 (v2.39.0) (#9502) * bump version * Sample data source (#9501) * Added sample data populating script * added expand-collapse in add data soure menu * Sample database * Design changes * Added CTA to buttons and added design changes * Added code sanity fix for some services * changed configration for create sampke db and code sanity fix * Removed logs * Added xlsx in dependency * added migration for sample db * Added loggin for testing * Added await in migration * Replace excel sheet with JSON files * reverted package-lock file * Fixed issues * dependecy deletion * Added schedular * Added changes for bug fixes and typeorm query for creating sample db * Removed color.scss file import * Add logo in sample application * add documentation link for sample db * fixed migration issue for data queries creation * removed sample db intergration * bump version * Remove .env file and code sanity * deleted migration file --------- Co-authored-by: Kritagya <[email protected]> Co-authored-by: Kritagya Kumar <[email protected]> Co-authored-by: kriks7raptor <[email protected]> Co-authored-by: gsmithun4 <[email protected]> * Add data-cy for drag drop empty canvas card (#9513) * Add sample db condition on all components (#9516) * Add sample db condition on all components * Changed empty state for container * Condiiton on sample data source --------- Co-authored-by: kriks7raptor <[email protected]> * Release fix: subpath (#9535) * Add sample db condition on all components * Changed empty state for container * Condiiton on sample data source * fixed subpath issue for workspace setting and folders * Folder change handler in subpath --------- Co-authored-by: kriks7raptor <[email protected]> * fixed version * fixed version * fixed version * update server version * Bump version to v2.39.0 --------- Co-authored-by: kriks7iitk <34170719+[email protected]> Co-authored-by: Kritagya <[email protected]> Co-authored-by: Kritagya Kumar <[email protected]> Co-authored-by: kriks7raptor <[email protected]> Co-authored-by: Ajith KV <[email protected]> Co-authored-by: kriks7iitk <[email protected]> Co-authored-by: Adish M <44204658+[email protected]> Co-authored-by: Muhsin Shah <[email protected]>
2024-04-30 16:19:37 +00:00
sampleDataSource: null,
globalDataSourceStatus: {
isSaving: false,
isEditing: false,
unSavedModalVisible: false,
action: null,
saveAction: null,
},
};
export const useDataSourcesStore = create(
zustandDevTools(
(set, get) => ({
...initialState,
actions: {
fetchDataSources: (appId) => {
set({ loadingDataSources: true });
datasourceService.getAll(appId).then((data) => {
set({
dataSources: data.data_sources,
loadingDataSources: false,
});
});
},
fetchGlobalDataSources: (organizationId) => {
globalDatasourceService.getAll(organizationId).then((data) => {
set({
Release Platform v17 (v2.39.0) (#9502) * bump version * Sample data source (#9501) * Added sample data populating script * added expand-collapse in add data soure menu * Sample database * Design changes * Added CTA to buttons and added design changes * Added code sanity fix for some services * changed configration for create sampke db and code sanity fix * Removed logs * Added xlsx in dependency * added migration for sample db * Added loggin for testing * Added await in migration * Replace excel sheet with JSON files * reverted package-lock file * Fixed issues * dependecy deletion * Added schedular * Added changes for bug fixes and typeorm query for creating sample db * Removed color.scss file import * Add logo in sample application * add documentation link for sample db * fixed migration issue for data queries creation * removed sample db intergration * bump version * Remove .env file and code sanity * deleted migration file --------- Co-authored-by: Kritagya <[email protected]> Co-authored-by: Kritagya Kumar <[email protected]> Co-authored-by: kriks7raptor <[email protected]> Co-authored-by: gsmithun4 <[email protected]> * Add data-cy for drag drop empty canvas card (#9513) * Add sample db condition on all components (#9516) * Add sample db condition on all components * Changed empty state for container * Condiiton on sample data source --------- Co-authored-by: kriks7raptor <[email protected]> * Release fix: subpath (#9535) * Add sample db condition on all components * Changed empty state for container * Condiiton on sample data source * fixed subpath issue for workspace setting and folders * Folder change handler in subpath --------- Co-authored-by: kriks7raptor <[email protected]> * fixed version * fixed version * fixed version * update server version * Bump version to v2.39.0 --------- Co-authored-by: kriks7iitk <34170719+[email protected]> Co-authored-by: Kritagya <[email protected]> Co-authored-by: Kritagya Kumar <[email protected]> Co-authored-by: kriks7raptor <[email protected]> Co-authored-by: Ajith KV <[email protected]> Co-authored-by: kriks7iitk <[email protected]> Co-authored-by: Adish M <44204658+[email protected]> Co-authored-by: Muhsin Shah <[email protected]>
2024-04-30 16:19:37 +00:00
globalDataSources: data.data_sources?.filter((source) => source?.type != DATA_SOURCE_TYPE.SAMPLE),
sampleDataSource: data.data_sources?.filter((source) => source?.type == DATA_SOURCE_TYPE.SAMPLE)[0],
});
});
},
setGlobalDataSourceStatus: (status) =>
set({
globalDataSourceStatus: {
...get().globalDataSourceStatus,
...status,
},
}),
},
}),
{ name: 'Data Source Store' }
)
);
export const useDataSources = () => useDataSourcesStore((state) => state.dataSources);
export const useGlobalDataSources = () => useDataSourcesStore((state) => state.globalDataSources);
Release Platform v17 (v2.39.0) (#9502) * bump version * Sample data source (#9501) * Added sample data populating script * added expand-collapse in add data soure menu * Sample database * Design changes * Added CTA to buttons and added design changes * Added code sanity fix for some services * changed configration for create sampke db and code sanity fix * Removed logs * Added xlsx in dependency * added migration for sample db * Added loggin for testing * Added await in migration * Replace excel sheet with JSON files * reverted package-lock file * Fixed issues * dependecy deletion * Added schedular * Added changes for bug fixes and typeorm query for creating sample db * Removed color.scss file import * Add logo in sample application * add documentation link for sample db * fixed migration issue for data queries creation * removed sample db intergration * bump version * Remove .env file and code sanity * deleted migration file --------- Co-authored-by: Kritagya <[email protected]> Co-authored-by: Kritagya Kumar <[email protected]> Co-authored-by: kriks7raptor <[email protected]> Co-authored-by: gsmithun4 <[email protected]> * Add data-cy for drag drop empty canvas card (#9513) * Add sample db condition on all components (#9516) * Add sample db condition on all components * Changed empty state for container * Condiiton on sample data source --------- Co-authored-by: kriks7raptor <[email protected]> * Release fix: subpath (#9535) * Add sample db condition on all components * Changed empty state for container * Condiiton on sample data source * fixed subpath issue for workspace setting and folders * Folder change handler in subpath --------- Co-authored-by: kriks7raptor <[email protected]> * fixed version * fixed version * fixed version * update server version * Bump version to v2.39.0 --------- Co-authored-by: kriks7iitk <34170719+[email protected]> Co-authored-by: Kritagya <[email protected]> Co-authored-by: Kritagya Kumar <[email protected]> Co-authored-by: kriks7raptor <[email protected]> Co-authored-by: Ajith KV <[email protected]> Co-authored-by: kriks7iitk <[email protected]> Co-authored-by: Adish M <44204658+[email protected]> Co-authored-by: Muhsin Shah <[email protected]>
2024-04-30 16:19:37 +00:00
export const useSampleDataSource = () => useDataSourcesStore((state) => state.sampleDataSource);
export const useLoadingDataSources = () => useDataSourcesStore((state) => state.loadingDataSources);
export const useDataSourcesActions = () => useDataSourcesStore((state) => state.actions);
export const useGlobalDataSourcesStatus = () => useDataSourcesStore((state) => state.globalDataSourceStatus);