@@ -1113,30 +1113,24 @@ const Filter = handlers(({ value, onChange, onSubmit, isCaseSens, onToggleCaseSe
1113
1113
) ;
1114
1114
} ) ;
1115
1115
1116
- const tsakorpusIdStrSet = {
1117
- "3796,6" : null ,
1118
- "4222,7" : null ,
1119
- "3235,7" : null ,
1120
- "4083,7" : null ,
1121
- "3421,8" : null ,
1122
- "3648,8" : null ,
1123
- "3814,9" : null ,
1124
- "3872,9" : null ,
1125
- "5180,9" : null ,
1126
- "3428,9" : null ,
1127
- "4448,9" : null ,
1128
- "4830,11" : null ,
1129
- "5039,22" : null ,
1130
- "4830,27" : null ,
1131
- "4473,32" : null ,
1132
- "4443,37" : null ,
1133
- "5124,45" : null ,
1134
- "4447,99" : null ,
1135
- "4447,130" : null ,
1136
- "3539,769" : null ,
1137
- "3391,9437" : null ,
1138
- "4084,86722" : null
1139
- } ;
1116
+ const getUploadDate = gql `
1117
+ query getUploadDate($id: LingvodocID!) {
1118
+ perspective(id: $id) {
1119
+ id
1120
+ additional_metadata {
1121
+ uploaded_at
1122
+ }
1123
+ }
1124
+ }
1125
+ ` ;
1126
+
1127
+ const uploadPerspective = gql `
1128
+ mutation uploadPerspective($id: LingvodocID!, $debugFlag: Boolean) {
1129
+ tsakorpus(perspective_id: $id, debug_flag: $debugFlag) {
1130
+ triumph
1131
+ }
1132
+ }
1133
+ ` ;
1140
1134
1141
1135
const ModeSelector = compose (
1142
1136
connect ( state => state . user ) ,
@@ -1157,6 +1151,24 @@ const ModeSelector = compose(
1157
1151
} ) => {
1158
1152
const getTranslation = useContext ( TranslationContext ) ;
1159
1153
1154
+ const { data : dateData , error : dateError , loading : dateLoading , refetch} = (
1155
+ useQuery ( getUploadDate , { variables : { id } , fetchPolicy : "network-only" } ) ) ;
1156
+
1157
+ const [ runUploadPerspective , { data, error, loading} ] = (
1158
+ useMutation ( uploadPerspective , { variables : { id } , onCompleted : refetch } ) ) ;
1159
+
1160
+ if ( dateLoading || dateError ) {
1161
+ return null ;
1162
+ }
1163
+
1164
+ const {
1165
+ perspective : { additional_metadata : { uploaded_at } }
1166
+ } = dateData ;
1167
+
1168
+ if ( ! uploaded_at && ! loading && ! error && ! data ) {
1169
+ runUploadPerspective ( ) ;
1170
+ }
1171
+
1160
1172
const modes = { } ;
1161
1173
if ( user . id !== undefined ) {
1162
1174
Object . assign ( modes , {
@@ -1190,8 +1202,6 @@ const ModeSelector = compose(
1190
1202
}
1191
1203
} ) ;
1192
1204
1193
- const tsakorpusFlag = tsakorpusIdStrSet . hasOwnProperty ( id2str ( id ) ) ;
1194
-
1195
1205
return (
1196
1206
< Menu tabular className = "lingvo-perspective-menu" >
1197
1207
{ map ( modes , ( info , stub ) => (
@@ -1200,10 +1210,19 @@ const ModeSelector = compose(
1200
1210
{ info . component === PerspectiveView ? < Counter id = { id } mode = { info . entitiesMode } /> : null }
1201
1211
</ Menu . Item >
1202
1212
) ) }
1203
- { tsakorpusFlag && (
1204
- < Menu . Item key = "corpus_search" href = { `http://83.149.198.78/${ id [ 0 ] } _${ id [ 1 ] } /search` } >
1205
- { getTranslation ( "Corpus search" ) }
1206
- </ Menu . Item >
1213
+ { ( uploaded_at || loading ) && (
1214
+ < Menu . Item
1215
+ key = "corpus_search"
1216
+ onClick = { ( ) => uploaded_at && window . open ( `http://83.149.198.78/${ id [ 0 ] } _${ id [ 1 ] } /search` , "_blank" ) }
1217
+ content = {
1218
+ loading ? (
1219
+ < span >
1220
+ { getTranslation ( "Uploading" ) } ... < Icon name = "spinner" loading />
1221
+ </ span >
1222
+ ) : (
1223
+ getTranslation ( "Corpus search" )
1224
+ ) }
1225
+ />
1207
1226
) }
1208
1227
< Tools
1209
1228
id = { id }
0 commit comments