-
Notifications
You must be signed in to change notification settings - Fork 65
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
File openings inside new tab #2521
Draft
trollepierre
wants to merge
11
commits into
master
Choose a base branch
from
native-opening
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c4a168f
fix(opening): allow natural opening of file and folder
trollepierre d2e6e0c
fix(opening): note and shortcut can now be ctrl clicked as well
trollepierre 70b591a
refactor(navigate): extract route navigation out of Views components
trollepierre b13cddd
refactor(public): public page navigate file does not handle notes
trollepierre 210ddde
refactor(opening): Use fileUrlToNavigate in Views
trollepierre 0990fb7
debug
trollepierre c8706a5
fix(opening): fix trash, recent, sharing views
trollepierre 9c91cea
refactor(FileOpener): remove unused function
trollepierre 4314cc6
fix(opening): fix recent views on click on folder midellipsis
trollepierre 489f8a2
fix(opening): in sharing index, some files don't have attributes
trollepierre 5ca4236
fix(opening): validate dom nesting, no anchor inside anchor
trollepierre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,18 +15,6 @@ const getParentDiv = element => { | |
return getParentDiv(element.parentNode) | ||
} | ||
|
||
export const getParentLink = element => { | ||
if (!element) { | ||
return null | ||
} | ||
|
||
if (element.nodeName.toLowerCase() === 'a') { | ||
return element | ||
} | ||
|
||
return getParentLink(element.parentNode) | ||
} | ||
|
||
const enableTouchEvents = ev => { | ||
// remove event when you rename a file | ||
if (['INPUT', 'BUTTON'].indexOf(ev.target.nodeName) !== -1) { | ||
|
@@ -43,7 +31,10 @@ const enableTouchEvents = ev => { | |
} | ||
|
||
// Check if the clicked element is a file path, in that case the FileOpener has nothing to handle | ||
if (ev.srcEvent.target.closest('[class^="fil-file-path"]')) return false | ||
if (ev.srcEvent.target.closest('[class^="fil-file-path"]')) { | ||
console.log('case 3') | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
@@ -56,7 +47,9 @@ const FileOpener = ({ | |
open, | ||
selectionModeActive, | ||
isRenaming, | ||
children | ||
children, | ||
folderUrlToNavigate, | ||
fileUrlToNavigate | ||
}) => { | ||
const rowRef = useRef() | ||
|
||
|
@@ -66,14 +59,20 @@ const FileOpener = ({ | |
const gesturesHandler = propagating(new Hammer(rowRef.current)) | ||
|
||
gesturesHandler.on('tap press singletap', ev => { | ||
console.log('tap press singletap') | ||
|
||
if (actionMenuVisible || disabled) return | ||
console.log('RETURN PASSE') | ||
if (enableTouchEvents(ev)) { | ||
console.log('TOUCH EVENT ENABLE') | ||
ev.preventDefault() // prevent a ghost click | ||
if (ev.type === 'press' || selectionModeActive) { | ||
console.log('PRESS') | ||
ev.srcEvent.stopImmediatePropagation() | ||
toggle(ev.srcEvent) | ||
} else { | ||
ev.srcEvent.stopImmediatePropagation() | ||
console.log('open') | ||
if (!isRenaming) open(ev.srcEvent, file) | ||
} | ||
} | ||
|
@@ -110,15 +109,47 @@ const FileOpener = ({ | |
) | ||
} | ||
|
||
const isFolder = file => | ||
file.attributes && file.attributes.type === 'directory' | ||
const isFile = file => | ||
(file.attributes && file.attributes.type === 'file') || | ||
file._type === 'io.cozy.files' | ||
const isShortcut = file => file.class === 'shortcut' | ||
const isNote = file => file.name.endsWith('.cozy-note') | ||
let buildHref = '' | ||
if (isFolder(file)) { | ||
buildHref = `/#${folderUrlToNavigate(file.id)}` | ||
} else if (isNote(file)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All these helpers method should already been in https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/models/file.js#L36-L50 I think |
||
// DO NOTHING | ||
// http://drive.cozy.localhost:8080/#/folder/io.cozy.files.root-dir/file/682e64b839470826fda67a4abc022ff4 | ||
// notes.cozy.localhost:8080/#/n/682e64b839470826fda67a4abc022ff4 | ||
} else if (isShortcut(file)) { | ||
// generate external file <= | ||
// DO NOTHING | ||
} else if (isFile(file)) { | ||
buildHref = `/#${fileUrlToNavigate(file.dir_id)(file)}` | ||
} else { | ||
console.log('NOT FILE') | ||
console.log({ file }) | ||
console.log('file._type, ', file._type) | ||
buildHref = '' | ||
} | ||
|
||
return ( | ||
<span | ||
<a | ||
data-testid="not-onlyoffice-span" | ||
className={styles['file-opener']} | ||
className={`${styles['file-opener']} ${styles['file-opener__a']}`} | ||
ref={rowRef} | ||
id={file.id} | ||
href={buildHref} | ||
onClick={ev => { | ||
console.log('on click file opener') | ||
|
||
ev.preventDefault() | ||
}} | ||
> | ||
{children} | ||
</span> | ||
</a> | ||
) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems that you build an href for a folder https://github.com/cozy/cozy-drive/pull/2521/files#diff-66f571a15fdeccd6293e111e9483d731a1d8a1bddf527123ece478a9605e12bfR121 why do you need to check the event key?