mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
map older query ids to new for event action: run query
This commit is contained in:
parent
5040a7bc30
commit
dcb1926db5
2 changed files with 27 additions and 3 deletions
|
|
@ -467,6 +467,7 @@ export const EventManager = ({
|
|||
search={true}
|
||||
onChange={(value) => {
|
||||
const query = dataQueries.find((dataquery) => dataquery.id === value);
|
||||
|
||||
const parameters = (query?.options?.parameters ?? []).reduce(
|
||||
(paramObj, param) => ({
|
||||
...paramObj,
|
||||
|
|
|
|||
|
|
@ -541,7 +541,7 @@ export class AppsService {
|
|||
const dataSourceMapping = {};
|
||||
const newDataQueries = [];
|
||||
const allEvents = await manager.find(EventHandler, {
|
||||
where: { appVersionId: versionFrom?.id },
|
||||
where: { appVersionId: versionFrom?.id, target: 'data_query' },
|
||||
});
|
||||
|
||||
if (dataSources?.length) {
|
||||
|
|
@ -569,14 +569,12 @@ export class AppsService {
|
|||
const dataQueryEvents = allEvents.filter((event) => event.sourceId === dataQuery.id);
|
||||
for (const event of dataQueryEvents) {
|
||||
const newEvent = new EventHandler();
|
||||
|
||||
newEvent.id = uuid.v4();
|
||||
newEvent.name = event.name;
|
||||
newEvent.sourceId = newQuery.id;
|
||||
newEvent.target = event.target;
|
||||
newEvent.event = event.event;
|
||||
newEvent.appVersionId = appVersion.id;
|
||||
|
||||
await manager.save(newEvent);
|
||||
}
|
||||
|
||||
|
|
@ -619,6 +617,18 @@ export class AppsService {
|
|||
oldDataQueryToNewMapping
|
||||
);
|
||||
newQuery.options = newOptions;
|
||||
|
||||
const newQueryEvents = await manager.find(EventHandler, {
|
||||
where: { appVersionId: appVersion.id, sourceId: newQuery.id },
|
||||
});
|
||||
|
||||
const updatedEvents = this.replaceDataQueryEventActionWithNewDataQueryIds(
|
||||
newQueryEvents,
|
||||
oldDataQueryToNewMapping
|
||||
);
|
||||
|
||||
await manager.save(updatedEvents);
|
||||
|
||||
await manager.save(newQuery);
|
||||
}
|
||||
|
||||
|
|
@ -676,6 +686,19 @@ export class AppsService {
|
|||
return options;
|
||||
}
|
||||
|
||||
replaceDataQueryEventActionWithNewDataQueryIds(events: EventHandler[], dataQueryMapping) {
|
||||
if (events) {
|
||||
const replacedEvents = events.map((event) => {
|
||||
if (event.event.queryId) {
|
||||
event.event.queryId = dataQueryMapping[event.event.queryId];
|
||||
}
|
||||
|
||||
return event;
|
||||
});
|
||||
return replacedEvents;
|
||||
}
|
||||
}
|
||||
|
||||
replaceDataQueryIdWithinDefinitions(definition, dataQueryMapping) {
|
||||
if (definition?.pages) {
|
||||
for (const pageId of Object.keys(definition?.pages)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue