@@ -37,7 +37,7 @@ export const fieldsQuery = gql`
3737 data_type
3838 data_type_translation_gist_id
3939 }
40- user_blobs(data_type: "txt") {
40+ user_blobs(data_type: [ "txt", "json"] ) {
4141 id
4242 data_type
4343 name
@@ -46,7 +46,15 @@ export const fieldsQuery = gql`
4646 }
4747` ;
4848
49- const convertMutation = gql `
49+ const convertJsonMutation = gql `
50+ mutation convertMutation($corpus_inf: CorpusInf!, $columns_inf: [ColumnInf]!) {
51+ convert_parallel_json(corpus_inf: $corpus_inf, columns_inf: $columns_inf) {
52+ triumph
53+ }
54+ }
55+ ` ;
56+
57+ const convertTxtMutation = gql `
5058 mutation convertMutation($corpus_inf: CorpusInf!, $columns_inf: [ColumnInf]!) {
5159 convert_plain_text(corpus_inf: $corpus_inf, columns_inf: $columns_inf) {
5260 triumph
@@ -95,7 +103,7 @@ class Info extends React.Component {
95103 data : { loading, error, user_blobs : blobs }
96104 } = this . props ;
97105 if ( ! loading && ! error ) {
98- const newBlobs = fromJS ( blobs . filter ( b => b . data_type === "txt" ) ) . map ( v => v . set ( "values" , new Map ( ) ) ) ;
106+ const newBlobs = fromJS ( blobs ) . map ( v => v . set ( "values" , new Map ( ) ) ) ;
99107 // XXX: Ugly workaround
100108 if ( JSON . stringify ( this . props . blobs ) !== JSON . stringify ( newBlobs ) ) {
101109 this . props . setBlobs ( newBlobs ) ;
@@ -127,10 +135,6 @@ class Info extends React.Component {
127135 return ( column , value , oldValue ) => this . props . updateColumn ( id , column , value , oldValue ) ;
128136 }
129137
130- onUpdateColumn ( id ) {
131- return ( column , value , oldValue ) => this . props . updateColumn ( id , column , value , oldValue ) ;
132- }
133-
134138 onSetLanguage ( id ) {
135139 return language => this . props . setLanguage ( id , language ) ;
136140 }
@@ -153,12 +157,13 @@ class Info extends React.Component {
153157 }
154158
155159 render ( ) {
156- const { step, isNextStep, blobs, linking, columnTypes, languages, licenses, locales, data } = this . props ;
160+ const { step, isNextStep, blobs, linking, mode , columnTypes, languages, licenses, locales, data } = this . props ;
157161
158162 if ( data . loading || data . error ) {
159163 return null ;
160164 }
161165
166+ const mode_note = ! ! mode ? ` (${ mode } )` : "" ;
162167 const { all_fields : fields } = data ;
163168 const fieldTypes = fromJS ( fields ) . filter ( field => field . get ( "data_type" ) === "Text" ) ;
164169 let i = 0 ;
@@ -167,7 +172,7 @@ class Info extends React.Component {
167172 < Step . Group widths = { 4 } >
168173 < Step link active = { step === "LINKING" } onClick = { this . onStepClick ( "LINKING" ) } >
169174 < Step . Content >
170- < Step . Title > { this . context ( "Parent Corpora" ) } </ Step . Title >
175+ < Step . Title > { this . context ( "Parent Corpora" ) + mode_note . toUpperCase ( ) } </ Step . Title >
171176 < Step . Description > { this . context ( "Choose parallel corpora" ) } </ Step . Description >
172177 </ Step . Content >
173178 </ Step >
@@ -261,7 +266,7 @@ class Info extends React.Component {
261266 </ Button >
262267 ) : step === "LINKING" ? (
263268 < Message style = { { margin : 0 , textAlign : "center" } } >
264- < Message . Content > { this . context ( "Choose at least two parent corpora." ) } </ Message . Content >
269+ < Message . Content > { this . context ( "Choose at least two txt corpora or one json file ." ) } </ Message . Content >
265270 </ Message >
266271 ) : step === "COLUMNS" ? (
267272 < Message style = { { margin : 0 , textAlign : "center" } } >
@@ -276,11 +281,16 @@ class Info extends React.Component {
276281Info . contextType = TranslationContext ;
277282
278283function mapStateToProps ( state ) {
284+
285+ const linking = selectors . getLinking ( state ) ;
286+ const mode = linking . first ( ) ? linking . first ( ) . get ( "data_type" ) : null ;
287+
279288 return {
280289 step : selectors . getStep ( state ) ,
281- isNextStep : selectors . getNextStep ( state , true ) ,
290+ isNextStep : selectors . getNextStep ( state , mode ) ,
282291 blobs : selectors . getBlobs ( state ) ,
283- linking : selectors . getLinking ( state ) ,
292+ linking,
293+ mode,
284294 columnTypes : selectors . getColumnTypes ( state ) ,
285295 languages : selectors . getLanguages ( state ) ,
286296 licenses : selectors . getLicenses ( state ) ,
@@ -303,13 +313,15 @@ const mapDispatchToProps = {
303313
304314Info . propTypes = {
305315 data : PropTypes . object ,
306- convert : PropTypes . func . isRequired ,
316+ convertTxt : PropTypes . func . isRequired ,
317+ convertJson : PropTypes . func . isRequired ,
307318 licenses : PropTypes . object . isRequired ,
308319 setLicense : PropTypes . func . isRequired
309320} ;
310321
311322export default compose (
312323 connect ( mapStateToProps , mapDispatchToProps ) ,
313324 graphql ( fieldsQuery , { options : { fetchPolicy : "network-only" } } ) ,
314- graphql ( convertMutation , { name : "convert" } )
325+ graphql ( convertTxtMutation , { name : "convertTxt" } ) ,
326+ graphql ( convertJsonMutation , { name : "convertJson" } )
315327) ( Info ) ;
0 commit comments