From d48da96e3b5430e28e097f751f901da9d5b089a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Mon, 26 Oct 2015 11:21:22 +0100 Subject: [PATCH 1/3] Add login-validation to actions DetailProperty in Edition and Piece detail view --- js/components/ascribe_detail/edition.js | 18 +++--- .../ascribe_detail/piece_container.js | 58 ++++++++++--------- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index ccab60a0..b7c0205f 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -25,11 +25,11 @@ import LicenseDetail from './license_detail'; import FurtherDetails from './further_details'; import EditionActionPanel from './edition_action_panel'; +import AclProxy from '../acl_proxy'; import Note from './note'; import ApiUrls from '../../constants/api_urls'; -import AppConstants from '../../constants/application_constants'; import AscribeSpinner from '../ascribe_spinner'; import { getLangText } from '../../utils/lang_utils'; @@ -211,13 +211,15 @@ let EditionSummary = React.createClass({ value={ edition.owner } /> {this.getStatus()} - - - + + + + +
); diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js index f8a2369f..01edede1 100644 --- a/js/components/ascribe_detail/piece_container.js +++ b/js/components/ascribe_detail/piece_container.js @@ -28,6 +28,7 @@ import CreateEditionsButton from '../ascribe_buttons/create_editions_button'; import DeleteButton from '../ascribe_buttons/delete_button'; import AclInformation from '../ascribe_buttons/acl_information'; +import AclProxy from '../acl_proxy'; import ListRequestActions from '../ascribe_forms/list_form_request_actions'; @@ -181,38 +182,41 @@ let PieceContainer = React.createClass({ }, getActions() { - if (this.state.piece && - this.state.piece.notifications && - this.state.piece.notifications.length > 0) { + const { piece, currentUser } = this.state; + + if (piece && piece.notifications && piece.notifications.length > 0) { return ( ); + notifications={piece.notifications}/>); } else { return ( - - - - - - - + + + + + + + + + ); } }, From da895bb434c8688330b2e0ffbd05b83fb4fd41ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Mon, 26 Oct 2015 15:13:02 +0100 Subject: [PATCH 2/3] Add alberto's suggestion on currentUser's login status to refactor.md --- docs/refactor-todo.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/refactor-todo.md b/docs/refactor-todo.md index f7a5917b..91c0fa21 100644 --- a/docs/refactor-todo.md +++ b/docs/refactor-todo.md @@ -8,6 +8,7 @@ queryParams of the piece_list_store should all be reflected in the url and not a single component each should manipulate the URL bar (refactor pagination, use actions and state) - Refactor string-templating for api_urls - Use classNames plugin instead of if-conditional-classes +- Instead of using `currentUser && currentUser.email` in an validation that checks whether we user is logged in or now, in the `UserStore` on login we set a boolean property called `isLoggedIn` that can then be used instead of `email` # Refactor DONE - Refactor forms to generic-declarative form component ✓ From 29e422d16ad9ea65e13b612c9fd1bbd2ea9b2eb2 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Mon, 26 Oct 2015 16:53:48 +0100 Subject: [PATCH 3/3] Add suggestion to refactor AclProxy to readme --- docs/refactor-todo.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/refactor-todo.md b/docs/refactor-todo.md index 91c0fa21..c0329bc2 100644 --- a/docs/refactor-todo.md +++ b/docs/refactor-todo.md @@ -9,6 +9,7 @@ queryParams of the piece_list_store should all be reflected in the url and not a - Refactor string-templating for api_urls - Use classNames plugin instead of if-conditional-classes - Instead of using `currentUser && currentUser.email` in an validation that checks whether we user is logged in or now, in the `UserStore` on login we set a boolean property called `isLoggedIn` that can then be used instead of `email` +- Refactor AclProxy to be a generic hide/show element component. Have it take data input and a validation function to assess whether it should show or hide child elements. Move current Acl checks to another place, eg. acl_utils.js. # Refactor DONE - Refactor forms to generic-declarative form component ✓