graceguo-supercat edited a comment on pull request #10834:
URL: 
https://github.com/apache/incubator-superset/pull/10834#issuecomment-712514309


   Hi @eschutho Thanks for the work! 
   
   Yes #11220 and #11305 caused conflicts for this PR, and we can make this PR 
work with it. The idea of preventing co-edit is, when dashboard is loaded, it 
carries the last_modified_time which was dashboard's changedon property stored 
in the database. When user edit dashboard and submit new updates to save, we 
send this last_modified_time with all the updates. `/save_dash/` endpoint 
compares the last_modified_time from incoming request with current database: if 
incoming last_modified_time < current data, this means the dashboard was 
changed **_since_** user open dashboard, so the save request will be rejected.
   
   So for the Dashboard Properties modal, right now the problem is it didn't 
send last_modified_time information when it calling `/save_dash/` request, 
which happens after the first save is done. For other dashboard metadata change 
flow, we manage last_modified_time in redux store. 
   
   I just found dashboardInfo is already in redux store. so you can add a 
`lastModifiedTime` in dashboardInfo state, and update `lastModifiedTime` when 
data is updated from server-side. Similar like this:
   
https://github.com/apache/incubator-superset/blob/8863c939ad01fe1e065ce60edc93a683e6828d80/superset-frontend/src/dashboard/reducers/dashboardState.js#L110
   
   At the same time, please update DashboardHeader container component. Instead 
of only getting lastModifiedTime from dashboardState:
   
https://github.com/apache/incubator-superset/blob/8863c939ad01fe1e065ce60edc93a683e6828d80/superset-frontend/src/dashboard/containers/DashboardHeader.jsx#L86
   
   it should be:
   `lastModifiedTime: Max(dashboardState.lastModifiedTime, 
dashboardInfo.lastModifiedTime)` 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to