Skip to content

Commit

Permalink
Merge pull request #40390 from nextcloud/manual/backport/stable27/40372
Browse files Browse the repository at this point in the history
[stable27] Backport polish sharing flow bugs
  • Loading branch information
blizzz authored Sep 13, 2023
2 parents 9037509 + 2a54fc5 commit 0e5bb30
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 31 deletions.
23 changes: 21 additions & 2 deletions apps/files_sharing/lib/Listener/LoadSidebarListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,39 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Files_Sharing\Listener;

use OCA\Files_Sharing\AppInfo\Application;
use OCA\Files\Event\LoadSidebar;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;
use OCP\AppFramework\Services\IInitialState;
use OCP\Share\IManager;

/**
* @template-implements IEventListener<Event>
*/
class LoadSidebarListener implements IEventListener
{

class LoadSidebarListener implements IEventListener {
public function handle(Event $event): void {
public function __construct(private IInitialState $initialState, private IManager $shareManager)
{
}

public function handle(Event $event): void
{
if (!($event instanceof LoadSidebar)) {
return;
}

Util::addScript(Application::APP_ID, 'files_sharing_tab', 'files');

$shareConfig = [
'allowPublicUploads' => $this->shareManager->shareApiLinkAllowPublicUpload(),
];

$this->initialState->provideInitialState('shareConfig', $shareConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default {
return options
},
supportsFileDrop() {
if (this.isFolder) {
if (this.isFolder && this.config.isPublicUploadEnabled) {
const shareType = this.share.type ?? this.share.shareType
return [this.SHARE_TYPES.SHARE_TYPE_LINK, this.SHARE_TYPES.SHARE_TYPE_EMAIL].includes(shareType)
}
Expand Down
9 changes: 7 additions & 2 deletions apps/files_sharing/src/services/ConfigService.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@
*
*/

import { loadState } from '@nextcloud/initial-state'

export default class Config {

constructor() {
this._shareConfig = loadState('files_sharing', 'shareConfig', {})
}

/**
* Is public upload allowed on link shares ?
*
Expand All @@ -32,8 +38,7 @@ export default class Config {
* @memberof Config
*/
get isPublicUploadEnabled() {
return document.getElementsByClassName('files-filestable')[0]
&& document.getElementsByClassName('files-filestable')[0].dataset.allowPublicUpload === 'yes'
return this._shareConfig.allowPublicUploads
}

/**
Expand Down
36 changes: 16 additions & 20 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export default {
return this.share.id === null || this.share.id === undefined
},
allowsFileDrop() {
if (this.isFolder) {
if (this.isFolder && this.config.isPublicUploadEnabled) {
if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_LINK || this.share.type === this.SHARE_TYPES.SHARE_TYPE_EMAIL) {
return true
}
Expand Down Expand Up @@ -779,7 +779,7 @@ export default {
incomingShare.password = this.share.password
}
const share = await this.addShare(incomingShare, this.fileInfo, this.config)
const share = await this.addShare(incomingShare, this.fileInfo)
this.share = share
this.$emit('add:share', this.share)
} else {
Expand All @@ -791,36 +791,33 @@ export default {
/**
* Process the new share request
*
* @param {object} value the multiselect option
* @param {Share} share incoming share object
* @param {object} fileInfo file data
* @param {Config} config instance configs
*/
async addShare(value, fileInfo, config) {
// Clear the displayed selection
this.value = null
async addShare(share, fileInfo) {
// handle externalResults from OCA.Sharing.ShareSearch
if (value.handler) {
const share = await value.handler(this)
this.$emit('add:share', new Share(share))
if (share.handler) {
const shareFromHandler = await share.handler(this)
this.$emit('add:share', new Share(shareFromHandler))
return true
}
// this.loading = true // Are we adding loaders the new share flow?
console.debug('Adding a new share from the input for', value)
console.debug('Adding a new share from the input for', share)
try {
const path = (fileInfo.path + '/' + fileInfo.name).replace('//', '/')
const share = await this.createShare({
const resultingShare = await this.createShare({
path,
shareType: value.shareType,
shareWith: value.shareWith,
permissions: value.permissions,
shareType: share.shareType,
shareWith: share.shareWith,
permissions: share.permissions,
attributes: JSON.stringify(fileInfo.shareAttributes),
...(value.note ? { note: value.note } : {}),
...(value.password ? { password: value.password } : {}),
...(value.expireDate ? { expireDate: value.expireDate } : {}),
...(share.note ? { note: share.note } : {}),
...(share.password ? { password: share.password } : {}),
...(share.expireDate ? { expireDate: share.expireDate } : {}),
})
return share
return resultingShare
} catch (error) {
console.error('Error while adding new share', error)
} finally {
Expand Down Expand Up @@ -1030,7 +1027,6 @@ export default {
align-items: flex-start;
>button:first-child {
font-size: 12px;
color: rgb(223, 7, 7);
background-color: #f5f5f5;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

0 comments on commit 0e5bb30

Please sign in to comment.