-
Notifications
You must be signed in to change notification settings - Fork 159
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
fix: resolving internal links into share spaces and shared files #9821
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
447a41c
fix: resolving internal links into share spaces and shared files
JammingBen 063ddf9
test: remove invalid test steps
JammingBen c5b336d
fix: resolving public links to default app if configured
JammingBen 2502c54
docs: add changelog item
JammingBen 723f54d
feat: add export via index for useOpenWithDefaultApp composable
JammingBen 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Bugfix: Link resolving into default app | ||
|
||
Internal and public file links now reliably resolve into the default app when `openLinksWithDefaultApp` is enabled. | ||
|
||
https://github.com/owncloud/web/issues/9799 | ||
https://github.com/owncloud/web/issues/9776 | ||
https://github.com/owncloud/web/pull/9821 |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './actions' | ||
export * from './resourcesViewDefaults' | ||
export * from './openWithDefaultApp' | ||
export * from './shares' |
1 change: 1 addition & 0 deletions
1
packages/web-app-files/src/composables/openWithDefaultApp/index.ts
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './useOpenWithDefaultApp' |
30 changes: 30 additions & 0 deletions
30
packages/web-app-files/src/composables/openWithDefaultApp/useOpenWithDefaultApp.ts
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { useFileActions } from '@ownclouders/web-pkg' | ||
import { Resource, SpaceResource } from '@ownclouders/web-client' | ||
|
||
export function useOpenWithDefaultApp() { | ||
const { getDefaultEditorAction } = useFileActions() | ||
|
||
const openWithDefaultApp = ({ | ||
space, | ||
resource | ||
}: { | ||
space: SpaceResource | ||
resource: Resource | ||
}) => { | ||
if (!resource || resource.isFolder) { | ||
return | ||
} | ||
|
||
const fileActionsOptions = { | ||
resources: [resource], | ||
space: space | ||
} | ||
|
||
const defaultEditorAction = getDefaultEditorAction(fileActionsOptions) | ||
if (defaultEditorAction) { | ||
defaultEditorAction.handler({ ...fileActionsOptions }) | ||
} | ||
} | ||
|
||
return { openWithDefaultApp } | ||
} |
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
66 changes: 66 additions & 0 deletions
66
...ges/web-app-files/tests/unit/composables/openWithDefaultApp/useOpenWithDefaultApp.spec.ts
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { getComposableWrapper } from 'web-test-helpers' | ||
import { mock } from 'jest-mock-extended' | ||
import { Resource, SpaceResource } from '@ownclouders/web-client' | ||
import { useOpenWithDefaultApp } from '../../../../src/composables/openWithDefaultApp' | ||
import { useFileActions, Action } from '@ownclouders/web-pkg' | ||
|
||
jest.mock('@ownclouders/web-pkg', () => ({ | ||
...jest.requireActual('@ownclouders/web-pkg'), | ||
useFileActions: jest.fn() | ||
})) | ||
|
||
describe('useOpenWithDefaultApp', () => { | ||
it('should be valid', () => { | ||
expect(useOpenWithDefaultApp).toBeDefined() | ||
}) | ||
describe('method "openWithDefaultApp"', () => { | ||
it('should call the default action handler for files', () => { | ||
getWrapper({ | ||
setup: ({ openWithDefaultApp }, { defaultEditorAction }) => { | ||
openWithDefaultApp({ | ||
space: mock<SpaceResource>(), | ||
resource: mock<Resource>({ isFolder: false }) | ||
}) | ||
expect(defaultEditorAction.handler).toHaveBeenCalled() | ||
} | ||
}) | ||
}) | ||
it('should not call the default action handler for folders', () => { | ||
getWrapper({ | ||
setup: ({ openWithDefaultApp }, { defaultEditorAction }) => { | ||
openWithDefaultApp({ | ||
space: mock<SpaceResource>(), | ||
resource: mock<Resource>({ isFolder: true }) | ||
}) | ||
expect(defaultEditorAction.handler).not.toHaveBeenCalled() | ||
} | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
function getWrapper({ | ||
setup, | ||
defaultEditorAction = mock<Action>({ handler: jest.fn() }) | ||
}: { | ||
setup: ( | ||
instance: ReturnType<typeof useOpenWithDefaultApp>, | ||
mocks: { defaultEditorAction: any } | ||
) => void | ||
defaultEditorAction?: any | ||
}) { | ||
jest.mocked(useFileActions).mockReturnValue( | ||
mock<ReturnType<typeof useFileActions>>({ | ||
getDefaultEditorAction: () => defaultEditorAction | ||
}) | ||
) | ||
|
||
const mocks = { defaultEditorAction } | ||
|
||
return { | ||
wrapper: getComposableWrapper(() => { | ||
const instance = useOpenWithDefaultApp() | ||
setup(instance, mocks) | ||
}) | ||
} | ||
} |
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.
always nice to see how composables can actually be used in other composables... that turned out nice 💪
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.
apparently "composables" weren't named that way by accident ;-)