Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit af47719

Browse files
committed
Re-implement QRCode feature for shared links
1 parent e3b4ab2 commit af47719

File tree

6 files changed

+37
-2
lines changed

6 files changed

+37
-2
lines changed

core/src/plugins/action.share/res/react-share-form.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ div#react_share_form .additional-actions-links a {
7979
display: inline-block;
8080
margin-left: 10px;
8181
}
82+
div#react_share_form .additional-actions-links a.qrcode-active {
83+
color: #333333;
84+
}
85+
div#react_share_form .qrCode {
86+
text-align: center;
87+
}
88+
div#react_share_form .qrCode canvas {
89+
margin-top: 10px;
90+
}
8291
div#react_share_form .form-legend {
8392
color: #bbb;
8493
margin-top: -5px !important;

core/src/plugins/action.share/res/react-share-form.less

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ div#react_share_form {
9898
cursor: pointer;
9999
display: inline-block;
100100
margin-left: 10px;
101+
&.qrcode-active{
102+
color: #333333;
103+
}
104+
}
105+
}
106+
.qrCode{
107+
text-align: center;
108+
canvas{
109+
margin-top: 10px;
101110
}
102111
}
103112
.form-legend {

core/src/plugins/action.share/res/react/ShareDialog.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@
854854
showMailer:React.PropTypes.func
855855
},
856856
getInitialState: function(){
857-
return {editLink: false, copyMessage:''};
857+
return {editLink: false, copyMessage:'', showQRCode: false};
858858
},
859859
toggleEditMode: function(){
860860
if(this.state.editLink && this.state.customLink){
@@ -917,6 +917,10 @@
917917
this.props.showMailer(mailData.subject, mailData.message, []);
918918
},
919919

920+
toggleQRCode: function(){
921+
this.setState({showQRCode:!this.state.showQRCode});
922+
},
923+
920924
render: function(){
921925
var publicLink = this.props.linkData['public_link'];
922926
var editAllowed = this.props.editAllowed && !this.props.linkData['hash_is_shorten'] && !this.context.isReadonly() && this.props.shareModel.currentIsOwner();
@@ -944,13 +948,19 @@
944948
if(editAllowed){
945949
actionLinks.push(<a key="customize" onClick={this.toggleEditMode}>{this.context.getMessage('193')}</a>);
946950
}
951+
if(ReactModel.Share.qrcodeEnabled()){
952+
actionLinks.push(<a className={this.state.showQRCode?'qrcode-active':''} key="qrcode" onClick={this.toggleQRCode}>{this.context.getMessage('94')}</a>)
953+
}
947954
if(actionLinks.length){
948955
actionLinks = (
949956
<div className="additional-actions-links">{actionLinks}</div>
950957
) ;
951958
}else{
952959
actionLinks = null;
953960
}
961+
if(this.state.showQRCode){
962+
var qrCode = <div className="qrCode"><ReactQRCode size={128} value={publicLink} level="Q"/></div>;
963+
}
954964
return (
955965
<div className="public-link-container">
956966
<ReactMUI.TextField
@@ -963,6 +973,7 @@
963973
/> {copyButton}
964974
<div style={{textAlign:'center'}} className="section-legend" dangerouslySetInnerHTML={setHtml()}/>
965975
{actionLinks}
976+
{qrCode}
966977
</div>
967978
);
968979
}

core/src/plugins/action.share/res/react/model/ShareModel.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,10 @@
857857
return global.pydio.getPluginConfigs("core.ocs").get("ENABLE_FEDERATED_SHARING");
858858
}
859859

860+
static qrcodeEnabled(){
861+
return global.pydio.getPluginConfigs("action.share").get("CREATE_QRCODE");
862+
}
863+
860864
prepareEmail(shareType, linkId = null){
861865
var MessageHash = global.pydio.MessageHash;
862866
var ApplicationTitle = global.pydio.appTitle;

core/src/plugins/gui.ajax/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"lodash": "^3.10.1",
2525
"classnames": "~2.1.3",
2626
"react-autosuggest": "1.18.2",
27-
"clipboard":"^1.5.8"
27+
"clipboard":"^1.5.8",
28+
"qrcode.react":"0.6.1"
2829
},
2930
"devDependencies": {
3031
"grunt": "~0.4.5",

core/src/plugins/gui.ajax/res/js/vendor/nodejs/export.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ window.ReactDND.flow = require('lodash/function/flow');
1414
window.classNames = require('classnames');
1515
window.ReactAutoSuggest = require('react-autosuggest');
1616
window.Clipboard = require('clipboard');
17+
window.ReactQRCode = require('qrcode.react');
1718
window.injectTapEventPlugin();

0 commit comments

Comments
 (0)