"use strict"; function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } (function () { scrivito.Sidebar.WorkspacesPanel = scrivito.createReactClass({ propTypes: { isActive: React.PropTypes.bool.isRequired }, render: function render() { if (!this.props.isActive) { return null; } return React.createElement( ReactCustomScrollbars.Scrollbars, { className: "scrivito_second_level_content scrivito_workspaces_panel scrivito_dark" }, React.createElement(CurrentWorkspaceGroup, null), React.createElement(OtherWorkspacesGroup, null) ); } }); var GeneralWorkspacesGroup = scrivito.createReactClass({ render: function render() { return React.createElement( "div", { className: "scrivito_general_workspaces_group" }, React.createElement( "div", { className: "scrivito_sidebar_separator" }, React.createElement( "span", null, scrivito.t('sidebar.workspaces_panel.general_workspaces_group.title') ) ), React.createElement( "ul", { className: "scrivito_sidebar_action" }, React.createElement(CreateWorkspaceButton, null), React.createElement(PublishHistoryButton, null) ) ); } }); var CurrentWorkspaceGroup = scrivito.createReactClass({ render: function render() { var currentWorkspace = scrivito.Workspace.selected; var currentWorkspaceButtons = undefined; if (currentWorkspace.isEditable()) { currentWorkspaceButtons = React.createElement( "ul", { className: "scrivito_sidebar_action" }, React.createElement(TasksButton, { workspace: currentWorkspace }), React.createElement(ChangesButton, { workspace: currentWorkspace }) ); } return React.createElement( "div", { className: "scrivito_current_workspace_group" }, React.createElement( "div", { className: "scrivito_sidebar_separator" }, React.createElement( "span", null, scrivito.t('sidebar.workspaces_panel.current_workspace_group.title') ) ), React.createElement(scrivito.Sidebar.WorkspaceList, { workspaces: [currentWorkspace], isActive: true }), currentWorkspaceButtons ); } }); var OtherWorkspacesGroup = scrivito.createReactClass({ render: function render() { return React.createElement( "div", { className: "scrivito_other_workspaces_group" }, React.createElement( "div", { className: "scrivito_sidebar_separator" }, React.createElement( "span", null, scrivito.t('sidebar.workspaces_panel.other_workspaces_group.title') ) ), React.createElement(OtherWorkspacesList, null) ); } }); var OtherWorkspacesList = scrivito.createReactClass({ shouldRenderLoader: true, render: function render() { var currentWorkspace = scrivito.Workspace.selected; var otherWorkspaces = currentWorkspace.otherEditableWorkspaces; if (currentWorkspace.isEditable()) { otherWorkspaces = [scrivito.Workspace.published].concat(_toConsumableArray(otherWorkspaces)); } return React.createElement(scrivito.Sidebar.WorkspaceList, { workspaces: otherWorkspaces }); } }); var CreateWorkspaceButton = scrivito.createReactClass({ render: function render() { return React.createElement( "li", { className: this._buttonClassName(), title: this._buttonHint(), onClick: this._onClick }, React.createElement("i", { className: "scrivito_icon scrivito_icon_inv_plus scrivito_green" }), React.createElement( "span", null, scrivito.t('sidebar.workspaces_panel.create_workspace_button.title') ) ); }, _onClick: function _onClick(e) { if (this._isEnabled()) { scrivito.create_workspace_command().execute(); } e.stopPropagation(); }, _buttonClassName: function _buttonClassName() { var className = 'scrivito_create_workspace_button scrivito_sidebar_action_item'; if (!this._isEnabled()) { className += ' scrivito_disabled'; } return className; }, _buttonHint: function _buttonHint() { if (!this._isEnabled()) { return scrivito.t('sidebar.workspaces_panel.create_workspace_button.is_disabled'); } return scrivito.t('sidebar.workspaces_panel.create_workspace_button.hint'); }, _isEnabled: function _isEnabled() { return scrivito.User.current.can('create'); } }); var PublishHistoryButton = scrivito.createReactClass({ render: function render() { return React.createElement( "li", { className: "scrivito_publish_history_button scrivito_sidebar_action_item", title: scrivito.t('sidebar.workspaces_panel.publish_history_button.hint'), onClick: this._onClick }, React.createElement("i", { className: "scrivito_icon scrivito_icon_history" }), React.createElement( "span", null, scrivito.t('sidebar.workspaces_panel.publish_history_button.title') ) ); }, _onClick: function _onClick(e) { scrivito.PublishHistoryDialog.open(); e.stopPropagation(); } }); var ChangesButton = createWorkspaceButtonClass({ name: 'changes', icon: 'edited', verb: 'read', onClick: function onClick() { scrivito.openWorkspaceChanges(); } }); var PublishButton = createWorkspaceButtonClass({ name: 'publish', verb: 'publish', color: 'green', onClick: function onClick(workspace) { var publisher = new scrivito.WorkspacePublisher(workspace); scrivito.publishWorkspace(workspace, publisher); } }); /* PATCH BEGINS HERE */ var TasksButton = createWorkspaceButtonClass({ name: 'tasks', icon: 'clipboard', verb: 'read', onClick: function onClick() { scrivito.task_list_dialog.open(); } }); /* PATCH ENDS HERE */ var SettingsButton = createWorkspaceButtonClass({ name: 'settings', verb: 'invite_to', onClick: function onClick(workspace) { scrivito.openWorkspaceSettings(workspace); } }); var RebaseButton = createWorkspaceButtonClass({ name: 'rebase', icon: 'refresh', verb: 'write', isButtonDisabled: function isButtonDisabled(workspace) { return workspace.isAutoUpdate(); }, onClick: function onClick(workspace) { var legacyWorkspace = scrivito.legacy_workspace.fromWorkspace(workspace); scrivito.rebase_workspace_command(legacyWorkspace).execute(); } }); function createWorkspaceButtonClass(_ref) { var name = _ref.name; var icon = _ref.icon; var color = _ref.color; var verb = _ref.verb; var isButtonDisabled = _ref.isButtonDisabled; var onClick = _ref.onClick; return scrivito.createReactClass({ propTypes: { workspace: React.PropTypes.instanceOf(scrivito.Workspace).isRequired }, render: function render() { if (isButtonDisabled && isButtonDisabled(this.props.workspace)) { return null; } return React.createElement( "li", { className: this._buttonClassName(), title: this._title(), onClick: this._onClick }, React.createElement("i", { className: this._iconClassName() }), React.createElement( "span", null, scrivito.t("sidebar.workspaces_panel." + name + "_button.title") ) ); }, _buttonClassName: function _buttonClassName() { var className = "scrivito_sidebar_action_item scrivito_" + name + "_button"; if (!this._canAccessWorkspace()) { className += ' scrivito_disabled'; } return className; }, _iconClassName: function _iconClassName() { var className = "scrivito_icon scrivito_icon_" + (icon || name); if (color) { className += " scrivito_" + color; } return className; }, _title: function _title() { var localesPrefix = "sidebar.workspaces_panel." + name + "_button"; if (!this._canAccessWorkspace()) { return scrivito.t(localesPrefix + ".is_forbidden"); } return scrivito.t(localesPrefix + ".hint"); }, _canAccessWorkspace: function _canAccessWorkspace() { return scrivito.User.current.can(verb, this.props.workspace); }, _onClick: function _onClick(e) { if (this._canAccessWorkspace()) { onClick(this.props.workspace); } e.stopPropagation(); } }); } })(); /* PATCH BEGINS HERE PATCH ENDS HERE */ /* PATCH BEINGS HERE */ /* */ /* PATCH ENDS HERE */