(function(global){
class Loader{
static loadInfoPanel(container, node){
let mainCont = container.querySelectorAll("#ajxp_shared_info_panel .infoPanelTable")[0];
mainCont.destroy = function(){
React.unmountComponentAtNode(mainCont);
};
mainCont.className += (mainCont.className ? ' ' : '') + 'infopanel-destroyable-pane';
React.render(
React.createElement(InfoPanel, {pydio:global.pydio, node:node}),
mainCont
);
}
}
const InfoPanelInputRow = React.createClass({
render: function(){
return (
{this.props.getMessage(this.props.inputTitle)}
);
}
});
const TemplatePanel = React.createClass({
propTypes: {
node:React.PropTypes.instanceOf(AjxpNode),
pydio:React.PropTypes.instanceOf(Pydio),
getMessage:React.PropTypes.func,
publicLink:React.PropTypes.string
},
getInitialState:function(){
return {show: false};
},
generateTplHTML: function(){
let editors = this.props.pydio.Registry.findEditorsForMime(this.props.node.getAjxpMime(), true);
if(!editors.length){
return null;
}
let newLink = ReactModel.Share.buildDirectDownloadUrl(this.props.node, this.props.publicLink, true);
let editor = FuncUtils.getFunctionByName(editors[0].editorClass, global);
if(editor && editor.getSharedPreviewTemplate){
return {
messageKey:61,
templateString:editor.getSharedPreviewTemplate(this.props.node, newLink, {WIDTH:350, HEIGHT:350, DL_CT_LINK:newLink})
};
}else{
return{
messageKey:60,
templateString:newLink
}
}
},
render : function(){
let data = this.generateTplHTML();
if(!data){
return null;
}
return ;
}
});
const InfoPanel = React.createClass({
propTypes: {
node:React.PropTypes.instanceOf(AjxpNode),
pydio:React.PropTypes.instanceOf(Pydio)
},
getInitialState: function(){
return {
status:'loading',
model : new ReactModel.Share(this.props.pydio, this.props.node)
};
},
componentWillReceiveProps: function(nextProps){
if(nextProps.node && nextProps.node !== this.props.node){
const model = new ReactModel.Share(this.props.pydio, nextProps.node);
this.setState({
status:'loading',
model : model
}, function(){
model.observe("status_changed", this.modelUpdated);
model.initLoad();
}.bind(this))
}
},
componentDidMount:function(){
this.state.model.observe("status_changed", this.modelUpdated);
this.state.model.initLoad();
},
modelUpdated: function(){
if(this.isMounted()){
this.setState({status:this.state.model.getStatus()});
}
},
getMessage: function(id){
try{
return this.props.pydio.MessageHash['share_center.' + id];
}catch(e){
return id;
}
},
render: function(){
if(this.state.model.hasPublicLink()){
var linkData = this.state.model.getPublicLinks()[0];
var isExpired = linkData["is_expired"];
// Main Link Field
var linkField = ();
if(this.props.node.isLeaf() && this.props.pydio.getPluginConfigs("action.share").get("INFOPANEL_DISPLAY_DIRECT_DOWNLOAD")){
// Direct Download Field
var downloadField = ;
}
if(this.props.node.isLeaf() && this.props.pydio.getPluginConfigs("action.share").get("INFOPANEL_DISPLAY_HTML_EMBED")){
// HTML Code Snippet (may be empty)
var templateField = ;
}
}
const users = this.state.model.getSharedUsers();
let sharedUsersEntries = [], remoteUsersEntries = [], sharedUsersBlock;
const {pydio} = this.props;
if(users.length){
sharedUsersEntries = users.map(function(u){
let rights = [];
if(u.RIGHT.indexOf('r') !== -1) rights.push(global.MessageHash["share_center.31"]);
if(u.RIGHT.indexOf('w') !== -1) rights.push(global.MessageHash["share_center.181"]);
const userType = (u.TYPE === 'team' ? 'team' : (u.TYPE === 'group' ? 'group' : 'user'))
return (
);
});
}
const ocsLinks = this.state.model.getOcsLinks();
if(ocsLinks.length){
remoteUsersEntries = ocsLinks.map(function(link){
const i = link['invitation'];
let status;
if(!i){
status = '214';
}else {
if(i.STATUS == 1){
status = '211';
}else if(i.STATUS == 2){
status = '212';
}else if(i.STATUS == 4){
status = '213';
}
}
status = this.getMessage(status);
return (
);
}.bind(this));
}
if(sharedUsersEntries.length || remoteUsersEntries.length){
sharedUsersBlock = (
{this.getMessage('54')}
{sharedUsersEntries}
{remoteUsersEntries}
);
}
if(this.state.model.getStatus() !== 'loading' && !sharedUsersEntries.length
&& !remoteUsersEntries.length && !this.state.model.hasPublicLink()){
let func = function(){
this.state.model.stopSharing();
}.bind(this);
var noEntriesFoundBlock = (
);
}
return (
{linkField}
{downloadField}
{templateField}
{sharedUsersBlock}
{noEntriesFoundBlock}
);
}
});
const ReactInfoPanel = React.createClass({
render: function(){
let actions = [
{global.pydio.getController().fireAction("share-edit-shared");}}
/>
];
return (
);
}
});
global.ShareInfoPanel = {};
global.ShareInfoPanel.loader = Loader.loadInfoPanel;
global.ShareInfoPanel.InfoPanel = ReactInfoPanel;
})(window);