feat: remove usage of .sync and define explicitly emits (#10209)

References

- https://v3-migration.vuejs.org/breaking-changes/v-model
-
https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html
This commit is contained in:
Shivam Mishra
2024-10-03 12:44:18 +05:30
committed by GitHub
parent edc1fe2363
commit b8d0252511
82 changed files with 224 additions and 221 deletions

View File

@@ -785,7 +785,7 @@ watch(conversationFilters, (newVal, oldVal) => {
<DeleteCustomViews
v-if="showDeleteFoldersModal"
:show-delete-popup.sync="showDeleteFoldersModal"
v-model:show="showDeleteFoldersModal"
:active-custom-view="activeFolder"
:custom-views-id="foldersId"
:open-last-item-after-delete="openLastItemAfterDeleteInFolder"
@@ -878,7 +878,7 @@ watch(conversationFilters, (newVal, oldVal) => {
</DynamicScroller>
</div>
<woot-modal
:show.sync="showAdvancedFilters"
v-model:show="showAdvancedFilters"
:on-close="closeAdvanceFiltersModal"
size="medium"
>

View File

@@ -3,9 +3,8 @@
import { ref, computed, defineEmits, onMounted } from 'vue';
import { useEventListener } from '@vueuse/core';
const { show, modalType, closeOnBackdropClick, onClose } = defineProps({
const { modalType, closeOnBackdropClick, onClose } = defineProps({
closeOnBackdropClick: { type: Boolean, default: true },
show: Boolean,
showCloseButton: { type: Boolean, default: true },
onClose: { type: Function, required: true },
fullWidth: { type: Boolean, default: false },
@@ -14,6 +13,7 @@ const { show, modalType, closeOnBackdropClick, onClose } = defineProps({
});
const emit = defineEmits(['close']);
const show = defineModel('show', { type: Boolean, default: false });
const modalClassName = computed(() => {
const modalClassNameMap = {
@@ -32,6 +32,7 @@ const handleMouseDown = () => {
};
const close = () => {
show.value = false;
emit('close');
onClose();
};
@@ -40,14 +41,14 @@ const onMouseUp = () => {
if (mousedDownOnBackdrop.value) {
mousedDownOnBackdrop.value = false;
if (closeOnBackdropClick) {
onClose();
close();
}
}
};
const onKeydown = e => {
if (show && e.code === 'Escape') {
onClose();
if (show.value && e.code === 'Escape') {
close();
e.stopPropagation();
}
};

View File

@@ -4,6 +4,7 @@ export default {
modelValue: { type: Boolean, default: false },
size: { type: String, default: '' },
},
emits: ['update:modelValue', 'input'],
methods: {
onClick() {
this.$emit('update:modelValue', !this.modelValue);

View File

@@ -137,7 +137,7 @@ export default {
@click="openAIAssist"
/>
<woot-modal
:show.sync="showAIAssistanceModal"
v-model:show="showAIAssistanceModal"
:on-close="hideAIAssistanceModal"
>
<AIAssistanceModal
@@ -149,7 +149,7 @@ export default {
</div>
<div v-else-if="shouldShowAIAssistCTAButtonForAdmin" class="relative">
<AIAssistanceCTAButton @click="openAICta" />
<woot-modal :show.sync="showAICtaModal" :on-close="hideAICtaModal">
<woot-modal v-model:show="showAICtaModal" :on-close="hideAICtaModal">
<AICTAModal @close="hideAICtaModal" />
</woot-modal>
</div>

View File

@@ -38,6 +38,7 @@ export default {
default: false,
},
},
emits: ['update:modelValue', 'input', 'removeAction', 'resetAction'],
computed: {
action_name: {
get() {

View File

@@ -3,6 +3,7 @@ export default {
// The value types are dynamic, hence prop validation removed to work with our action schema
// eslint-disable-next-line vue/require-prop-types
props: ['teams', 'value'],
emits: ['input'],
data() {
return {
selectedTeams: [],

View File

@@ -47,6 +47,7 @@ export default {
placeholder: { type: String, default: '' },
enabledMenuOptions: { type: Array, default: () => [] },
},
emits: ['blur', 'input', 'update:modelValue', 'keyup', 'focus', 'keydown'],
setup() {
const { uiSettings, updateUISettings } = useUISettings();

View File

@@ -1,20 +1,20 @@
<script>
import { defineModel } from 'vue';
import { useVuelidate } from '@vuelidate/core';
import { required, minLength, email } from '@vuelidate/validators';
import { useAlert } from 'dashboard/composables';
export default {
props: {
show: {
type: Boolean,
default: false,
},
currentChat: {
type: Object,
default: () => ({}),
},
},
emits: ['cancel'],
setup() {
return { v$: useVuelidate() };
const show = defineModel('show', { type: Boolean, default: false });
return { v$: useVuelidate(), show };
},
data() {
return {
@@ -80,9 +80,8 @@ export default {
};
</script>
<!-- eslint-disable vue/no-mutating-props -->
<template>
<woot-modal :show.sync="show" :on-close="onCancel">
<woot-modal v-model:show="show" :on-close="onCancel">
<div class="flex flex-col h-auto overflow-auto">
<woot-modal-header
:header-title="$t('EMAIL_TRANSCRIPT.TITLE')"

View File

@@ -547,9 +547,9 @@ export default {
</div>
</div>
<ReplyBox
v-model:popout-reply-box="isPopOutReplyBox"
:conversation-id="currentChat.id"
:popout-reply-box.sync="isPopOutReplyBox"
@togglePopout="showPopOutReplyBox"
@toggle-popout="showPopOutReplyBox"
/>
</div>
</div>

View File

@@ -1,5 +1,6 @@
<script>
import { defineAsyncComponent } from 'vue';
// [TODO] The popout events are needlessly complex and should be simplified
import { defineAsyncComponent, defineModel } from 'vue';
import { mapGetters } from 'vuex';
import { useAlert } from 'dashboard/composables';
import { useUISettings } from 'dashboard/composables/useUISettings';
@@ -65,12 +66,7 @@ export default {
ArticleSearchPopover,
},
mixins: [inboxMixin, fileUploadMixin, keyboardEventListenerMixins],
props: {
popoutReplyBox: {
type: Boolean,
default: false,
},
},
emits: ['update:popoutReplyBox', 'togglePopout'],
setup() {
const {
uiSettings,
@@ -79,8 +75,14 @@ export default {
fetchSignatureFlagFromUISettings,
} = useUISettings();
const popoutReplyBox = defineModel('popoutReplyBox', {
type: Boolean,
default: false,
});
return {
uiSettings,
popoutReplyBox,
updateUISettings,
isEditorHotKeyEnabled,
fetchSignatureFlagFromUISettings,
@@ -1081,15 +1083,15 @@ export default {
:banner-message="$t('CONVERSATION.NOT_ASSIGNED_TO_YOU')"
has-action-button
:action-button-label="$t('CONVERSATION.ASSIGN_TO_ME')"
@primaryAction="onClickSelfAssign"
@primary-action="onClickSelfAssign"
/>
<ReplyTopPanel
:mode="replyType"
:is-message-length-reaching-threshold="isMessageLengthReachingThreshold"
:characters-remaining="charactersRemaining"
:popout-reply-box="popoutReplyBox"
@setReplyMode="setReplyMode"
@togglePopout="$emit('togglePopout')"
@set-reply-mode="setReplyMode"
@toggle-popout="$emit('togglePopout')"
/>
<ArticleSearchPopover
v-if="showArticleSearchPopover && connectedPortalSlug"

View File

@@ -17,6 +17,7 @@ export default {
default: '',
},
},
emits: ['update:bccEmails', 'update:ccEmails', 'update:toEmails'],
setup() {
return { v$: useVuelidate() };
},

View File

@@ -1,4 +1,5 @@
<script>
import { defineModel } from 'vue';
import TemplatesPicker from './TemplatesPicker.vue';
import TemplateParser from './TemplateParser.vue';
export default {
@@ -11,10 +12,12 @@ export default {
type: Number,
default: undefined,
},
show: {
type: Boolean,
default: true,
},
},
emits: ['onSend', 'cancel'],
setup() {
const show = defineModel('show', { type: Boolean, default: false });
return { show };
},
data() {
return {
@@ -47,9 +50,8 @@ export default {
};
</script>
<!-- eslint-disable vue/no-mutating-props -->
<template>
<woot-modal :show.sync="show" :on-close="onClose" size="modal-big">
<woot-modal v-model:show="show" :on-close="onClose" size="modal-big">
<woot-modal-header
:header-title="$t('WHATSAPP_TEMPLATES.MODAL.TITLE')"
:header-content="modalHeaderContent"
@@ -58,13 +60,13 @@ export default {
<TemplatesPicker
v-if="!selectedWaTemplate"
:inbox-id="inboxId"
@onSelect="pickTemplate"
@on-select="pickTemplate"
/>
<TemplateParser
v-else
:template="selectedWaTemplate"
@resetTemplate="onResetTemplate"
@sendMessage="onSendMessage"
@reset-template="onResetTemplate"
@send-message="onSendMessage"
/>
</div>
</woot-modal>

View File

@@ -26,7 +26,7 @@ export default {
<template>
<div class="image message-text__wrap">
<img :src="url" @click="onClick" @error="$emit('error')" />
<woot-modal full-width :show.sync="show" :on-close="onClose">
<woot-modal v-model:show="show" full-width :on-close="onClose">
<img :src="url" class="modal-image skip-context-menu" />
</woot-modal>
</div>

View File

@@ -116,7 +116,7 @@ export default {
</audio>
<GalleryView
v-if="show"
:show.sync="show"
v-model:show="show"
:attachment="attachment"
:all-attachments="filteredCurrentChatAttachments"
@error="onImgError"

View File

@@ -106,7 +106,7 @@ export default {
</button>
<GalleryView
v-if="showGalleryViewer"
:show.sync="showGalleryViewer"
v-model:show="showGalleryViewer"
:attachment="attachment"
:all-attachments="availableAttachments"
@error="onClose"

View File

@@ -30,7 +30,7 @@ export default {
<template>
<div class="video message-text__wrap">
<video ref="videoElement" :src="url" muted playsInline @click="onClick" />
<woot-modal :show.sync="show" :on-close="onClose">
<woot-modal v-model:show="show" :on-close="onClose">
<video
:src="url"
controls

View File

@@ -7,10 +7,6 @@ import { messageTimestamp } from 'shared/helpers/timeHelper';
import Thumbnail from 'dashboard/components/widgets/Thumbnail.vue';
const props = defineProps({
show: {
type: Boolean,
required: true,
},
attachment: {
type: Object,
required: true,
@@ -22,6 +18,7 @@ const props = defineProps({
});
const emit = defineEmits(['close']);
const show = defineModel('show', { type: Boolean, default: false });
const getters = useStoreGetters();
@@ -208,11 +205,10 @@ onMounted(() => {
});
</script>
<!-- eslint-disable vue/no-mutating-props -->
<template>
<woot-modal
v-model:show="show"
full-width
:show.sync="show"
:show-close-button="false"
:on-close="onClose"
>

View File

@@ -240,7 +240,7 @@ export default {
{{ $t('BULK_ACTION.ALL_CONVERSATIONS_SELECTED_ALERT') }}
</div>
<woot-modal
:show.sync="showCustomTimeSnoozeModal"
v-model:show="showCustomTimeSnoozeModal"
:on-close="hideCustomSnoozeModal"
>
<CustomSnoozeModal

View File

@@ -122,7 +122,7 @@ onMounted(() => {
@unlinkIssue="unlinkIssue"
/>
<woot-modal
:show.sync="shouldShowPopup"
v-model:show="shouldShowPopup"
:on-close="closePopup"
:close-on-backdrop-click="false"
class="!items-start [&>div]:!top-12 [&>div]:sticky"

View File

@@ -38,7 +38,8 @@ export default {
default: () => {},
},
},
created() {
emits: ['update:modelValue', 'input', 'blur'],
mounted() {
// eslint-disable-next-line
console.warn(
'[DEPRECATED] <WootInput> has be deprecated and will be removed soon. Please use v3/components/Form/Input.vue instead'

View File

@@ -29,6 +29,7 @@ export default {
default: false,
},
},
emits: ['blur', 'input', 'setCode'],
data() {
return {
selectedIndex: -1,

View File

@@ -1,4 +1,5 @@
<script>
import { defineModel } from 'vue';
import { required } from '@vuelidate/validators';
import { useVuelidate } from '@vuelidate/core';
import Modal from '../../Modal.vue';
@@ -8,37 +9,17 @@ export default {
Modal,
},
props: {
show: {
type: Boolean,
default: false,
},
title: {
type: String,
default: '',
},
message: {
type: String,
default: '',
},
confirmText: {
type: String,
default: '',
},
rejectText: {
type: String,
default: '',
},
confirmValue: {
type: String,
default: '',
},
confirmPlaceHolderText: {
type: String,
default: '',
},
title: { type: String, default: '' },
message: { type: String, default: '' },
confirmText: { type: String, default: '' },
rejectText: { type: String, default: '' },
confirmValue: { type: String, default: '' },
confirmPlaceHolderText: { type: String, default: '' },
},
emits: ['onClose', 'onConfirm'],
setup() {
return { v$: useVuelidate() };
const show = defineModel('show', { type: Boolean, default: false });
return { v$: useVuelidate(), show };
},
data() {
return {
@@ -65,9 +46,8 @@ export default {
};
</script>
<!-- eslint-disable vue/no-mutating-props -->
<template>
<Modal :show.sync="show" :on-close="closeModal">
<Modal v-model:show="show" :on-close="closeModal">
<woot-modal-header :header-title="title" :header-content="message" />
<form @submit.prevent="onConfirm">
<woot-input

View File

@@ -51,7 +51,7 @@ export default {
</script>
<template>
<Modal :show.sync="show" :on-close="cancel">
<Modal v-model:show="show" :on-close="cancel">
<div class="h-auto overflow-auto flex flex-col">
<woot-modal-header :header-title="title" :header-content="description" />
<div class="flex flex-row justify-end gap-2 py-4 px-6 w-full">

View File

@@ -1,26 +1,21 @@
<script>
<script setup>
import Modal from '../../Modal.vue';
export default {
components: {
Modal,
},
props: {
show: Boolean,
onClose: { type: Function, default: () => {} },
onConfirm: { type: Function, default: () => {} },
title: { type: String, default: '' },
message: { type: String, default: '' },
messageValue: { type: String, default: '' },
confirmText: { type: String, default: '' },
rejectText: { type: String, default: '' },
},
};
defineProps({
onClose: { type: Function, default: () => {} },
onConfirm: { type: Function, default: () => {} },
title: { type: String, default: '' },
message: { type: String, default: '' },
messageValue: { type: String, default: '' },
confirmText: { type: String, default: '' },
rejectText: { type: String, default: '' },
});
const show = defineModel('show', { type: Boolean, default: false });
</script>
<!-- eslint-disable vue/no-mutating-props -->
<template>
<Modal :show.sync="show" :on-close="onClose">
<Modal v-model:show="show" :on-close="onClose">
<woot-modal-header
:header-title="title"
:header-content="message"