1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 01:25:17 +01:00

Merge pull request #3 from ascribe/AD-1229-aclinformation-button-on-no-available-buttons-fails

Login validation for ACL actions in edition and piece detail
This commit is contained in:
Tim Daubenschütz 2015-10-27 10:53:49 +01:00
commit 4dbed67a63
3 changed files with 43 additions and 35 deletions

View File

@ -8,6 +8,8 @@
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) 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 - Refactor string-templating for api_urls
- Use classNames plugin instead of if-conditional-classes - 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 DONE
- Refactor forms to generic-declarative form component ✓ - Refactor forms to generic-declarative form component ✓

View File

@ -25,11 +25,11 @@ import LicenseDetail from './license_detail';
import FurtherDetails from './further_details'; import FurtherDetails from './further_details';
import EditionActionPanel from './edition_action_panel'; import EditionActionPanel from './edition_action_panel';
import AclProxy from '../acl_proxy';
import Note from './note'; import Note from './note';
import ApiUrls from '../../constants/api_urls'; import ApiUrls from '../../constants/api_urls';
import AppConstants from '../../constants/application_constants';
import AscribeSpinner from '../ascribe_spinner'; import AscribeSpinner from '../ascribe_spinner';
import { getLangText } from '../../utils/lang_utils'; import { getLangText } from '../../utils/lang_utils';
@ -211,6 +211,7 @@ let EditionSummary = React.createClass({
value={ edition.owner } /> value={ edition.owner } />
<LicenseDetail license={edition.license_type}/> <LicenseDetail license={edition.license_type}/>
{this.getStatus()} {this.getStatus()}
<AclProxy show={currentUser && currentUser.email}>
<EditionDetailProperty <EditionDetailProperty
label={getLangText('ACTIONS')}> label={getLangText('ACTIONS')}>
<EditionActionPanel <EditionActionPanel
@ -218,6 +219,7 @@ let EditionSummary = React.createClass({
currentUser={currentUser} currentUser={currentUser}
handleSuccess={this.handleSuccess} /> handleSuccess={this.handleSuccess} />
</EditionDetailProperty> </EditionDetailProperty>
</AclProxy>
<hr/> <hr/>
</div> </div>
); );

View File

@ -28,6 +28,7 @@ import CreateEditionsButton from '../ascribe_buttons/create_editions_button';
import DeleteButton from '../ascribe_buttons/delete_button'; import DeleteButton from '../ascribe_buttons/delete_button';
import AclInformation from '../ascribe_buttons/acl_information'; import AclInformation from '../ascribe_buttons/acl_information';
import AclProxy from '../acl_proxy';
import ListRequestActions from '../ascribe_forms/list_form_request_actions'; import ListRequestActions from '../ascribe_forms/list_form_request_actions';
@ -181,38 +182,41 @@ let PieceContainer = React.createClass({
}, },
getActions() { getActions() {
if (this.state.piece && const { piece, currentUser } = this.state;
this.state.piece.notifications &&
this.state.piece.notifications.length > 0) { if (piece && piece.notifications && piece.notifications.length > 0) {
return ( return (
<ListRequestActions <ListRequestActions
pieceOrEditions={this.state.piece} pieceOrEditions={piece}
currentUser={this.state.currentUser} currentUser={currentUser}
handleSuccess={this.loadPiece} handleSuccess={this.loadPiece}
notifications={this.state.piece.notifications}/>); notifications={piece.notifications}/>);
} else { } else {
return ( return (
<AclProxy
show={currentUser && currentUser.email}>
<DetailProperty label={getLangText('ACTIONS')}> <DetailProperty label={getLangText('ACTIONS')}>
<AclButtonList <AclButtonList
className="ascribe-button-list" className="ascribe-button-list"
availableAcls={this.state.piece.acl} availableAcls={piece.acl}
editions={this.state.piece} editions={piece}
handleSuccess={this.loadPiece}> handleSuccess={this.loadPiece}>
<CreateEditionsButton <CreateEditionsButton
label={getLangText('CREATE EDITIONS')} label={getLangText('CREATE EDITIONS')}
className="btn-sm" className="btn-sm"
piece={this.state.piece} piece={piece}
toggleCreateEditionsDialog={this.toggleCreateEditionsDialog} toggleCreateEditionsDialog={this.toggleCreateEditionsDialog}
onPollingSuccess={this.handlePollingSuccess}/> onPollingSuccess={this.handlePollingSuccess}/>
<DeleteButton <DeleteButton
handleSuccess={this.handleDeleteSuccess} handleSuccess={this.handleDeleteSuccess}
piece={this.state.piece}/> piece={piece}/>
<AclInformation <AclInformation
aim="button" aim="button"
verbs={['acl_share', 'acl_create_editions', 'acl_loan', 'acl_delete', 'acl_consign']} verbs={['acl_share', 'acl_create_editions', 'acl_loan', 'acl_delete', 'acl_consign']}
aclObject={this.state.piece.acl}/> aclObject={piece.acl}/>
</AclButtonList> </AclButtonList>
</DetailProperty> </DetailProperty>
</AclProxy>
); );
} }
}, },