Skip to content

Commit

Permalink
Merge pull request #40372 from nextcloud/40172-polish-sharing-flow-bugs
Browse files Browse the repository at this point in the history
40172 polish sharing flow bugs
  • Loading branch information
Fenn-CS authored Sep 12, 2023
2 parents 4b349b1 + 3d071ab commit e94a83a
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 32 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 @@ -453,7 +453,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 @@ -784,7 +784,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 @@ -796,36 +796,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 @@ -1021,7 +1018,6 @@ export default {
align-items: flex-start;
>button:first-child {
font-size: 12px;
color: rgb(223, 7, 7);
background-color: #f5f5f5;
}
Expand Down
3 changes: 0 additions & 3 deletions dist/2079-2079.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/2079-2079.js.map

This file was deleted.

3 changes: 3 additions & 0 deletions dist/2785-2785.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/2785-2785.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 e94a83a

Please sign in to comment.