Skip to content

Commit

Permalink
hasCreateFileRole
Browse files Browse the repository at this point in the history
  • Loading branch information
macor161 committed Mar 8, 2019
1 parent f23969d commit f629497
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/frontend/src/components/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ inject("mainStore", "configStore")(
<span style={{ cursor: 'pointer' }} onClick={() => mainStore.isGroupsSectionOpen = true}><GroupsSectionBtn /></span>
<span style={{ cursor: 'pointer' }} onClick={() => mainStore.isDeletedFilesScreenOpen = true}><TrashSectionBtn /> </span>
<span style={{ cursor: 'pointer' }} onClick={() => configStore.isConfigSectionOpen = true}><ConfigurationSectionBtn /></span>
{ mainStore.selectedFolder && mainStore.selectedFolder.permissions && mainStore.selectedFolder.permissions.write && <MainDropDown mainStore={mainStore} />}
{ mainStore.isNewButtonVisible && <MainDropDown mainStore={mainStore} />}
</div>
}
/>
Expand Down
9 changes: 9 additions & 0 deletions app/frontend/src/stores/main-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export class MainStore {

@observable hasDeleteRole = false

@observable hasCreateFileRole = false

@observable isLabelScreenOpen = false

@observable isDeletedFilesScreenOpen = false
Expand Down Expand Up @@ -79,6 +81,11 @@ export class MainStore {
return this.files.toJS().filter(file => file && !file.isDeleted)
}
@computed get isNewButtonVisible() {
return this.hasCreateFileRole ||
(this.selectedFolder && this.selectedFolder.permissions && this.selectedFolder.permissions.write)
}
selectedFilePermissions = asyncComputed([], 100, async () =>
this.selectedFile ?
this._datastore.getFilePermissions(this.selectedFile.id)
Expand Down Expand Up @@ -289,6 +296,7 @@ export class MainStore {
this._refreshFiles()
this._refreshAvailableGroups()
this.hasDeleteRole = await this._datastore.hasDeleteRole()
this.hasCreateFileRole = await this._datastore.hasCreateFileRole()
res()
})
}
Expand All @@ -304,6 +312,7 @@ export class MainStore {
this.filesLoading = true

this.selectedFolder = await this._datastore.getFolder(this.selectedFolderId)

this.files = await Promise.all(
this.selectedFolder.files
.sort(folderFirst)
Expand Down
13 changes: 10 additions & 3 deletions contracts/DriveApp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,16 @@ contract Datastore is AragonApp {
}

/**
* @notice Returns whether an entity has the DELETE_FILE_ROLE
* @param _entity File id
* @dev Returns whether an entity has the CREATE_FILE_ROLE
* @param _entity Entity address
*/
function hasCreateFileRole(address _entity) external view returns (bool) {
return acl.hasPermission(_entity, this, CREATE_FILE_ROLE);
}

/**
* @dev Returns whether an entity has the DELETE_FILE_ROLE
* @param _entity Entity address
*/
function hasDeleteRole(address _entity)
external
Expand Down Expand Up @@ -497,7 +505,6 @@ contract Datastore is AragonApp {
}
}


contract DriveApp is HasComments, Datastore {

function initialize(ObjectACL _objectACL, AragonComments _comments) external {
Expand Down

0 comments on commit f629497

Please sign in to comment.