Skip to content

Commit d7b2c3a

Browse files
Merge pull request #1205 from nataliauvarova/xal_proxy
list sync buttons
2 parents d79b72c + ad35519 commit d7b2c3a

File tree

1 file changed

+48
-11
lines changed

1 file changed

+48
-11
lines changed

src/components/LanguageTree/node.js

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
1-
import React from "react";
2-
import { useSelector } from "react-redux";
1+
import React, { useState } from "react";
2+
import { connect, useSelector } from "react-redux";
33
import { Link } from "react-router-dom";
4-
import { Checkbox, Dropdown, Header, Icon, Popup } from "semantic-ui-react";
4+
import { Button, Checkbox, Confirm, Dropdown, Header, Icon, Popup } from "semantic-ui-react";
55
import PropTypes from "prop-types";
6+
import { compose } from "recompose";
7+
import { bindActionCreators } from "redux";
68

79
import { chooseTranslation } from "api/i18n";
810
// eslint-disable-next-line import/no-unresolved
911
import config from "config";
1012
import { useTranslations } from "hooks";
1113
import { compositeIdToString } from "utils/compositeId";
14+
import SyncModal from "components/SyncModal"; // new!!!!!!
15+
16+
import { openModal } from "ducks/modals"; // new!!!!!
1217

1318
/** Language tree node of a language. */
14-
export const LanguageNode = ({
19+
/*export const LanguageNode = ({*/
20+
/* new!!!!! */
21+
const LangNode = ({
1522
node,
1623
languageMap,
1724
dictionaryIdSet,
1825
dictionaryIdSetReverse,
1926
selected,
2027
setSelected,
21-
proxyData
28+
proxyData,
29+
openModal: openNewModal /* new!!!!! */
2230
}) => {
2331
const { getTranslation, chooseTranslation } = useTranslations();
2432
const user = useSelector(state => state.user.user);
@@ -43,6 +51,14 @@ export const LanguageNode = ({
4351
})
4452
: language.dictionaries;
4553

54+
/* new!!!!! */
55+
const onSynchronize = (id, fields) => {
56+
//console.log("!!!!!!!");
57+
//console.log(openModal);
58+
openNewModal(SyncModal, { perspectiveId: id, columns: fields });
59+
};
60+
/* /new!!!!! */
61+
4662
return (
4763
<li className="node_lang" id={`language_${languageId}`}>
4864
<span className={langClass}>{language.translations && chooseTranslation(language.translations)}</span>
@@ -91,7 +107,7 @@ export const LanguageNode = ({
91107
<Dropdown
92108
icon={null}
93109
trigger={
94-
<span className={perspectives.length && "dict-name dict-name_link" || "dict-name"}>
110+
<span className={(perspectives.length && "dict-name dict-name_link") || "dict-name"}>
95111
{dictionary.translations && chooseTranslation(dictionary.translations)} ({perspectives.length})
96112
</span>
97113
}
@@ -101,7 +117,10 @@ export const LanguageNode = ({
101117
{perspectives.map(perspective => {
102118
const permissions = proxyData ? proxyData.permission_lists : undefined;
103119

104-
if (!perspective.translations || (perspective.translations && !chooseTranslation(perspective.translations))) {
120+
if (
121+
!perspective.translations ||
122+
(perspective.translations && !chooseTranslation(perspective.translations))
123+
) {
105124
return;
106125
}
107126

@@ -129,7 +148,8 @@ export const LanguageNode = ({
129148
)}
130149
{perspective.translations && (
131150
<>
132-
<i className="lingvo-icon lingvo-icon_table" />{chooseTranslation(perspective.translations)}
151+
<i className="lingvo-icon lingvo-icon_table" />
152+
{chooseTranslation(perspective.translations)}
133153
</>
134154
)}
135155
</Dropdown.Item>
@@ -138,17 +158,24 @@ export const LanguageNode = ({
138158
</Dropdown.Menu>
139159
</Dropdown>
140160
)}
161+
141162
{authors && authors.length !== 0 && <span className="dict-authors">({authors.join(", ")})</span>}
142163
{config.buildType === "server" && signedIn && dictionary.english_status === "Published" && (
143164
<Popup
144-
trigger={
145-
<i className="lingvo-icon lingvo-icon_published" />
146-
}
165+
trigger={<i className="lingvo-icon lingvo-icon_published" />}
147166
content={publishedStr}
148167
className="lingvo-popup lingvo-popup_published"
149168
hideOnScroll={true}
150169
/>
151170
)}
171+
172+
{/* new!!!!!! */}
173+
<Button
174+
icon={<i className="lingvo-icon lingvo-icon_refresh" />}
175+
onClick={() => onSynchronize(dictionary.id, dictionaries)}
176+
className="lingvo-button-green lingvo-perspective-button"
177+
/>
178+
{/* /new!!!!!! */}
152179
</li>
153180
);
154181
})}
@@ -157,6 +184,16 @@ export const LanguageNode = ({
157184
);
158185
};
159186

187+
/* new!!!!!! */
188+
189+
/*LangNode.propTypes = {
190+
openModal: PropTypes.func.isRequired
191+
};*/
192+
193+
export const LanguageNode = compose(connect(null, dispatch => bindActionCreators({ openModal }, dispatch)))(LangNode);
194+
195+
/* /new!!!!!! */
196+
160197
/** Language tree node of a grant. */
161198
export const GrantNode = ({
162199
node,

0 commit comments

Comments
 (0)