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 8 commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"cozy-scripts": "1.13.2",
"cozy-sharing": "1.9.1",
"cozy-stack-client": "13.5.2",
"cozy-ui": "35.9.0",
"cozy-ui": "35.17.0",
"date-fns": "1.30.1",
"diacritics": "1.3.0",
"fastclick": "1.0.6",
Expand Down
3 changes: 0 additions & 3 deletions src/drive/assets/icons/icon-checkbox-16.svg

This file was deleted.

6 changes: 0 additions & 6 deletions src/drive/assets/icons/icon-share-dark.svg

This file was deleted.

6 changes: 0 additions & 6 deletions src/drive/assets/icons/icon-trash-red.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/drive/assets/icons/icons-16-icon-note.svg

This file was deleted.

71 changes: 8 additions & 63 deletions src/drive/styles/toolbar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -29,72 +29,17 @@
.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
button
svg
visibility: initial
display: initial
a
label
&.fil-action-upload
span[role=button]
display flex
padding-left 1rem
svg
margin-right .5rem

&.fil-action-newfolder
background embedurl('../assets/icons/icon-folder-add-16.svg') 1rem center no-repeat
&.fil-action-download
background embedurl("../assets/icons/icon-download-16.svg") 1rem center no-repeat
&.fil-action-select
background embedurl('../assets/icons/icon-checkbox-16.svg') 1rem center no-repeat
&.fil-action-delete
color var(--pomegranate)
background embedurl('../assets/icons/icon-trash-red.svg') 1rem center no-repeat
&.fil-action-share
position relative
background embedurl('../assets/icons/icon-share-dark.svg') 1rem center no-repeat
&.fil-action-create-note
background embedurl('../assets/icons/icons-16-icon-note.svg') 1rem center no-repeat
&.fil-action-create-shortcut
background embedurl('../assets/icons/icon-link.svg') 1rem center no-repeat
.fil-toolbar-menu-recipients
position absolute
right 1rem
top .1rem
.fil-action-share
display none
+medium-screen()
.fil-toolbar-menu
display block
left 1em
.fil-action-share
.fil-action-select
.fil-action-upload
display block
+tablet()
.fil-toolbar-menu-recipients
display none
+small-screen()
.fil-toolbar-inner-menu
position fixed
margin .5rem
width calc(100% - 1rem)
.fil-toolbar-files
.fil-toolbar-trash
position fixed
top 0
right 0
z-index $nav-index

.fil-public-download
display none
.fil-toolbar-menu
.fil-toolbar-menu-recipients
display inline-flex
+small-screen('min')
.fil-toolbar-menu--public
display none
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,17 @@ import withBreakpoints from 'cozy-ui/transpiled/react/helpers/withBreakpoints'

import BarContextProvider from 'cozy-ui/transpiled/react/BarContextProvider'
import { withClient } from 'cozy-client'
import { isMobileApp } from 'cozy-device-helper'

import { MoreButton } from 'components/Button'
import Menu, { Item } from 'components/Menu'

import { isSelectionBarVisible } from 'drive/web/modules/selection/duck'

import styles from 'drive/styles/toolbar.styl'

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

import DeleteItem from './Toolbar/delete/DeleteItem'
import SelectableItem from './Toolbar/selectable/SelectableItem'
import AddFolderItem from './Toolbar/components/AddFolderItem'
import UploadItem from './Toolbar/components/UploadItem'
import CreateNoteItem from './Toolbar/components/CreateNoteItem'
import CreateShortcut from './Toolbar/components/CreateShortcut'
import UploadButtonItem from './components/UploadButtonItem'
import MoreMenu from './components/MoreMenu'

import DownloadButtonItem from './Toolbar/components/DownloadButtonItem'
import ShareItem from './Toolbar/share/ShareItem'
import ShareButton from './Toolbar/share/ShareButton'
import SharedRecipients from './Toolbar/share/SharedRecipients'
import ScanWrapper from './Toolbar/components/ScanWrapper'
import ShareButton from './share/ShareButton'
import SharedRecipients from './share/SharedRecipients'

class Toolbar extends Component {
static contextTypes = {
Expand All @@ -54,72 +42,6 @@ class Toolbar extends Component {
const isDisabled = disabled || selectionModeActive
const { BarRight } = cozy.bar

const MoreMenu = (
<Menu
title={t('toolbar.item_more')}
disabled={isDisabled}
className={styles['fil-toolbar-menu']}
innerClassName={styles['fil-toolbar-inner-menu']}
button={<MoreButton />}
>
{canCreateFolder &&
hasWriteAccess && (
<Item>
<AddFolderItem />
</Item>
)}
{hasWriteAccess && (
<Item>
<CreateNoteItem />
</Item>
)}
{hasWriteAccess && (
<Item>
<CreateShortcut />
</Item>
)}
{canUpload &&
hasWriteAccess && (
<Item>
<UploadItem insideMoreMenu disabled={isDisabled} />
</Item>
)}
{isMobileApp() &&
canUpload &&
hasWriteAccess && (
<Item>
<ScanWrapper insideMoreMenu disabled={isDisabled} />
</Item>
)}
{hasWriteAccess && <hr />}
<NotRootFolder>
<Item>
<ShareItem />
</Item>
</NotRootFolder>
<NotRootFolder>
<Item>
<DownloadButtonItem />
</Item>
</NotRootFolder>
<Item>
<SelectableItem>
<a className={styles['fil-action-select']}>
{t('toolbar.menu_select')}
</a>
</SelectableItem>
</Item>
{hasWriteAccess && (
<NotRootFolder>
<hr />
<Item>
<DeleteItem />
</Item>
</NotRootFolder>
)}
</Menu>
)

return (
<div
data-test-id="fil-toolbar-files"
Expand All @@ -128,7 +50,7 @@ class Toolbar extends Component {
>
{!isShared &&
canUpload &&
hasWriteAccess && <UploadItem disabled={isDisabled} />}
hasWriteAccess && <UploadButtonItem disabled={isDisabled} />}
<NotRootFolder>
<SharedRecipients />
</NotRootFolder>
Expand All @@ -145,12 +67,22 @@ class Toolbar extends Component {
lang={lang}
>
<SharingProvider doctype="io.cozy.files" documentType="Files">
{MoreMenu}
<MoreMenu
isDisabled={isDisabled}
canCreateFolder={canCreateFolder}
canUpload={canUpload}
hasWriteAccess={hasWriteAccess}
/>
</SharingProvider>
</BarContextProvider>
</BarRight>
) : (
MoreMenu
<MoreMenu
isDisabled={isDisabled}
canCreateFolder={canCreateFolder}
canUpload={canUpload}
hasWriteAccess={hasWriteAccess}
/>
)}
</div>
)
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
48 changes: 24 additions & 24 deletions src/drive/web/modules/drive/Toolbar/components/CreateShortcut.jsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import React, { useState, useCallback } from 'react'
import React from 'react'
import { connect } from 'react-redux'
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'
import { showModal } from 'react-cozy-helpers'

const CreateShortcutWrapper = () => {
const [isModalDisplayed, setIsModalDisplayed] = useState(false)
const CreateShortcutWrapper = ({ openModal }) => {
const { t } = useI18n()
if (!isModalDisplayed) {
return (
<a
data-test-id="create-a-shortcut"
className={styles['fil-action-create-shortcut']}
onClick={useCallback(() => {
setIsModalDisplayed(true)
})}
>
{t('toolbar.menu_create_shortcut')}
</a>
)
} else {
return (
<ShortcutCreationModal
onClose={useCallback(() => setIsModalDisplayed(false))}
/>
)
}

return (
<ActionMenuItem
data-test-id="create-a-shortcut"
left={<Icon icon="link" />}
onClick={openModal}
>
{t('toolbar.menu_create_shortcut')}
</ActionMenuItem>
)
}

export default CreateShortcutWrapper
const mapDispatchToProps = dispatch => ({
openModal: () => dispatch(showModal(<ShortcutCreationModal />))
})

export default connect(
null,
mapDispatchToProps
)(CreateShortcutWrapper)
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
Loading