Skip to content
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

feat: Check upload directory share state #2657

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/Sabre/Album/AlbumRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OCA\Photos\Album\AlbumWithFiles;
use OCA\Photos\Service\UserConfigService;
use OCP\Files\Folder;
use OCP\Files\InvalidDirectoryException;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use Sabre\DAV\Exception\Conflict;
Expand Down Expand Up @@ -81,6 +82,10 @@ public function createFile($name, $data = null) {
throw new Conflict('The destination exists and is not a folder');
}

if ($photosFolder->isShared()) {
throw new InvalidDirectoryException('The destination is a received share');
}

// Check for conflict and rename the file accordingly
$newName = $photosFolder->getNonExistingName($name);

Expand Down
49 changes: 36 additions & 13 deletions src/components/PhotosPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,25 @@

<!-- The actions on the bottom -->
<template #actions>
<UploadPicker :accept="allowedMimes"
:context="uploadContext"
:destination="photosLocationFolder"
:multiple="true"
@uploaded="refreshFiles" />
<NcButton type="primary" :disabled="loading || selectedFileIds.length === 0" @click="emitPickedEvent">
<template #icon>
<ImagePlus v-if="!loading" />
<NcLoadingIcon v-if="loading" />
</template>
{{ t('photos', 'Add to {destination}', { destination }) }}
</NcButton>
<div class="photos-picker__actions">
<div class="photos-picker__actions__buttons">
<UploadPicker :accept="allowedMimes"
:context="uploadContext"
:destination="photosLocationFolder"
:multiple="true"
@uploaded="refreshFiles" />
<NcButton type="primary" :disabled="loading || selectedFileIds.length === 0" @click="emitPickedEvent">
<template #icon>
<ImagePlus v-if="!loading" />
<NcLoadingIcon v-if="loading" />
</template>
{{ t('photos', 'Add to {destination}', { destination }) }}
</NcButton>
</div>
<NcNoteCard v-if="photosLocationFolder.attributes['owner-id'] !== currentUser" type="warning">
{{ t('photos', 'The destination folder is owned by {owner}', { owner: photosLocationFolder.attributes['owner-id'] }) }}
</NcNoteCard>
</div>
</template>

<FilesListViewer class="photos-picker__file-list"
Expand Down Expand Up @@ -89,11 +96,12 @@

<script>
import { UploadPicker } from '@nextcloud/upload'
import { NcButton, NcDialog, NcLoadingIcon, NcSelect, useIsMobile } from '@nextcloud/vue'
import { NcButton, NcDialog, NcLoadingIcon, NcSelect, NcNoteCard, useIsMobile } from '@nextcloud/vue'
import { defineComponent } from 'vue'
import { mapGetters } from 'vuex'

import moment from '@nextcloud/moment'
import { getCurrentUser } from '@nextcloud/auth'

import ImagePlus from 'vue-material-design-icons/ImagePlus.vue'

Expand All @@ -116,6 +124,7 @@ export default defineComponent({
NcDialog,
NcLoadingIcon,
NcSelect,
NcNoteCard,
UploadPicker,
},

Expand Down Expand Up @@ -176,6 +185,7 @@ export default defineComponent({
uploadContext: {
route: 'albumpicker',
},
currentUser: getCurrentUser(),
}
},

Expand Down Expand Up @@ -280,5 +290,18 @@ export default defineComponent({
justify-content: center;
}
}

&__actions {
display: flex;
flex-direction: column;
flex-grow: 1;

&__buttons {
display: flex;
align-items: center;
justify-content: end;
gap: 16px;
}
}
}
</style>
Loading