Skip to content

Commit

Permalink
fix: able to edit app post version released (ToolJet#2915)
Browse files Browse the repository at this point in the history
* fix: able to edit app post version released

* feat: make datasources & queries realtime
  • Loading branch information
gondar00 authored Apr 28, 2022
1 parent 86b763d commit 9dbe636
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions frontend/src/Editor/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ class Editor extends React.Component {
initEventListeners() {
document.addEventListener('mousemove', this.onMouseMove);
document.addEventListener('mouseup', this.onMouseUp);
this.socket?.addEventListener('message', (event) => {
if (event.data === 'versionReleased') this.fetchApp();
else if (event.data === 'dataQueriesChanged') this.fetchDataQueries();
else if (event.data === 'dataSourcesChanged') this.fetchDataSources();
});
}

componentWillUnmount() {
Expand Down Expand Up @@ -388,12 +393,23 @@ class Editor extends React.Component {
};

dataSourcesChanged = () => {
this.fetchDataSources();
this.socket.send(
JSON.stringify({
event: 'events',
data: { message: 'dataSourcesChanged', appId: this.state.appId },
})
);
};

dataQueriesChanged = () => {
this.fetchDataQueries();
this.setState({ addingQuery: false });
this.setState({ addingQuery: false }, () => {
this.socket.send(
JSON.stringify({
event: 'events',
data: { message: 'dataQueriesChanged', appId: this.state.appId },
})
);
});
};

switchSidebarTab = (tabIndex) => {
Expand Down Expand Up @@ -792,12 +808,22 @@ class Editor extends React.Component {
};

onVersionRelease = (versionId) => {
this.setState({
app: {
...this.state.app,
current_version_id: versionId,
this.setState(
{
app: {
...this.state.app,
current_version_id: versionId,
},
},
});
() => {
this.socket.send(
JSON.stringify({
event: 'events',
data: { message: 'versionReleased', appId: this.state.appId },
})
);
}
);
};

onZoomChanged = (zoom) => {
Expand Down

0 comments on commit 9dbe636

Please sign in to comment.