Skip to content

Commit

Permalink
refactor: Use permissions model fetchOwn
Browse files Browse the repository at this point in the history
  • Loading branch information
y-lohse committed May 19, 2020
1 parent 689590e commit 92b3c26
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"cozy-authentication": "^2.0.5",
"cozy-bar": "7.12.2",
"cozy-ci": "0.4.1",
"cozy-client": "13.5.2",
"cozy-client": "13.8.0",
"cozy-client-js": "0.16.4",
"cozy-device-helper": "1.9.2",
"cozy-doctypes": "1.72.2",
Expand Down
11 changes: 5 additions & 6 deletions src/drive/web/modules/public/LightFolderView.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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 @@ -91,11 +90,11 @@ 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', {})
this.setState({ hasWriteAccess: !models.permission.isReadOnly(permission) })

const permissions = await models.permission.fetchOwn(client)
this.setState({
hasWriteAccess: !models.permission.isReadOnly(permissions[0])
})
}

navigateToFolder = async folderId => {
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5124,15 +5124,15 @@ cozy-client@13.1.0:
sift "^6.0.0"
url-search-params-polyfill "^7.0.0"

cozy-client@13.5.2:
version "13.5.2"
resolved "https://registry.yarnpkg.com/cozy-client/-/cozy-client-13.5.2.tgz#f0fa82c744f355d4fd9877347e4aeaed307de181"
integrity sha512-+L8eZlPTasXc1DOSUBZeWPpj8xhOu0HSb9LLtQjpnqClYZSqo0tP9Via0todyi+ZeDPt8e/lhbfQN8ltIE4abA==
cozy-client@13.8.0:
version "13.8.0"
resolved "https://registry.yarnpkg.com/cozy-client/-/cozy-client-13.8.0.tgz#86ad43db12dad1f1f775630ce01182e02257cc44"
integrity sha512-HACyr9StsGQxoFvRQZGph1+1uZbyhn1fkTJByCdJUuGFs0tt/japXTpTRJyJqdYEu6wyJhQswzFA54KAmWnaew==
dependencies:
btoa "^1.2.1"
cozy-device-helper "^1.7.3"
cozy-logger "^1.6.0"
cozy-stack-client "^13.5.2"
cozy-stack-client "^13.5.3"
isomorphic-fetch "^2.2.1"
lodash "^4.17.13"
microee "^0.0.6"
Expand Down Expand Up @@ -5360,7 +5360,7 @@ cozy-stack-client@13.5.2:
mime "^2.4.0"
qs "^6.7.0"

cozy-stack-client@^13.1.0, cozy-stack-client@^13.5.2, cozy-stack-client@^13.5.3:
cozy-stack-client@^13.1.0, cozy-stack-client@^13.5.3:
version "13.5.3"
resolved "https://registry.yarnpkg.com/cozy-stack-client/-/cozy-stack-client-13.5.3.tgz#d8f2489becd6c8da5b558ec07c1c7bdfced35971"
integrity sha512-VpnDGeSjlmaoKOtM/b0tEbJgceQXdd9fyHn5/GkXUWfdhFazjNw8Tw4SOlF8cJC4keEhVw0oAdIgh4BhlJQ/Rg==
Expand Down

0 comments on commit 92b3c26

Please sign in to comment.