From 3b10e9194c2fb5876f37626ab3f98aedb79c4178 Mon Sep 17 00:00:00 2001 From: cdujeu Date: Mon, 7 Mar 2016 19:41:13 +0100 Subject: [PATCH] Make LeftNavigation panel more generic --- .../ui/prototype/class.AjxpReactComponent.js | 3 +- .../res/js/ui/reactjs/jsx/LeftNavigation.js | 156 ++++++++++++------ .../orbit/css/components/leftpanel.less | 3 + .../gui.ajax/res/themes/orbit/css/pydio.css | 3 + 4 files changed, 113 insertions(+), 52 deletions(-) diff --git a/core/src/plugins/gui.ajax/res/js/ui/prototype/class.AjxpReactComponent.js b/core/src/plugins/gui.ajax/res/js/ui/prototype/class.AjxpReactComponent.js index bb2025f5e4..cf34a7cebd 100644 --- a/core/src/plugins/gui.ajax/res/js/ui/prototype/class.AjxpReactComponent.js +++ b/core/src/plugins/gui.ajax/res/js/ui/prototype/class.AjxpReactComponent.js @@ -35,7 +35,8 @@ Class.create('AjxpReactComponent', AjxpPane, { ResourcesManager.loadClassesAndApply(namespacesToLoad, function(){ this.reactComponent = React.render( React.createElement(window[options.componentNamespace][options.componentName], { - pydio:pydio + pydio:pydio, + pydioId:htmlElement.id }), $(htmlElement) ); diff --git a/core/src/plugins/gui.ajax/res/js/ui/reactjs/jsx/LeftNavigation.js b/core/src/plugins/gui.ajax/res/js/ui/reactjs/jsx/LeftNavigation.js index f16fc62c0a..b23676a995 100644 --- a/core/src/plugins/gui.ajax/res/js/ui/reactjs/jsx/LeftNavigation.js +++ b/core/src/plugins/gui.ajax/res/js/ui/reactjs/jsx/LeftNavigation.js @@ -4,7 +4,8 @@ var LeftPanel = React.createClass({ propTypes:{ - pydio:React.PropTypes.instanceOf(Pydio).isRequired + pydio:React.PropTypes.instanceOf(Pydio).isRequired, + pydioId:React.PropTypes.string.isRequired }, childContextTypes: { @@ -28,7 +29,7 @@ parseComponentConfigs:function(){ var reg = this.props.pydio.Registry.getXML(); - var contentNodes = XMLUtils.XPathSelectNodes(reg, 'client_configs/component_config[@className="AjxpReactComponent::left_navigator"]/additional_content'); + var contentNodes = XMLUtils.XPathSelectNodes(reg, 'client_configs/component_config[@className="AjxpReactComponent::'+this.props.pydioId+'"]/additional_content'); return contentNodes.map(function(node){ return { id:node.getAttribute('id'), @@ -39,11 +40,6 @@ }); }, - createRepositoryEnabled:function(){ - var reg = this.props.pydio.Registry.getXML(); - return XMLUtils.XPathSelectSingleNode(reg, 'actions/action[@name="user_create_repository"]') !== null; - }, - getInitialState:function(){ return { statusOpen:true, @@ -82,23 +78,7 @@ }, render:function(){ - var entries = [], sharedEntries = []; - this.state.workspaces.forEach(function(object, key){ - var entry = ( - - ); - if(object.getOwner()){ - sharedEntries.push(entry); - }else{ - entries.push(entry); - } - }.bind(this)); - var messages = this.props.pydio.MessageHash; const additional = this.state.additionalContents.map(function(paneData){ if(paneData.type == 'ListProvider'){ return ( @@ -113,20 +93,6 @@ } }.bind(this)); - if(this.createRepositoryEnabled()){ - var createClick = function(){ - this.props.pydio.Controller.fireAction('user_create_repository'); - }.bind(this); - var createAction = ( -
-
- + - {messages[417]} -
-
- ); - } - return (
@@ -134,20 +100,13 @@
{additional} -
-
{messages[468]}
-
- {entries} -
-
{messages[469]}
-
- {sharedEntries} -
-
- {createAction} +
- ) + ); } }); @@ -207,13 +166,92 @@ }); + var UserWorkspacesList = React.createClass({ + + propTypes:{ + pydio:React.PropTypes.instanceOf(Pydio), + workspaces:React.PropTypes.instanceOf(Map), + onHoverLink:React.PropTypes.func, + onOutLink:React.PropTypes.func + }, + + createRepositoryEnabled:function(){ + var reg = this.props.pydio.Registry.getXML(); + return XMLUtils.XPathSelectSingleNode(reg, 'actions/action[@name="user_create_repository"]') !== null; + }, + + render: function(){ + var entries = [], sharedEntries = [], inboxEntry; + this.props.workspaces.forEach(function(object, key){ + if(object.getId().indexOf('ajxp_') === 0){ + return; + } + if(object.hasContentFilter()){ + return; + } + var entry = ( + + ); + if(object.getAccessType() == "inbox"){ + inboxEntry = entry; + }else if(object.getOwner()){ + sharedEntries.push(entry); + }else{ + entries.push(entry); + } + }.bind(this)); + if(inboxEntry){ + sharedEntries.unshift(inboxEntry); + } + + var messages = this.props.pydio.MessageHash; + + if(this.createRepositoryEnabled()){ + var createClick = function(){ + this.props.pydio.Controller.fireAction('user_create_repository'); + }.bind(this); + var createAction = ( +
+
+ + + {messages[417]} +
+
+ ); + } + + return ( +
+
{messages[468]}
+
+ {entries} +
+
{messages[469]}
+
+ {sharedEntries} +
+
+ {createAction} +
+ ); + + } + + }); + var WorkspaceEntry = React.createClass({ mixins:[ReactPydio.MessagesConsumerMixin], propTypes:{ pydio:React.PropTypes.instanceOf(Pydio).isRequired, - workspace:React.PropTypes.instanceOf(Repository).isRequired + workspace:React.PropTypes.instanceOf(Repository).isRequired, + onHoverLink:React.PropTypes.func, + onOutLink:React.PropTypes.func }, getLetterBadge:function(){ return {__html:this.props.workspace.getHtmlBadge(true)}; @@ -227,10 +265,25 @@ if(current == this.props.workspace.getId()){ currentClass +=" workspace-current"; } + if(this.props.onHoverLink){ + var onHover = function(event){ + this.props.onHoverLink(event, this.props.workspace) + }.bind(this); + } + if(this.props.onOutLink){ + var onOut = function(event){this.props.onOutLink(event, this.props.ws)}.bind(this); + } return ( -
+
{this.props.workspace.getLabel()} + {this.props.workspace.getDescription()}
); } @@ -243,6 +296,7 @@ }else{ ns.Panel = LeftPanel; } + ns.UserWorkspacesList = UserWorkspacesList; global.LeftNavigation=ns; })(window); \ No newline at end of file diff --git a/core/src/plugins/gui.ajax/res/themes/orbit/css/components/leftpanel.less b/core/src/plugins/gui.ajax/res/themes/orbit/css/components/leftpanel.less index 582b521ffc..37518c732e 100644 --- a/core/src/plugins/gui.ajax/res/themes/orbit/css/components/leftpanel.less +++ b/core/src/plugins/gui.ajax/res/themes/orbit/css/components/leftpanel.less @@ -85,6 +85,9 @@ .workspace-label{ .nav-list-entry-label(); } + .workspace-description{ + display: none; + } &.workspace-current{ opacity: 0.4; } diff --git a/core/src/plugins/gui.ajax/res/themes/orbit/css/pydio.css b/core/src/plugins/gui.ajax/res/themes/orbit/css/pydio.css index f1b1585da7..91902cb6f8 100644 --- a/core/src/plugins/gui.ajax/res/themes/orbit/css/pydio.css +++ b/core/src/plugins/gui.ajax/res/themes/orbit/css/pydio.css @@ -4129,6 +4129,9 @@ div.menu.rootDirChooser span.rootDirTitle { overflow: hidden; text-overflow: ellipsis; } +.left-panel .workspaces .workspace-entry .workspace-description { + display: none; +} .left-panel .workspaces .workspace-entry.workspace-current { opacity: 0.4; }