11import { createElement , Component , render } from 'preact' ;
22import { Text , withText } from 'preact-i18n' ;
33import { withIntl } from '../../enhancers' ;
4- import { ActionMenuGroup , ActionMenuItem , NestedActionMenuItem } from '@zimbra-client/components' ;
4+ import { ModalDialog , ActionMenuGroup , ActionMenuItem , NestedActionMenuItem } from '@zimbra-client/components' ;
55import style from './style' ;
66import { getOCSPath , getDAVPath , getName , getTimeDate , getSize , sanitizeFileName , getParentPath } from '../../utils' ;
77import RenderPropfind from '../render-propfind' ;
@@ -24,6 +24,9 @@ import RenderPropfind from '../render-propfind';
2424 shareLinkPassword : 'nextcloud-zimlet-modern.shareLinkPassword' ,
2525 expirationDate : 'nextcloud-zimlet-modern.expirationDate' ,
2626 plainTextShareLink : 'nextcloud-zimlet-modern.plainTextShareLink' ,
27+ attachFromNextcloud : 'nextcloud-zimlet-modern.attachFromNextcloud' ,
28+ attachedOK : 'nextcloud-zimlet-modern.attachedOK' ,
29+ linkInserted : 'nextcloud-zimlet-modern.linkInserted'
2730} )
2831export default class NextcloudAttacher extends Component {
2932 constructor ( props ) {
@@ -89,6 +92,7 @@ export default class NextcloudAttacher extends Component {
8992 if ( ! editor . isPlainText ( ) )
9093 {
9194 editor . insertLinksAtCaret ( [ OCSResponse ] ) ;
95+ this . alert ( this . props . linkInserted ) ;
9296 }
9397 else
9498 {
@@ -112,6 +116,7 @@ export default class NextcloudAttacher extends Component {
112116 else if ( attachType == "attach" ) {
113117 editor . addAttachments ( [ file ] , false ) ;
114118 }
119+ this . alert ( this . props . attachedOK ) ;
115120 }
116121 } else {
117122 this . alert ( this . props . AttachFailure ) ;
@@ -122,20 +127,52 @@ export default class NextcloudAttacher extends Component {
122127 }
123128
124129 showDialog = ( editor , attachType ) => {
125- let display = window . parent . document . getElementsByClassName ( "zimbra-client_composer_right" ) ;
126- let dialog = < div > < div id = "shareLinkOptions" style = "margin:5px;margin-bottom:15px" > < input id = "linkSharePassword" placeholder = { this . props . shareLinkPassword } value = "" > </ input > { this . props . expirationDate } : < input type = "date" id = "expirationDate" name = "expirationDate" value = "" > </ input > </ div > < div onClick = { e => this . DAVItemListClick ( e , editor , attachType ) } id = "nextcloudPropfind" style = "width:100%; padding-left:10px; overflow:scroll; height:100%" > </ div > </ div >
127- display [ 0 ] . style . minWidth = "600px" ;
128- render ( dialog , display [ 0 ] ) ;
129- if ( attachType == "attachAsLink" ) {
130- window . parent . document . getElementById ( "shareLinkOptions" ) . style . display = "block" ;
131- window . parent . document . getElementById ( "expirationDate" ) . min = ( new Date ( Date . now ( ) + 1 * 24 * 60 * 60 * 1000 ) ) . toISOString ( ) . slice ( 0 , 10 ) ;
132- }
133- else {
134- window . parent . document . getElementById ( "shareLinkOptions" ) . style . display = "none" ;
130+ const minDate = ( new Date ( Date . now ( ) + 1 * 24 * 60 * 60 * 1000 ) ) . toISOString ( ) . slice ( 0 , 10 ) ;
131+
132+ switch ( attachType ) {
133+ case 'attach' :
134+ this . modalTitle = this . props . attachFromNextcloud ;
135+ this . displayShareLinkOptions = "none" ;
136+ break ;
137+ case 'attachInline' :
138+ this . modalTitle = this . props . attachInline
139+ this . displayShareLinkOptions = "none" ;
140+ break ;
141+ case 'attachAsLink' :
142+ this . modalTitle = this . props . attachAsLink ;
143+ this . displayShareLinkOptions = "block" ;
144+ break ;
135145 }
146+
147+ this . modal = (
148+ < ModalDialog
149+ class = { style . modalDialog }
150+ contentClass = { style . modalContent }
151+ innerClass = { style . inner }
152+ onClose = { this . handleClose }
153+ cancelButton = { false }
154+ header = { false }
155+ footer = { false }
156+ >
157+ < div class = "zimbra-client_modal-dialog_inner" > < header class = "zimbra-client_modal-dialog_header" > < h2 > { this . modalTitle } </ h2 > < button onClick = { this . handleClose } aria-label = "Close" class = "zimbra-client_close-button_close zimbra-client_modal-dialog_actionButton" > < span role = "img" class = "zimbra-icon zimbra-icon-close blocks_icon_md" > </ span > </ button > </ header >
158+ < div class = "zimbra-client_modal-dialog_content zimbra-client_language-modal_languageModalContent" > < div style = { { display :this . displayShareLinkOptions } } > < div style = "margin:5px;margin-bottom:15px" > < input id = "linkSharePassword" placeholder = { this . props . shareLinkPassword } value = "" > </ input > { this . props . expirationDate } : < input type = "date" min = { minDate } id = "expirationDate" name = "expirationDate" value = "" > </ input > </ div > </ div > < div onClick = { e => this . DAVItemListClick ( e , editor , attachType ) } id = "nextcloudPropfind" style = "width:100%; padding-left:10px; overflow:scroll; max-height:400px" > </ div >
159+ < button type = "button" onClick = { this . handleClose } class = "blocks_button_button blocks_button_primary blocks_button_regular zimbra-client_sidebar-primary-button_button" > OK</ button >
160+ </ div >
161+ </ div >
162+ </ ModalDialog >
163+ ) ;
164+
165+ const { dispatch } = this . zimletContext . store ;
166+ dispatch ( this . zimletContext . zimletRedux . actions . zimlets . addModal ( { id : 'attachFromNextcloudModal' , modal : this . modal } ) ) ;
167+
136168 this . doPropFind ( "/" ) ;
137169 }
138170
171+ handleClose = e => {
172+ const { dispatch } = this . zimletContext . store ;
173+ dispatch ( this . zimletContext . zimletRedux . actions . zimlets . addModal ( { id : 'attachFromNextcloudModal' } ) ) ;
174+ }
175+
139176 doPropFind = ( path ) => {
140177 let fakeEmailData = { }
141178 fakeEmailData . nextcloudAction = "propfind" ;
0 commit comments