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
Show file tree
Hide file tree
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/drive/styles/toolbar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
.fil-toolbar-trash
margin-left auto
display flex

.menu-recipients-wrapper
position relative

.menu-recipients
position absolute
right 0
top -.5rem

.fil-toolbar-menu
//!TODO Remove this code after upgrading to cozy-bar@6
Expand Down
4 changes: 2 additions & 2 deletions src/drive/web/modules/drive/Toolbar/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import styles from 'drive/styles/toolbar.styl'

import NotRootFolder from 'drive/web/modules/drive/Toolbar/components/NotRootFolder'

import UploadItem from './components/UploadItem'
import UploadButtonItem from './components/UploadButtonItem'
import MoreMenu from './components/MoreMenu'

import ShareButton from './share/ShareButton'
Expand Down Expand Up @@ -50,7 +50,7 @@ class Toolbar extends Component {
>
{!isShared &&
canUpload &&
hasWriteAccess && <UploadItem disabled={isDisabled} />}
hasWriteAccess && <UploadButtonItem disabled={isDisabled} />}
<NotRootFolder>
<SharedRecipients />
</NotRootFolder>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import React from 'react'
import { connect } from 'react-redux'
import { translate } from 'cozy-ui/transpiled/react/I18n'
import styles from 'drive/styles/toolbar.styl'
import { showNewFolderInput } from 'drive/web/modules/filelist/duck'
import { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu'
import Icon from 'cozy-ui/transpiled/react/Icon'

const AddFolderItem = translate()(({ t, addFolder }) => {
return (
<a
<ActionMenuItem
data-test-id="add-folder-link"
className={styles['fil-action-newfolder']}
onClick={addFolder}
left={<Icon icon="folder-add" />}
>
{t('toolbar.menu_new_folder')}
</a>
</ActionMenuItem>
)
})
const mapDispatchToProps = dispatch => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import {
useCapabilities
} from 'cozy-client'
import { generateUniversalLink } from 'cozy-ui/transpiled/react/AppLinker/native'
import { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu'
import Icon from 'cozy-ui/transpiled/react/Icon'

import toolbarContainer from 'drive/web/modules/drive/Toolbar/toolbar'
import styles from 'drive/styles/toolbar.styl'

const CreateNoteItem = ({ client, t, displayedFolder }) => {
const { fetchStatus, url, isInstalled } = useAppLinkWithStoreFallback(
Expand All @@ -34,9 +35,9 @@ const CreateNoteItem = ({ client, t, displayedFolder }) => {
}

return (
<a
<ActionMenuItem
data-test-id="create-a-note"
className={styles['fil-action-create-note']}
left={<Icon icon="note" />}
onClick={async () => {
if (!fetchStatus) return
if (isInstalled) {
Expand All @@ -55,7 +56,7 @@ const CreateNoteItem = ({ client, t, displayedFolder }) => {
}}
>
{t('toolbar.menu_create_note')}
</a>
</ActionMenuItem>
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import React, { useState, useCallback } from 'react'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import styles from 'drive/styles/toolbar.styl'
import { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu'
import Icon from 'cozy-ui/transpiled/react/Icon'
import ShortcutCreationModal from './ShortcutCreationModalConnected'

const CreateShortcutWrapper = () => {
const [isModalDisplayed, setIsModalDisplayed] = useState(false)
const { t } = useI18n()
if (!isModalDisplayed) {
return (
<a
<ActionMenuItem
data-test-id="create-a-shortcut"
className={styles['fil-action-create-shortcut']}
left={<Icon icon="link" />}
onClick={useCallback(() => {
setIsModalDisplayed(true)
})}
>
{t('toolbar.menu_create_shortcut')}
</a>
</ActionMenuItem>
)
} else {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import React from 'react'
import { connect } from 'react-redux'

import styles from 'drive/styles/toolbar.styl'
import { translate } from 'cozy-ui/transpiled/react'
import { translate } from 'cozy-ui/transpiled/react/I18n'
import { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu'
import Icon from 'cozy-ui/transpiled/react/Icon'
import { downloadFiles } from 'drive/web/modules/navigation/duck'

import toolbarContainer from '../toolbar'
const DownloadButtonItem = translate()(
({ t, displayedFolder, downloadAll }) => {
return (
<a
className={styles['fil-action-download']}
<ActionMenuItem
left={<Icon icon="download" />}
onClick={() => downloadAll([displayedFolder])}
>
{t('toolbar.menu_download_folder')}
</a>
</ActionMenuItem>
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState, useCallback } from 'react'

import { MoreButton } from 'components/Button'
import { isMobileApp } from 'cozy-device-helper'
import { translate } from 'cozy-ui/transpiled/react/I18n'
import ActionMenu from 'cozy-ui/transpiled/react/ActionMenu'
import withBreakpoints from 'cozy-ui/transpiled/react/helpers/withBreakpoints'

Expand Down Expand Up @@ -73,4 +74,4 @@ const MoreMenu = ({
)
}

export default withBreakpoints()(MoreMenu)
export default translate()(withBreakpoints()(MoreMenu))
y-lohse marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 8 additions & 7 deletions src/drive/web/modules/drive/Toolbar/components/ScanWrapper.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { Component } from 'react'
import { Icon, translate } from 'cozy-ui/transpiled/react'
import { translate } from 'cozy-ui/transpiled/react/I18n'
import { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu'
import Icon from 'cozy-ui/transpiled/react/Icon'

import { Scanner, SCANNER_DONE, SCANNER_UPLOADING } from 'cozy-scanner'
import toolbarContainer from '../toolbar'
Expand Down Expand Up @@ -35,18 +37,17 @@ const ScanMenuItem = translate()(({ status, onClick, t, online }) => {
tracker.push(['trackEvent', 'Drive', 'Scanner', 'Scan Click'])
}
}
//!TODO Color should be removed after the fix of https://github.com/cozy/cozy-ui/issues/1170

return (
<span
className="u-pl-1 u-flex u-pt-half u-pb-half u-charcoalGrey"
<ActionMenuItem
left={<Icon icon="camera" />}
onClick={() => {
trackEvent()
return actionOnClick()
}}
>
<Icon icon="camera" />
<span className="u-pl-half u">{t('Scan.scan_a_doc')}</span>
</span>
{t('Scan.scan_a_doc')}
</ActionMenuItem>
)
})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import classNames from 'classnames'
import UploadButton from 'drive/web/modules/upload/UploadButton'
import { translate } from 'cozy-ui/transpiled/react'
import styles from 'drive/styles/toolbar.styl'
import { compose } from 'redux'

import toolbarContainer from '../toolbar'

const UploadButtonItem = ({ t, displayedFolder, isDisabled }) => (
<UploadButton
disabled={isDisabled}
displayedFolder={displayedFolder}
label={t('toolbar.item_upload')}
className={classNames(styles['c-btn'], 'u-hide--mob')}
/>
)

export default compose(
toolbarContainer,
translate()
y-lohse marked this conversation as resolved.
Show resolved Hide resolved
)(UploadButtonItem)
55 changes: 35 additions & 20 deletions src/drive/web/modules/drive/Toolbar/components/UploadItem.jsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
import React from 'react'
import classNames from 'classnames'
import UploadButton from 'drive/web/modules/upload/UploadButton'
Crash-- marked this conversation as resolved.
Show resolved Hide resolved
import { connect } from 'react-redux'
import { compose } from 'redux'
import { translate } from 'cozy-ui/transpiled/react'
import styles from 'drive/styles/toolbar.styl'
import { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu'
import Icon from 'cozy-ui/transpiled/react/Icon'
import FileInput from 'cozy-ui/transpiled/react/FileInput'
import withSharingState from 'cozy-sharing/dist/hoc/withSharingState'

import { uploadFiles } from 'drive/web/modules/navigation/duck'
import toolbarContainer from '../toolbar'

const UploadItem = translate()(
({ t, displayedFolder, insideMoreMenu, isDisabled }) =>
insideMoreMenu ? (
<UploadButton
displayedFolder={displayedFolder}
label={t('toolbar.menu_upload')}
className={styles['fil-action-upload']}
/>
) : (
<UploadButton
disabled={isDisabled}
displayedFolder={displayedFolder}
label={t('toolbar.item_upload')}
className={classNames(styles['c-btn'], 'u-hide--mob')}
/>
)
const UploadItem = ({ t, isDisabled, onUpload }) => (
<FileInput
label={t('toolbar.menu_upload')}
disabled={isDisabled}
multiple
onChange={onUpload}
data-test-id="upload-btn"
value={[]}
>
<ActionMenuItem left={<Icon icon="upload" />}>
{t('toolbar.menu_upload')}
</ActionMenuItem>
</FileInput>
)

export default toolbarContainer(UploadItem)
const mapDispatchToProps = (dispatch, { displayedFolder, sharingState }) => ({
onUpload: files => {
dispatch(uploadFiles(files, displayedFolder.id, sharingState))
}
})

export default compose(
withSharingState,
toolbarContainer,
translate(),
connect(
null,
mapDispatchToProps
)
)(UploadItem)
21 changes: 11 additions & 10 deletions src/drive/web/modules/drive/Toolbar/delete/DeleteItem.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
import React from 'react'
import classNames from 'classnames'
import styles from 'drive/styles/toolbar.styl'
import { translate } from 'cozy-ui/transpiled/react/I18n'
import { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu'
import Icon from 'cozy-ui/transpiled/react/Icon'
import deleteContainer from './delete'

const DeleteItem = translate()(
({ t, isSharedWithMe, displayedFolder, trashFolder, onLeave }) =>
isSharedWithMe ? (
<a
<ActionMenuItem
Crash-- marked this conversation as resolved.
Show resolved Hide resolved
data-test-id="fil-action-delete"
className={classNames(styles['fil-action-delete'])}
left={<Icon icon="trash" color="var(--pomegranate)" />}
onClick={() =>
onLeave(displayedFolder).then(() => trashFolder(displayedFolder))
}
>
{t('toolbar.leave')}
</a>
<span className="u-pomegranate">{t('toolbar.leave')}</span>
</ActionMenuItem>
) : (
<a
<ActionMenuItem
data-test-id="fil-action-delete"
className={classNames(styles['fil-action-delete'])}
left={<Icon icon="trash" color="var(--pomegranate)" />}
onClick={() => trashFolder(displayedFolder)}
>
{t('toolbar.trash')}
</a>
<span className="u-pomegranate">{t('toolbar.trash')}</span>
</ActionMenuItem>
)
)

Expand Down
26 changes: 16 additions & 10 deletions src/drive/web/modules/drive/Toolbar/share/ShareItem.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react'
import { RecipientsAvatars } from 'cozy-sharing/dist/components/Recipient'
import { translate } from 'cozy-ui/transpiled/react'
import { translate } from 'cozy-ui/transpiled/react/I18n'
import { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu'
import Icon from 'cozy-ui/transpiled/react/Icon'
import styles from 'drive/styles/toolbar.styl'
import { SharedDocument } from 'cozy-sharing'
import shareContainer from './share'
Expand All @@ -9,22 +11,26 @@ const ShareItem = translate()(({ t, share, displayedFolder }) => {
return (
<SharedDocument docId={displayedFolder.id}>
{({ isSharedWithMe, recipients, link }) => (
<a
className={styles['fil-action-share']}
<ActionMenuItem
onClick={() => share(displayedFolder)}
left={<Icon icon="share" />}
right={
<div className={styles['menu-recipients-wrapper']}>
<RecipientsAvatars
className={styles['menu-recipients']}
recipients={recipients}
link={link}
size="small"
/>
</div>
}
>
{t(
isSharedWithMe
? 'Files.share.sharedWithMe'
: 'toolbar.menu_share_folder'
)}
<RecipientsAvatars
className={styles['fil-toolbar-menu-recipients']}
recipients={recipients}
link={link}
size="small"
/>
</a>
</ActionMenuItem>
)}
</SharedDocument>
)
Expand Down
Loading