@@ -35,6 +35,27 @@ const ModalContentWrapper = styled("div")`
3535 min-height: 15vh;
3636` ;
3737
38+ export const queryListChanges = gql `
39+ query listChanges(
40+ $proxy: String,
41+ $stamps: ObjectVal!
42+ ) {
43+ list_changes(
44+ proxy: $proxy,
45+ stamps: $stamps
46+ ) {
47+ language
48+ dictionary
49+ perspective {
50+ lexical_entries {
51+ entities
52+ }
53+ }
54+ }
55+
56+ }
57+ ` ;
58+
3859export const queryPerspective = gql `
3960 query queryPerspective1($id: LingvodocID!) {
4061 perspective(id: $id) {
@@ -558,6 +579,30 @@ class P extends React.Component {
558579 } ) ;
559580 } ;
560581
582+ const doSync = ( ) => {
583+ // 1. Get changes from Core,
584+ // 2. Get changes from Satellite,
585+ // 3. Display changes,
586+ // 4. Apply/Deny changes
587+
588+ const groupList = [ selectedEntries ] ;
589+
590+ mergeLexicalEntries ( {
591+ variables : { groupList } ,
592+
593+ refetchQueries : [
594+ {
595+ query : queryLexicalEntries ,
596+ variables : query_args
597+ }
598+ ]
599+
600+ } ) . then ( ( ) => {
601+ resetSelection ( ) ;
602+ this . setState ( { entriesTotal : entriesTotal - selectedEntries . length + 1 } ) ;
603+ } ) ;
604+ } ;
605+
561606 const mergeEntries = ( ) => {
562607 const groupList = [ selectedEntries ] ;
563608
@@ -607,7 +652,8 @@ class P extends React.Component {
607652 ) ;
608653 }
609654 /* eslint-enable no-shadow */
610- const isAuthenticated = user && user . user . id ;
655+ const isAuthenticated = user ?. user ?. id ;
656+ const allowedSync = user ?. user ?. allowed_sync ;
611657
612658 const isTableLanguages = JSON . stringify ( id ) === JSON . stringify ( [ 4839 , 2 ] ) ;
613659
@@ -713,6 +759,14 @@ class P extends React.Component {
713759 ( mode === "publish" && isAuthenticated ) ||
714760 ( mode === "contributions" && isAuthenticated ) ) && (
715761 < div className = "lingvo-perspective-buttons" >
762+ { mode === "edit" && allowedSync && (
763+ < Button
764+ icon = { < i className = "lingvo-icon lingvo-icon_refresh" /> }
765+ content = { this . context ( "Synchronize" ) }
766+ onClick = { doSync }
767+ className = "lingvo-button-green lingvo-perspective-button"
768+ />
769+ ) }
716770 { mode === "edit" && (
717771 < Button
718772 icon = { < i className = "lingvo-icon lingvo-icon_add" /> }
@@ -1219,5 +1273,6 @@ export default compose(
12191273 graphql ( queryPerspective , {
12201274 options : { notifyOnNetworkStatusChange : true }
12211275 } ) ,
1276+ graphql ( queryListChanges , { name : "listChanges" } ) ,
12221277 branch ( ( { data : { loading } } ) => loading , renderComponent ( Placeholder ) )
12231278) ( PerspectiveViewWrapper ) ;
0 commit comments