mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
Merge pull request #40390 from nextcloud/manual/backport/stable27/40372
[stable27] Backport polish sharing flow bugs
This commit is contained in:
commit
0e5bb30929
8 changed files with 51 additions and 31 deletions
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Files_Sharing\Listener;
|
||||
|
||||
use OCA\Files_Sharing\AppInfo\Application;
|
||||
|
|
@ -30,13 +31,31 @@ 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;
|
||||
|
||||
class LoadSidebarListener implements IEventListener {
|
||||
public function handle(Event $event): void {
|
||||
/**
|
||||
* @template-implements IEventListener<Event>
|
||||
*/
|
||||
class LoadSidebarListener implements IEventListener
|
||||
{
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 ?
|
||||
*
|
||||
|
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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 {
|
||||
|
|
@ -1030,7 +1027,6 @@ export default {
|
|||
align-items: flex-start;
|
||||
|
||||
>button:first-child {
|
||||
font-size: 12px;
|
||||
color: rgb(223, 7, 7);
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
|
|
|||
4
dist/core-common.js
vendored
4
dist/core-common.js
vendored
File diff suppressed because one or more lines are too long
2
dist/core-common.js.map
vendored
2
dist/core-common.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/files_sharing-files_sharing_tab.js
vendored
4
dist/files_sharing-files_sharing_tab.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files_sharing-files_sharing_tab.js.map
vendored
2
dist/files_sharing-files_sharing_tab.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue