Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read-write actions on public view #2017

Merged
merged 30 commits into from May 19, 2020
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8f6eced
refactor: Moved Toolbar file
y-lohse Apr 21, 2020
8c56a17
refactor: Separate MoreMenu from Toolbar
y-lohse Apr 21, 2020
94be56a
refactor: Switch MoreMenu to ActionMenu
y-lohse Apr 27, 2020
c7dd42f
refactor: Migrate Trash MoreMenu
y-lohse Apr 27, 2020
1944efd
refactor: Removed old menu code
y-lohse Apr 28, 2020
4aadd0e
refactor: Shortcut menu item doesn't display the modal itself
y-lohse Apr 30, 2020
c172464
refactor: Make SelectableItem a real action menu item
y-lohse Apr 30, 2020
1d7da32
fix: ActionMenus close automatically
y-lohse May 7, 2020
4a222a3
fix: Enable rendering modals on public view
y-lohse May 7, 2020
a5cb33d
feat: Render file history on public view
y-lohse May 7, 2020
0e0a42d
refactor: Pass write permission to toolbar
y-lohse May 7, 2020
b40da3e
feat: New actions for files on public view
y-lohse May 7, 2020
896e7d1
feat: New toolbar for public view
y-lohse May 7, 2020
71ef983
fix: Avoid duplicate menu item in trash
y-lohse May 11, 2020
7a0ab75
fix: Fallback link to notes if no permissions
y-lohse May 11, 2020
5858716
refactor: Removed unused style
y-lohse May 11, 2020
347b53c
fix: Check write conditions on public actions
y-lohse May 12, 2020
82bf301
fix: Case sensitive file name
y-lohse May 12, 2020
9a98cd3
chore: Set test env variable
y-lohse May 12, 2020
49fb54c
chore: Use recent versions of node and yarn on android
y-lohse May 12, 2020
03b821a
feat: Upgrade cozy-sharings
y-lohse May 12, 2020
705bfd2
refactor: Make SharingProvider available to all public views
y-lohse May 12, 2020
8d12fec
fix: Add reloadView proptype
y-lohse May 15, 2020
fffb585
refactor: Removed useless translate HOC
y-lohse May 15, 2020
a605f32
docs: Added comment about realtime
y-lohse May 15, 2020
dfeb56e
refactor: Renamed props
y-lohse May 15, 2020
d6ed0df
feat: Reload public view after upload
y-lohse May 12, 2020
291d6f8
refactor: Only query notes app url if we have permissions
y-lohse May 12, 2020
6169bb6
refactor: Use permissions model fetchOwn
y-lohse May 12, 2020
06392ba
docs: Added missing doc string
y-lohse May 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/drive/web/modules/public/LightFolderView.jsx
@@ -1,6 +1,7 @@
import React from 'react'
import { connect } from 'react-redux'
import { withRouter } from 'react-router'
import get from 'lodash/get'

import { Content, Overlay } from 'cozy-ui/transpiled/react'
import Alerter from 'cozy-ui/transpiled/react/Alerter'
Expand Down Expand Up @@ -31,7 +32,8 @@ class DumbFolderView extends React.Component {
state = {
revoked: false,
viewerOpened: false,
currentViewedIndex: null
currentViewedIndex: null,
hasWriteAccess: false
}
handleFileOpen = async file => {
const isNote = models.file.isNote(file)
Expand Down Expand Up @@ -73,6 +75,7 @@ class DumbFolderView extends React.Component {
}))

componentWillMount() {
this.loadPermissions()
this.props
.fetchFolder(getFolderIdFromRoute(this.props.location, this.props.params))
.then(e => {
Expand All @@ -82,6 +85,15 @@ class DumbFolderView extends React.Component {
})
}

loadPermissions = async () => {
const { client } = this.props
const response = await client
.collection('io.cozy.permissions')
.getOwnPermissions()
const permission = get(response, 'data.attributes.permissions.files', {})
y-lohse marked this conversation as resolved.
Show resolved Hide resolved
this.setState({ hasWriteAccess: !models.permission.isReadOnly(permission) })
}

navigateToFolder = async folderId => {
await this.props.fetchFolder(folderId)
this.props.router.push(getFolderUrl(folderId, this.props.location))
Expand All @@ -91,14 +103,18 @@ class DumbFolderView extends React.Component {
if (this.state.revoked) {
return <ErrorShare errorType={`public_unshared`} />
}
const { viewerOpened, currentViewedIndex } = this.state
const { viewerOpened, currentViewedIndex, hasWriteAccess } = this.state
const { children, ...fileListProps } = this.props

return (
<Main isPublic>
<Topbar>
<Breadcrumb isPublic onFolderOpen={this.props.fetchFolder} />
<PublicToolbar files={[this.props.displayedFolder]} isFile={false} />
<PublicToolbar
files={[this.props.displayedFolder]}
isFile={false}
hasWriteAccess={hasWriteAccess}
/>
</Topbar>
<Content>
<FileList
Expand Down