Skip to content

Commit

Permalink
chore(files_sharing): cleanup NewFileRequestDialog vue
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Jul 12, 2024
1 parent 5f42936 commit 04da658
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use OCA\Files_Sharing\ResponseDefinitions;
use OCA\Files_Sharing\SharedStorage;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\AppFramework\Http\DataResponse;
Expand Down
13 changes: 7 additions & 6 deletions apps/files_sharing/src/components/NewFileRequestDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<form ref="form"
class="file-request-dialog__form"
aria-labelledby="file-request-dialog-description"
aria-live="polite"
data-cy-file-request-dialog-form
@submit.prevent.stop="">
<FileRequestIntro v-show="currentStep === STEP.FIRST"
Expand All @@ -33,8 +34,8 @@
:note.sync="note" />

<FileRequestDatePassword v-show="currentStep === STEP.SECOND"
:deadline.sync="deadline"
:disabled="loading"
:expiration-date.sync="expirationDate"
:password.sync="password" />

<FileRequestFinish v-if="share"
Expand Down Expand Up @@ -124,9 +125,9 @@ import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
import IconCheck from 'vue-material-design-icons/Check.vue'
import IconNext from 'vue-material-design-icons/ArrowRight.vue'
import FileRequestDatePassword from './NewFileRequestDialog/FileRequestDatePassword.vue'
import FileRequestFinish from './NewFileRequestDialog/FileRequestFinish.vue'
import FileRequestIntro from './NewFileRequestDialog/FileRequestIntro.vue'
import FileRequestDatePassword from './NewFileRequestDialog/NewFileRequestDialogDatePassword.vue'
import FileRequestFinish from './NewFileRequestDialog/NewFileRequestDialogFinish.vue'
import FileRequestIntro from './NewFileRequestDialog/NewFileRequestDialogIntro.vue'
import Share from '../models/Share'
import logger from '../services/logger'
Expand Down Expand Up @@ -182,7 +183,7 @@ export default defineComponent({
label: '',
note: '',
deadline: null as Date | null,
expirationDate: null as Date | null,
password: null as string | null,
share: null as Share | null,
Expand Down Expand Up @@ -249,7 +250,7 @@ export default defineComponent({
this.loading = true
// Format must be YYYY-MM-DD
const expireDate = this.deadline ? this.deadline.toISOString().split('T')[0] : undefined
const expireDate = this.expirationDate ? this.expirationDate.toISOString().split('T')[0] : undefined
const shareUrl = generateOcsUrl('apps/files_sharing/api/v1/shares')
try {
const request = await axios.post<OCSResponse>(shareUrl, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@
<!-- Enable expiration -->
<legend>{{ t('files_sharing', 'When should the request expire ?') }}</legend>
<NcCheckboxRadioSwitch v-show="!defaultExpireDateEnforced"
:checked="defaultExpireDateEnforced || deadline !== null"
:checked="defaultExpireDateEnforced || expirationDate !== null"
:disabled="disabled || defaultExpireDateEnforced"
@update:checked="onToggleDeadline">
{{ t('files_sharing', 'Set a submission deadline') }}
{{ t('files_sharing', 'Set a submission expirationDate') }}
</NcCheckboxRadioSwitch>

<!-- Date picker -->
<NcDateTimePickerNative v-if="deadline !== null"
id="file-request-dialog-deadline"
<NcDateTimePickerNative v-if="expirationDate !== null"
id="file-request-dialog-expirationDate"
:disabled="disabled"
:hide-label="true"
:max="maxDate"
:min="minDate"
:placeholder="t('files_sharing', 'Select a date')"
:required="defaultExpireDateEnforced"
:value="deadline"
name="deadline"
:value="expirationDate"
name="expirationDate"
type="date"
@update:value="$emit('update:deadline', $event)"/>
@update:value="$emit('update:expirationDate', $event)"/>
</fieldset>

<!-- Password -->
Expand Down Expand Up @@ -113,7 +113,7 @@ export default defineComponent({
required: false,
default: false,
},
deadline: {
expirationDate: {
type: Date as PropType<Date | null>,
required: false,
default: null,
Expand All @@ -126,7 +126,7 @@ export default defineComponent({
},
emits: [
'update:deadline',
'update:expirationDate',
'update:password',
],
Expand Down Expand Up @@ -157,15 +157,15 @@ export default defineComponent({
computed: {
passwordAndExpirationSummary(): string {
if (this.deadline && this.password) {
if (this.expirationDate && this.password) {
return this.t('files_sharing', 'The request will expire on {date} at midnight and will be password protected.', {
date: this.deadline.toLocaleDateString(),
date: this.expirationDate.toLocaleDateString(),
})
}
if (this.deadline) {
if (this.expirationDate) {
return this.t('files_sharing', 'The request will expire on {date} at midnight.', {
date: this.deadline.toLocaleDateString(),
date: this.expirationDate.toLocaleDateString(),
})
}
Expand All @@ -180,7 +180,7 @@ export default defineComponent({
mounted() {
// If defined, we set the default expiration date
if (this.defaultExpireDate) {
this.$emit('update:deadline', sharingConfig.defaultExpirationDate)
this.$emit('update:expirationDate', sharingConfig.defaultExpirationDate)
}
// If enforced, we cannot set a date before the default expiration days (see admin settings)
Expand All @@ -196,7 +196,7 @@ export default defineComponent({
methods: {
onToggleDeadline(checked: boolean) {
this.$emit('update:deadline', checked ? new Date() : null)
this.$emit('update:expirationDate', checked ? new Date() : null)
},
async onTogglePassword(checked: boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,14 @@ export default defineComponent({
methods: {
async copyShareLink(event: MouseEvent) {
if (this.isCopied) {
this.isCopied = false
return
}
if (!navigator.clipboard) {
// Clipboard API not available
showError(this.t('files_sharing', 'Clipboard is not available'))
window.prompt(this.t('files_sharing', 'Automatically copying failed, please copy the share link manually'), this.shareLink)
return
}
Expand Down

0 comments on commit 04da658

Please sign in to comment.