| 
				
			 | 
			
			
				@@ -6,7 +6,10 @@ import { 
			 | 
		
	
		
			
			| 
				6
			 | 
			
				6
			 | 
			
			
				   PopinFixedHeader, 
			 | 
		
	
		
			
			| 
				7
			 | 
			
				7
			 | 
			
			
				   PopinFixedOption, 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				8
			 | 
			
			
				   PopinFixedContent, 
			 | 
		
	
		
			
			| 
				9
			 | 
			
				
			 | 
			
			
				-  Timeline 
			 | 
		
	
		
			
			| 
				
			 | 
			
				9
			 | 
			
			
				+  Timeline, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				10
			 | 
			
			
				+  NewVersionBtn, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				11
			 | 
			
			
				+  ArchiveDeleteContent, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				12
			 | 
			
			
				+  SelectStatus 
			 | 
		
	
		
			
			| 
				10
			 | 
			
				13
			 | 
			
			
				 } from 'tracim_lib' 
			 | 
		
	
		
			
			| 
				11
			 | 
			
				14
			 | 
			
			
				 import { FETCH_CONFIG, MODE, debug } from '../helper.js' 
			 | 
		
	
		
			
			| 
				12
			 | 
			
				15
			 | 
			
			
				 import i18n from '../i18n.js' 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -88,15 +91,17 @@ class HtmlDocument extends React.Component { 
			 | 
		
	
		
			
			| 
				88
			 | 
			
				91
			 | 
			
			
				     ]) 
			 | 
		
	
		
			
			| 
				89
			 | 
			
				92
			 | 
			
			
				       .then(([resComment, resRevision]) => { 
			 | 
		
	
		
			
			| 
				90
			 | 
			
				93
			 | 
			
			
				         const resCommentWithProperDate = resComment.body.map(c => ({...c, created: (new Date(c.created)).toLocaleString()})) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				91
			 | 
			
				95
			 | 
			
			
				         const revisionWithComment = resRevision.body 
			 | 
		
	
		
			
			| 
				92
			 | 
			
				
			 | 
			
			
				-          .map(r => ({ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				96
			 | 
			
			
				+          .map((r, i) => ({ 
			 | 
		
	
		
			
			| 
				93
			 | 
			
				97
			 | 
			
			
				             ...r, 
			 | 
		
	
		
			
			| 
				94
			 | 
			
				98
			 | 
			
			
				             created: (new Date(r.created)).toLocaleString(), 
			 | 
		
	
		
			
			| 
				95
			 | 
			
				99
			 | 
			
			
				             timelineType: 'revision', 
			 | 
		
	
		
			
			| 
				96
			 | 
			
				100
			 | 
			
			
				             commentList: r.comments_ids.map(ci => ({ 
			 | 
		
	
		
			
			| 
				97
			 | 
			
				101
			 | 
			
			
				               timelineType: 'comment', 
			 | 
		
	
		
			
			| 
				98
			 | 
			
				102
			 | 
			
			
				               ...resCommentWithProperDate.find(c => c.content_id === ci) 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				
			 | 
			
			
				-            })) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				+            })), 
			 | 
		
	
		
			
			| 
				
			 | 
			
				104
			 | 
			
			
				+            number: i + 1 
			 | 
		
	
		
			
			| 
				100
			 | 
			
				105
			 | 
			
			
				           })) 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				106
			 | 
			
			
				           .reduce((acc, rev) => [ 
			 | 
		
	
		
			
			| 
				102
			 | 
			
				107
			 | 
			
			
				             ...acc, 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -108,8 +113,6 @@ class HtmlDocument extends React.Component { 
			 | 
		
	
		
			
			| 
				108
			 | 
			
				113
			 | 
			
			
				             })) 
			 | 
		
	
		
			
			| 
				109
			 | 
			
				114
			 | 
			
			
				           ], []) 
			 | 
		
	
		
			
			| 
				110
			 | 
			
				115
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				111
			 | 
			
				
			 | 
			
			
				-        console.log(revisionWithComment) 
			 | 
		
	
		
			
			| 
				112
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				113
			 | 
			
				116
			 | 
			
			
				         this.setState({timeline: revisionWithComment}) 
			 | 
		
	
		
			
			| 
				114
			 | 
			
				117
			 | 
			
			
				       }) 
			 | 
		
	
		
			
			| 
				115
			 | 
			
				118
			 | 
			
			
				       .catch(e => { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -204,9 +207,7 @@ class HtmlDocument extends React.Component { 
			 | 
		
	
		
			
			| 
				204
			 | 
			
				207
			 | 
			
			
				     const fetchResultSaveEditStatus = await fetch(`${config.apiUrl}/workspaces/${content.workspace_id}/html-documents/${content.content_id}/status`, { 
			 | 
		
	
		
			
			| 
				205
			 | 
			
				208
			 | 
			
			
				       ...FETCH_CONFIG, 
			 | 
		
	
		
			
			| 
				206
			 | 
			
				209
			 | 
			
			
				       method: 'PUT', 
			 | 
		
	
		
			
			| 
				207
			 | 
			
				
			 | 
			
			
				-      body: JSON.stringify({ 
			 | 
		
	
		
			
			| 
				208
			 | 
			
				
			 | 
			
			
				-        status: newStatus 
			 | 
		
	
		
			
			| 
				209
			 | 
			
				
			 | 
			
			
				-      }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				210
			 | 
			
			
				+      body: JSON.stringify({status: newStatus}) 
			 | 
		
	
		
			
			| 
				210
			 | 
			
				211
			 | 
			
			
				     }) 
			 | 
		
	
		
			
			| 
				211
			 | 
			
				212
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				212
			 | 
			
				213
			 | 
			
			
				     handleFetchResult(fetchResultSaveEditStatus) 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -228,6 +229,7 @@ class HtmlDocument extends React.Component { 
			 | 
		
	
		
			
			| 
				228
			 | 
			
				229
			 | 
			
			
				     //   method: 'PUT' 
			 | 
		
	
		
			
			| 
				229
			 | 
			
				230
			 | 
			
			
				     // }) 
			 | 
		
	
		
			
			| 
				230
			 | 
			
				231
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				232
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				231
			 | 
			
				233
			 | 
			
			
				   handleClickDelete = async () => { 
			 | 
		
	
		
			
			| 
				232
			 | 
			
				234
			 | 
			
			
				     console.log('delete') 
			 | 
		
	
		
			
			| 
				233
			 | 
			
				235
			 | 
			
			
				     // const { config, content } = this.state 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -237,8 +239,21 @@ class HtmlDocument extends React.Component { 
			 | 
		
	
		
			
			| 
				237
			 | 
			
				239
			 | 
			
			
				     // }) 
			 | 
		
	
		
			
			| 
				238
			 | 
			
				240
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				239
			 | 
			
				241
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				242
			 | 
			
			
				+  handleClickShowRevision = revision => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				243
			 | 
			
			
				+    console.log('revision', revision) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				244
			 | 
			
			
				+    this.setState(prev => ({ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				245
			 | 
			
			
				+      content: { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				246
			 | 
			
			
				+        ...prev.content, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				247
			 | 
			
			
				+        label: revision.label, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				248
			 | 
			
			
				+        raw_content: revision.raw_content, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				249
			 | 
			
			
				+        number: revision.number 
			 | 
		
	
		
			
			| 
				
			 | 
			
				250
			 | 
			
			
				+      }, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				251
			 | 
			
			
				+      mode: MODE.REVISION 
			 | 
		
	
		
			
			| 
				
			 | 
			
				252
			 | 
			
			
				+    })) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				253
			 | 
			
			
				+  } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				254
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				240
			 | 
			
				255
			 | 
			
			
				   render () { 
			 | 
		
	
		
			
			| 
				241
			 | 
			
				
			 | 
			
			
				-    const { isVisible, loggedUser, content, timeline, newComment, timelineWysiwyg, config } = this.state 
			 | 
		
	
		
			
			| 
				
			 | 
			
				256
			 | 
			
			
				+    const { isVisible, loggedUser, content, timeline, newComment, timelineWysiwyg, config, mode } = this.state 
			 | 
		
	
		
			
			| 
				242
			 | 
			
				257
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				243
			 | 
			
				258
			 | 
			
			
				     if (!isVisible) return null 
			 | 
		
	
		
			
			| 
				244
			 | 
			
				259
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -252,24 +267,36 @@ class HtmlDocument extends React.Component { 
			 | 
		
	
		
			
			| 
				252
			 | 
			
				267
			 | 
			
			
				           onValidateChangeTitle={this.handleSaveEditTitle} 
			 | 
		
	
		
			
			| 
				253
			 | 
			
				268
			 | 
			
			
				         /> 
			 | 
		
	
		
			
			| 
				254
			 | 
			
				269
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				255
			 | 
			
				
			 | 
			
			
				-        <PopinFixedOption 
			 | 
		
	
		
			
			| 
				256
			 | 
			
				
			 | 
			
			
				-          customClass={`${config.slug}`} 
			 | 
		
	
		
			
			| 
				257
			 | 
			
				
			 | 
			
			
				-          availableStatus={config.availableStatuses} 
			 | 
		
	
		
			
			| 
				258
			 | 
			
				
			 | 
			
			
				-          onClickNewVersionBtn={this.handleClickNewVersion} 
			 | 
		
	
		
			
			| 
				259
			 | 
			
				
			 | 
			
			
				-          onChangeStatus={this.handleChangeStatus} 
			 | 
		
	
		
			
			| 
				260
			 | 
			
				
			 | 
			
			
				-          selectedStatus={config.availableStatuses.find(s => s.slug === content.status)} // might be empty while api hasn't responded yet 
			 | 
		
	
		
			
			| 
				261
			 | 
			
				
			 | 
			
			
				-          onClickArchive={this.handleClickArchive} 
			 | 
		
	
		
			
			| 
				262
			 | 
			
				
			 | 
			
			
				-          onClickDelete={this.handleClickDelete} 
			 | 
		
	
		
			
			| 
				263
			 | 
			
				
			 | 
			
			
				-          i18n={i18n} 
			 | 
		
	
		
			
			| 
				264
			 | 
			
				
			 | 
			
			
				-        /> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				270
			 | 
			
			
				+        <PopinFixedOption customClass={`${config.slug}`} i18n={i18n}> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				271
			 | 
			
			
				+          <div> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				272
			 | 
			
			
				+            <NewVersionBtn onClickNewVersionBtn={this.handleClickNewVersion} disabled={mode === MODE.REVISION} /> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				273
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				274
			 | 
			
			
				+            <SelectStatus 
			 | 
		
	
		
			
			| 
				
			 | 
			
				275
			 | 
			
			
				+              selectedStatus={config.availableStatuses.find(s => s.slug === content.status)} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				276
			 | 
			
			
				+              availableStatus={config.availableStatuses} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				277
			 | 
			
			
				+              onChangeStatus={this.handleChangeStatus} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				278
			 | 
			
			
				+              disabled={mode === MODE.REVISION} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				279
			 | 
			
			
				+            /> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				280
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				281
			 | 
			
			
				+            <ArchiveDeleteContent 
			 | 
		
	
		
			
			| 
				
			 | 
			
				282
			 | 
			
			
				+              onClickArchiveBtn={this.handleClickArchive} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				283
			 | 
			
			
				+              onClickDeleteBtn={this.handleClickDelete} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				284
			 | 
			
			
				+              disabled={mode === MODE.REVISION} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				285
			 | 
			
			
				+            /> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				286
			 | 
			
			
				+          </div> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				287
			 | 
			
			
				+        </PopinFixedOption> 
			 | 
		
	
		
			
			| 
				265
			 | 
			
				288
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				266
			 | 
			
				289
			 | 
			
			
				         <PopinFixedContent customClass={`${config.slug}__contentpage`}> 
			 | 
		
	
		
			
			| 
				267
			 | 
			
				290
			 | 
			
			
				           <HtmlDocumentComponent 
			 | 
		
	
		
			
			| 
				268
			 | 
			
				
			 | 
			
			
				-            mode={this.state.mode} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				291
			 | 
			
			
				+            mode={mode} 
			 | 
		
	
		
			
			| 
				269
			 | 
			
				292
			 | 
			
			
				             wysiwygNewVersion={'wysiwygNewVersion'} 
			 | 
		
	
		
			
			| 
				270
			 | 
			
				293
			 | 
			
			
				             onClickCloseEditMode={this.handleCloseNewVersion} 
			 | 
		
	
		
			
			| 
				271
			 | 
			
				294
			 | 
			
			
				             onClickValidateBtn={this.handleSaveHtmlDocument} 
			 | 
		
	
		
			
			| 
				272
			 | 
			
				
			 | 
			
			
				-            version={timeline.filter(t => t.timelineType === 'revision').length} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				295
			 | 
			
			
				+            version={ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				296
			 | 
			
			
				+              mode === MODE.REVISION 
			 | 
		
	
		
			
			| 
				
			 | 
			
				297
			 | 
			
			
				+                ? content.number 
			 | 
		
	
		
			
			| 
				
			 | 
			
				298
			 | 
			
			
				+                : timeline.filter(t => t.timelineType === 'revision').length 
			 | 
		
	
		
			
			| 
				
			 | 
			
				299
			 | 
			
			
				+            } 
			 | 
		
	
		
			
			| 
				273
			 | 
			
				300
			 | 
			
			
				             text={content.raw_content} 
			 | 
		
	
		
			
			| 
				274
			 | 
			
				301
			 | 
			
			
				             onChangeText={this.handleChangeText} 
			 | 
		
	
		
			
			| 
				275
			 | 
			
				302
			 | 
			
			
				             key={'html-documents'} 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -280,10 +307,12 @@ class HtmlDocument extends React.Component { 
			 | 
		
	
		
			
			| 
				280
			 | 
			
				307
			 | 
			
			
				             loggedUser={loggedUser} 
			 | 
		
	
		
			
			| 
				281
			 | 
			
				308
			 | 
			
			
				             timelineData={timeline} 
			 | 
		
	
		
			
			| 
				282
			 | 
			
				309
			 | 
			
			
				             newComment={newComment} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				310
			 | 
			
			
				+            disableComment={mode === MODE.REVISION} 
			 | 
		
	
		
			
			| 
				283
			 | 
			
				311
			 | 
			
			
				             wysiwyg={timelineWysiwyg} 
			 | 
		
	
		
			
			| 
				284
			 | 
			
				312
			 | 
			
			
				             onChangeNewComment={this.handleChangeNewComment} 
			 | 
		
	
		
			
			| 
				285
			 | 
			
				313
			 | 
			
			
				             onClickValidateNewCommentBtn={this.handleClickValidateNewCommentBtn} 
			 | 
		
	
		
			
			| 
				286
			 | 
			
				314
			 | 
			
			
				             onClickWysiwygBtn={this.handleToggleWysiwyg} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				315
			 | 
			
			
				+            onClickRevisionBtn={this.handleClickShowRevision} 
			 | 
		
	
		
			
			| 
				287
			 | 
			
				316
			 | 
			
			
				           /> 
			 | 
		
	
		
			
			| 
				288
			 | 
			
				317
			 | 
			
			
				         </PopinFixedContent> 
			 | 
		
	
		
			
			| 
				289
			 | 
			
				318
			 | 
			
			
				       </PopinFixed> 
			 |