From a780de4b640da515939a8e0ead0bb889437a41ca Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Tue, 11 Feb 2025 19:15:46 +0530 Subject: [PATCH] refactor: show deprecation warnings in dev only (#10868) Fixes: https://github.com/chatwoot/chatwoot/issues/10734 --- app/javascript/dashboard/components/Modal.vue | 2 +- app/javascript/dashboard/components/buttons/Button.vue | 10 ++++++---- .../dashboard/components/widgets/forms/Input.vue | 10 ++++++---- app/javascript/v3/components/Button/SubmitButton.vue | 10 ++++++---- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/javascript/dashboard/components/Modal.vue b/app/javascript/dashboard/components/Modal.vue index a1f7ba5ed..653e6cde0 100644 --- a/app/javascript/dashboard/components/Modal.vue +++ b/app/javascript/dashboard/components/Modal.vue @@ -57,7 +57,7 @@ useEventListener(document.body, 'mouseup', onMouseUp); useEventListener(document, 'keydown', onKeydown); onMounted(() => { - if (onClose && typeof onClose === 'function') { + if (import.meta.env.DEV && onClose && typeof onClose === 'function') { // eslint-disable-next-line no-console console.warn( "[DEPRECATED] The 'onClose' prop is deprecated. Please use the 'close' event instead." diff --git a/app/javascript/dashboard/components/buttons/Button.vue b/app/javascript/dashboard/components/buttons/Button.vue index 1ec445890..64b5ecb9a 100644 --- a/app/javascript/dashboard/components/buttons/Button.vue +++ b/app/javascript/dashboard/components/buttons/Button.vue @@ -28,10 +28,12 @@ export default { }, }, created() { - // eslint-disable-next-line - console.warn( - '[DEPRECATED] This component has been deprecated and will be removed soon. Please use v3/components/Form/Button.vue instead' - ); + if (import.meta.env.DEV) { + // eslint-disable-next-line + console.warn( + '[DEPRECATED] This component has been deprecated and will be removed soon. Please use v3/components/Form/Button.vue instead' + ); + } }, }; diff --git a/app/javascript/dashboard/components/widgets/forms/Input.vue b/app/javascript/dashboard/components/widgets/forms/Input.vue index b34d81259..bd6d49470 100644 --- a/app/javascript/dashboard/components/widgets/forms/Input.vue +++ b/app/javascript/dashboard/components/widgets/forms/Input.vue @@ -40,10 +40,12 @@ export default { }, emits: ['update:modelValue', 'input', 'blur'], mounted() { - // eslint-disable-next-line - console.warn( - '[DEPRECATED] has be deprecated and will be removed soon. Please use v3/components/Form/Input.vue instead' - ); + if (import.meta.env.DEV) { + // eslint-disable-next-line no-console + console.warn( + '[DEPRECATED] has be deprecated and will be removed soon. Please use v3/components/Form/Input.vue instead' + ); + } }, methods: { onChange(e) { diff --git a/app/javascript/v3/components/Button/SubmitButton.vue b/app/javascript/v3/components/Button/SubmitButton.vue index 24c04acbb..88dad0799 100644 --- a/app/javascript/v3/components/Button/SubmitButton.vue +++ b/app/javascript/v3/components/Button/SubmitButton.vue @@ -40,10 +40,12 @@ export default { }, }, created() { - // eslint-disable-next-line - console.warn( - '[DEPRECATED] This component has been deprecated and will be removed soon. Please use v3/components/Form/Button.vue instead' - ); + if (import.meta.env.DEV) { + // eslint-disable-next-line + console.warn( + '[DEPRECATED] This component has been deprecated and will be removed soon. Please use v3/components/Form/Button.vue instead' + ); + } }, };