-
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
[full-ci] Batch actions for accepting and declining shares #5374
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2bfbe61
batch actions for Accept and Decline in Shared with me
elizavetaRa f13eab5
Move share action trigger into helper and create file action mixins
kulmann 0fbd6ed
Merge remote-tracking branch 'origin/master' into batch-actions-accep…
kulmann da7ecf5
Remove unnecessary params
kulmann 3ff7e9d
Move unit test from SharedWithMe view to helper
kulmann e10c0f2
Fix tests for declining a share
kulmann 27a774d
Changelog item
kulmann dd65fca
Remove unneeded mutation mappings
kulmann 8e6e97c
Fix e2e test about declining share
kulmann 5b889e6
Use decline share action in all files view sidebar
kulmann cc63a9e
Make highlighted file reactive
kulmann 7ebf005
Introduce mixins for data mod when mounting and destroying sidebar
kulmann dc2e4c3
Adjust tests about accepting shares
kulmann 745a28d
Remove resource after declining share when in personal route
kulmann 1371e88
Merge remote-tracking branch 'origin/master' into batch-actions-accep…
kulmann 695c7be
Make linter happy
kulmann 8c9bb37
Revert "decline share" action on "all files" page back to "delete" ac…
kulmann df7a6ac
Use delete step in tests where delete button is expected
kulmann f352330
Merge remote-tracking branch 'origin/master' into batch-actions-accep…
kulmann fee2fb5
Revert share loading when sidebar opens as it's not needed, yet
kulmann e72172f
Fix loading highlighted file in search mode
kulmann 953e6d9
Merge remote-tracking branch 'origin/master' into batch-actions-accep…
kulmann 168c78d
Fix e2e test for batch declining shares
kulmann 9caf39c
Add expected test failure about declining shares
kulmann 05404eb
Add more issue links to changelog
kulmann 1e72e12
Correctly await share action batches with a p-queue
kulmann 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,9 @@ | ||
Enhancement: Batch actions for accepting and declining shares | ||
|
||
We've added batch actions for accepting and declining multiple selected incoming shares at once. | ||
|
||
https://github.com/owncloud/web/issues/5204 | ||
https://github.com/owncloud/web/pull/5374 | ||
https://github.com/owncloud/web/issues/2513 | ||
https://github.com/owncloud/web/issues/3101 | ||
https://github.com/owncloud/web/issues/5435 |
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
43 changes: 43 additions & 0 deletions
43
packages/web-app-files/src/helpers/share/triggerShareAction.js
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,43 @@ | ||
import { buildSharedResource } from '../resources' | ||
import { shareStatus } from '../shareStatus' | ||
|
||
export async function triggerShareAction(resource, status, allowReSharing, $client) { | ||
const method = _getRequestMethod(status) | ||
if (!method) { | ||
throw new Error('invalid new share status') | ||
} | ||
|
||
// exec share action | ||
let response = await $client.requests.ocs({ | ||
service: 'apps/files_sharing', | ||
action: `api/v1/shares/pending/${resource.share.id}`, | ||
method | ||
}) | ||
|
||
// exit on failure | ||
if (response.status !== 200) { | ||
throw new Error(response.statusText) | ||
} | ||
|
||
// get updated share from response and transform & return it | ||
if (parseInt(response.headers.get('content-length')) > 0) { | ||
response = await response.json() | ||
if (response.ocs.data.length > 0) { | ||
const share = response.ocs.data[0] | ||
return buildSharedResource(share, true, allowReSharing) | ||
} | ||
} | ||
|
||
return null | ||
} | ||
|
||
function _getRequestMethod(status) { | ||
switch (status) { | ||
case shareStatus.accepted: | ||
return 'POST' | ||
case shareStatus.declined: | ||
return 'DELETE' | ||
default: | ||
return null | ||
} | ||
} |
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,51 @@ | ||
import { triggerShareAction } from '../../helpers/share/triggerShareAction' | ||
|
||
import { checkRoute } from '../../helpers/route' | ||
import MixinRoutes from '../routes' | ||
import { shareStatus } from '../../helpers/shareStatus' | ||
import { mapGetters, mapMutations } from 'vuex' | ||
|
||
export default { | ||
mixins: [MixinRoutes], | ||
computed: { | ||
...mapGetters(['isOcis']), | ||
$_acceptShare_items() { | ||
return [ | ||
{ | ||
icon: 'check', | ||
handler: this.$_acceptShare_trigger, | ||
label: () => this.$gettext('Accept share'), | ||
isEnabled: ({ resource }) => { | ||
if (!checkRoute(['files-shared-with-me'], this.$route.name)) { | ||
return false | ||
} | ||
|
||
return [shareStatus.pending, shareStatus.declined].includes(resource.status) | ||
}, | ||
componentType: 'oc-button', | ||
class: 'oc-files-actions-sidebar-accept-share-trigger' | ||
} | ||
] | ||
} | ||
}, | ||
methods: { | ||
...mapMutations('Files', ['UPDATE_RESOURCE']), | ||
async $_acceptShare_trigger(resource) { | ||
try { | ||
const share = await triggerShareAction( | ||
resource, | ||
shareStatus.accepted, | ||
!this.isOcis, | ||
this.$client | ||
) | ||
this.UPDATE_RESOURCE(share) | ||
} catch (error) { | ||
console.log(error) | ||
this.showMessage({ | ||
title: this.$gettext('Error while accepting the selected share.'), | ||
status: 'danger' | ||
}) | ||
} | ||
} | ||
} | ||
} |
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.
Dev leftover or on purpose?
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.
Intentional, because I don't want to swallow errors. Eventually we should come up with a proper logging solution.
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.
RFC ;)