aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2024-07-12 10:41:41 +0200
committerJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-07-12 20:14:30 +0200
commit9b84831c8d0c1d715cd42fa3e4e01ac8a59fa369 (patch)
treee39514c2cd1e51150075dff10c36c664d2d53ab2 /apps
parent62defbd6b4dded5cdb4d76efe947231cc310263b (diff)
downloadnextcloud-server-9b84831c8d0c1d715cd42fa3e4e01ac8a59fa369.tar.gz
nextcloud-server-9b84831c8d0c1d715cd42fa3e4e01ac8a59fa369.zip
fix(files_sharing): adjust IAttributes API and files_versions
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/fileinfomodel.js2
-rw-r--r--apps/files/src/actions/downloadAction.ts2
-rw-r--r--apps/files/src/actions/moveOrCopyActionUtils.ts4
-rw-r--r--apps/files/src/views/FilesList.vue8
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php27
-rw-r--r--apps/files_sharing/tests/ApiTest.php2
-rw-r--r--apps/files_versions/src/components/Version.vue2
7 files changed, 20 insertions, 27 deletions
diff --git a/apps/files/js/fileinfomodel.js b/apps/files/js/fileinfomodel.js
index 9cd3660f710..0c0061d4d13 100644
--- a/apps/files/js/fileinfomodel.js
+++ b/apps/files/js/fileinfomodel.js
@@ -128,7 +128,7 @@
for (const i in this.attributes.shareAttributes) {
const attr = this.attributes.shareAttributes[i]
if (attr.scope === 'permissions' && attr.key === 'download') {
- return attr.enabled
+ return attr.value === true
}
}
diff --git a/apps/files/src/actions/downloadAction.ts b/apps/files/src/actions/downloadAction.ts
index 28a52551d22..a63beaca3f2 100644
--- a/apps/files/src/actions/downloadAction.ts
+++ b/apps/files/src/actions/downloadAction.ts
@@ -33,7 +33,7 @@ const isDownloadable = function(node: Node) {
if (node.attributes['mount-type'] === 'shared') {
const shareAttributes = JSON.parse(node.attributes['share-attributes'] ?? 'null')
const downloadAttribute = shareAttributes?.find?.((attribute: { scope: string; key: string }) => attribute.scope === 'permissions' && attribute.key === 'download')
- if (downloadAttribute !== undefined && downloadAttribute.enabled === false) {
+ if (downloadAttribute !== undefined && downloadAttribute.value === false) {
return false
}
}
diff --git a/apps/files/src/actions/moveOrCopyActionUtils.ts b/apps/files/src/actions/moveOrCopyActionUtils.ts
index d55247c8662..2092087cd9b 100644
--- a/apps/files/src/actions/moveOrCopyActionUtils.ts
+++ b/apps/files/src/actions/moveOrCopyActionUtils.ts
@@ -24,7 +24,7 @@ export const getQueue = () => {
}
type ShareAttribute = {
- enabled: boolean
+ value: any
key: string
scope: string
}
@@ -48,7 +48,7 @@ export const canMove = (nodes: Node[]) => {
export const canDownload = (nodes: Node[]) => {
return nodes.every(node => {
const shareAttributes = JSON.parse(node.attributes?.['share-attributes'] ?? '[]') as Array<ShareAttribute>
- return !shareAttributes.some(attribute => attribute.scope === 'permissions' && attribute.enabled === false && attribute.key === 'download')
+ return !shareAttributes.some(attribute => attribute.scope === 'permissions' && attribute.value === false && attribute.key === 'download')
})
}
diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue
index 98a817ac067..2f09bc73080 100644
--- a/apps/files/src/views/FilesList.vue
+++ b/apps/files/src/views/FilesList.vue
@@ -396,14 +396,14 @@ export default defineComponent({
return { ...this.$route, query: { dir } }
},
- shareAttributes(): number[] | undefined {
+ shareTypesAttributes(): number[] | undefined {
if (!this.currentFolder?.attributes?.['share-types']) {
return undefined
}
return Object.values(this.currentFolder?.attributes?.['share-types'] || {}).flat() as number[]
},
shareButtonLabel() {
- if (!this.shareAttributes) {
+ if (!this.shareTypesAttributes) {
return t('files', 'Share')
}
@@ -413,12 +413,12 @@ export default defineComponent({
return t('files', 'Shared')
},
shareButtonType(): Type | null {
- if (!this.shareAttributes) {
+ if (!this.shareTypesAttributes) {
return null
}
// If all types are links, show the link icon
- if (this.shareAttributes.some(type => type === Type.SHARE_TYPE_LINK)) {
+ if (this.shareTypesAttributes.some(type => type === Type.SHARE_TYPE_LINK)) {
return Type.SHARE_TYPE_LINK
}
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index 273dd30f7ef..4b044450957 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -1055,7 +1055,7 @@ class ShareAPIController extends OCSController {
}
if (!($node->getPermissions() & Constants::PERMISSION_SHARE)) {
- throw new SharingRightsException('no sharing rights on this item');
+ throw new SharingRightsException($this->l->t('no sharing rights on this item'));
}
// The current top parent we have access to
@@ -1171,7 +1171,7 @@ class ShareAPIController extends OCSController {
}
if (!$this->canEditShare($share)) {
- throw new OCSForbiddenException('You are not allowed to edit incoming shares');
+ throw new OCSForbiddenException($this->l->t('You are not allowed to edit incoming shares'));
}
if (
@@ -1218,7 +1218,7 @@ class ShareAPIController extends OCSController {
*/
if ($share->getSharedBy() !== $this->currentUser) {
- throw new OCSForbiddenException('You are not allowed to edit link shares that you don\'t own');
+ throw new OCSForbiddenException($this->l->t('You are not allowed to edit link shares that you don\'t own'));
}
// Update hide download state
@@ -1640,7 +1640,7 @@ class ShareAPIController extends OCSController {
// Make sure it expires at midnight in owner timezone
$date->setTime(0, 0, 0);
} catch (\Exception $e) {
- throw new \Exception('Invalid date. Format must be YYYY-MM-DD');
+ throw new \Exception($this->l->t('Invalid date. Format must be YYYY-MM-DD'));
}
return $date;
@@ -1845,7 +1845,7 @@ class ShareAPIController extends OCSController {
*/
private function confirmSharingRights(Node $node): void {
if (!$this->hasResharingRights($this->currentUser, $node)) {
- throw new SharingRightsException('no sharing rights on this item');
+ throw new SharingRightsException($this->l->t('No sharing rights on this item'));
}
}
@@ -2008,13 +2008,6 @@ class ShareAPIController extends OCSController {
$formattedShareAttributes = \json_decode($attributesString, true);
if (is_array($formattedShareAttributes)) {
foreach ($formattedShareAttributes as $formattedAttr) {
- // Legacy handling of the 'enabled' attribute
- if (array_key_exists('enabled', $formattedAttr)) {
- $formattedAttr['value'] = is_string($formattedAttr['enabled'])
- ? (bool) \json_decode($formattedAttr['enabled'])
- : $formattedAttr['enabled'];
- }
-
$newShareAttributes->setAttribute(
$formattedAttr['scope'],
$formattedAttr['key'],
@@ -2022,7 +2015,7 @@ class ShareAPIController extends OCSController {
);
}
} else {
- throw new OCSBadRequestException('Invalid share attributes provided: \"' . $attributesString . '\"');
+ throw new OCSBadRequestException($this->l->t('Invalid share attributes provided: "%s"', [$attributesString]));
}
}
$share->setAttributes($newShareAttributes);
@@ -2044,10 +2037,10 @@ class ShareAPIController extends OCSController {
if ($storage instanceof Wrapper) {
$storage = $storage->getInstanceOfStorage(SharedStorage::class);
if ($storage === null) {
- throw new \RuntimeException('Should not happen, instanceOfStorage but getInstanceOfStorage return null');
+ throw new \RuntimeException($this->l->t('Should not happen, instanceOfStorage but getInstanceOfStorage return null'));
}
} else {
- throw new \RuntimeException('Should not happen, instanceOfStorage but not a wrapper');
+ throw new \RuntimeException($this->l->t('Should not happen, instanceOfStorage but not a wrapper'));
}
/** @var \OCA\Files_Sharing\SharedStorage $storage */
$inheritedAttributes = $storage->getShare()->getAttributes();
@@ -2085,7 +2078,7 @@ class ShareAPIController extends OCSController {
}
if (!$this->canEditShare($share)) {
- throw new OCSForbiddenException('You are not allowed to send mail notifications');
+ throw new OCSForbiddenException($this->l->t('You are not allowed to send mail notifications'));
}
// For mail and link shares, the user must be
@@ -2093,7 +2086,7 @@ class ShareAPIController extends OCSController {
if ($share->getShareType() === IShare::TYPE_EMAIL
|| $share->getShareType() === IShare::TYPE_LINK) {
if ($share->getSharedBy() !== $this->currentUser) {
- throw new OCSForbiddenException('You are not allowed to send mail notifications');
+ throw new OCSForbiddenException($this->l->t('You are not allowed to send mail notifications'));
}
}
diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php
index cb5fbd145e9..770ebd14f1e 100644
--- a/apps/files_sharing/tests/ApiTest.php
+++ b/apps/files_sharing/tests/ApiTest.php
@@ -960,7 +960,7 @@ class ApiTest extends TestCase {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$ocs->updateShare(
$share1->getId(), 1, null, null, null, null, null, null, null,
- '[{"scope": "app1", "key": "attr1", "enabled": true}]'
+ '[{"scope": "app1", "key": "attr1", "value": true}]'
);
$ocs->cleanup();
diff --git a/apps/files_versions/src/components/Version.vue b/apps/files_versions/src/components/Version.vue
index c6d44edaf06..7c3bb4758de 100644
--- a/apps/files_versions/src/components/Version.vue
+++ b/apps/files_versions/src/components/Version.vue
@@ -259,7 +259,7 @@ export default defineComponent({
const downloadAttribute = this.fileInfo.shareAttributes
.find((attribute) => attribute.scope === 'permissions' && attribute.key === 'download') || {}
// If the download attribute is set to false, the file is not downloadable
- if (downloadAttribute?.enabled === false) {
+ if (downloadAttribute?.value === false) {
return false
}
}