Skip to content

Commit

Permalink
fix(bans): handle max length of internal note
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Jul 16, 2024
1 parent 88038f2 commit 26a717f
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/components/RightSidebar/Participants/Participant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,21 @@
{{ t('spreed', 'Also ban from this conversation') }}
</NcCheckboxRadioSwitch>
<template v-if="isBanParticipant">
<NcTextField v-if="isBanParticipant"
<NcTextArea v-if="isBanParticipant"
class="participant-dialog__input"
:label="t('spreed', 'Internal note (reason to ban)')"
:error="!!maxLengthWarning"
:value.sync="internalNote" />
<span v-if="maxLengthWarning" class="participant-dialog__error-hint">
{{ maxLengthWarning }}
</span>
</template>
</template>
<template #actions>
<NcButton type="tertiary" :disabled="isLoading" @click="isRemoveDialogOpen = false">
{{ t('spreed', 'Dismiss') }}
</NcButton>
<NcButton type="error" :disabled="isLoading" @click="removeParticipant">
<NcButton type="error" :disabled="isLoading || !!maxLengthWarning" @click="removeParticipant">
{{ t('spreed', 'Remove') }}
</NcButton>
</template>
Expand Down Expand Up @@ -376,7 +380,7 @@ import NcActionText from '@nextcloud/vue/dist/Components/NcActionText.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js'
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
import NcTextArea from '@nextcloud/vue/dist/Components/NcTextArea.js'
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip.js'

import ParticipantPermissionsEditor from './ParticipantPermissionsEditor.vue'
Expand Down Expand Up @@ -411,7 +415,7 @@ export default {
NcButton,
NcCheckboxRadioSwitch,
NcDialog,
NcTextField,
NcTextArea,
ParticipantPermissionsEditor,
// Icons
Account,
Expand Down Expand Up @@ -801,6 +805,16 @@ export default {
|| this.participant.actorType === ATTENDEE.ACTOR_TYPE.EMAILS)
},

maxLengthWarning() {
if (this.internalNote.length <= 4000) {
return ''
}
return t('spreed', 'The text must be less than or equal to {maxLength} characters long. Your current text is {charactersCount} characters long.', {
maxLength: 4000,
charactersCount: this.internalNote.length,
})
},

removeParticipantLabel() {
switch (this.participant.actorType) {
case ATTENDEE.ACTOR_TYPE.GROUPS:
Expand Down Expand Up @@ -1261,6 +1275,9 @@ export default {
&__input {
margin-block-end: 6px;
}
&__error-hint {
color: var(--color-error);
}
}

.utils {
Expand Down

0 comments on commit 26a717f

Please sign in to comment.