2015-04-14 10:36:12 +02:00
/ *
2018-11-25 17:31:43 +01:00
Copyright 2008 - 2018 Clipperz Srl
2015-04-14 10:36:12 +02:00
This file is part of Clipperz , the online password manager .
For further information about its features and functionalities please
refer to http : //www.clipperz.com.
* Clipperz is free software : you can redistribute it and / or modify it
under the terms of the GNU Affero General Public License as published
by the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
* Clipperz is distributed in the hope that it will be useful , but
WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the GNU Affero General Public License for more details .
* You should have received a copy of the GNU Affero General Public
License along with Clipperz . If not , see http : //www.gnu.org/licenses/.
* /
"use strict" ;
Clipperz . Base . module ( 'Clipperz.PM.UI.Components.DeleteAccount' ) ;
Clipperz . PM . UI . Components . ExtraFeatures . DeleteAccountClass = React . createClass ( {
2016-03-29 11:45:50 +02:00
displayName : 'Clipperz.PM.UI.Components.ExtraFeatures.DeleteAccount' ,
2015-04-14 10:36:12 +02:00
propTypes : {
// featureSet: React.PropTypes.oneOf(['FULL', 'EXPIRED', 'TRIAL']).isRequired,
// 'level': React.PropTypes.oneOf(['hide', 'info', 'warning', 'error']).isRequired
} ,
getInitialState : function ( ) {
return {
'username' : 'empty' ,
'passphrase' : 'empty' ,
'confirm' : '' ,
} ;
} ,
//=========================================================================
handleDeleteAccount : function ( event ) {
event . preventDefault ( ) ;
MochiKit . Signal . signal ( Clipperz . Signal . NotificationCenter , 'deleteAccount' ) ;
} ,
handleFormChange : function ( ) {
var deferredResult ;
deferredResult = new Clipperz . Async . Deferred ( "DeleteAccount.handleDeleteAccount" , { trace : false } ) ;
2016-03-29 11:45:50 +02:00
deferredResult . addCallback ( this . props . userInfo [ 'checkPassphraseCallback' ] , this . refs [ 'passphrase' ] . value ) ;
2015-04-14 10:36:12 +02:00
deferredResult . addMethod ( this , function ( passCheck ) {
2016-03-29 11:45:50 +02:00
var username = this . refs [ 'username' ] . value ;
var passphrase = this . refs [ 'passphrase' ] . value ;
2015-04-14 10:36:12 +02:00
this . setState ( {
'username' : ( username != '' ) ? ( username == this . props . userInfo [ 'username' ] ) ? 'valid' : 'invalid' : 'empty' ,
'passphrase' : ( passphrase != '' ) ? ( passCheck ) ? 'valid' : 'invalid' : 'empty' ,
2016-03-29 11:45:50 +02:00
'confirm' : this . refs [ 'confirm' ] . checked ,
2015-04-14 10:36:12 +02:00
} ) ;
} ) ;
deferredResult . callback ( ) ;
return deferredResult ;
} ,
shouldEnableDeleteAccountButton : function ( ) {
return ( this . state [ 'username' ] == 'valid' && this . state [ 'passphrase' ] == 'valid' && this . state [ 'confirm' ] ) ;
} ,
//=========================================================================
render : function ( ) {
return React . DOM . div ( { className : 'extraFeature deleteAccount' } , [
2015-06-27 19:08:20 +02:00
React . DOM . div ( { 'className' : 'header' } , [
2015-07-05 09:09:33 +02:00
React . DOM . h1 ( { } , "Delete account" ) ,
2015-06-27 19:08:20 +02:00
] ) ,
2015-05-21 14:32:51 +02:00
React . DOM . div ( { 'className' : 'content' } , [
2015-05-07 16:23:57 +02:00
React . DOM . form ( { 'key' : 'form' , 'className' : 'deleteAccountForm' , 'onChange' : this . handleFormChange , 'onSubmit' : this . handleDeleteAccount } , [
React . DOM . div ( { 'key' : 'fields' } , [
2015-06-27 19:08:20 +02:00
React . DOM . label ( { 'key' : 'username-label' , 'htmlFor' : 'name' } , "username" ) ,
React . DOM . input ( { 'key' : 'username' , 'className' : this . state [ 'username' ] , 'type' : 'text' , 'name' : 'name' , 'ref' : 'username' , 'placeholder' : "username" , 'autoCapitalize' : 'none' } ) ,
React . DOM . label ( { 'key' : 'passphrase-label' , 'autoFocus' : 'true' , 'htmlFor' : 'passphrase' } , "passphrase" ) ,
React . DOM . input ( { 'key' : 'passphrase' , 'className' : this . state [ 'passphrase' ] , 'type' : 'password' , 'name' : 'passphrase' , 'ref' : 'passphrase' , 'placeholder' : "passphrase" } ) ,
2015-05-07 16:23:57 +02:00
React . DOM . p ( { } , [
2015-06-27 19:08:20 +02:00
React . DOM . input ( { 'key' : 'confirm' , 'className' : 'confirmCheckbox' , 'type' : 'checkbox' , 'id' : 'deleteAccountConfirmCheckbox' , 'name' : 'confirm' , 'ref' : 'confirm' } ) ,
2016-03-29 11:45:50 +02:00
React . DOM . label ( { 'htmlFor' : 'deleteAccountConfirmCheckbox' } , "All my data will be permanently deleted. I understand that this action cannot be undone or canceled." )
2015-05-07 16:23:57 +02:00
] ) ,
2015-04-14 10:36:12 +02:00
] ) ,
2015-05-07 16:23:57 +02:00
React . DOM . button ( { 'key' : 'button' , 'type' : 'submit' , 'disabled' : ! this . shouldEnableDeleteAccountButton ( ) , 'className' : 'button' } , "Delete my account" )
] )
2015-05-21 14:32:51 +02:00
] )
2015-04-14 10:36:12 +02:00
] ) ;
} ,
//=========================================================================
} ) ;
Clipperz . PM . UI . Components . ExtraFeatures . DeleteAccount = React . createFactory ( Clipperz . PM . UI . Components . ExtraFeatures . DeleteAccountClass ) ;