chore: Repalce Hook Mixin with useHook composable [CW-3454] (#9994)

# Pull Request Template

## Description

Replace Hook mixin with useHook composable

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality not to work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration.


## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules

---------

Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
This commit is contained in:
Fayaz Ahmed
2024-08-22 16:48:02 +05:30
committed by GitHub
parent c80de24ac1
commit 7c2353c7d9
6 changed files with 174 additions and 34 deletions

View File

@@ -2,7 +2,7 @@
import { isEmptyObject } from '../../../../helper/commons';
import { mapGetters } from 'vuex';
import { useAlert } from 'dashboard/composables';
import hookMixin from './hookMixin';
import { useIntegrationHook } from 'dashboard/composables/useIntegrationHook';
import NewHook from './NewHook.vue';
import SingleIntegrationHooks from './SingleIntegrationHooks.vue';
import MultipleIntegrationHooks from './MultipleIntegrationHooks.vue';
@@ -13,13 +13,28 @@ export default {
SingleIntegrationHooks,
MultipleIntegrationHooks,
},
mixins: [hookMixin],
props: {
integrationId: {
type: [String, Number],
required: true,
},
},
setup(props) {
const { integrationId } = props;
const {
integration,
isIntegrationMultiple,
isIntegrationSingle,
isHookTypeInbox,
} = useIntegrationHook(integrationId);
return {
integration,
isIntegrationMultiple,
isIntegrationSingle,
isHookTypeInbox,
};
},
data() {
return {
loading: {},
@@ -31,23 +46,9 @@ export default {
},
computed: {
...mapGetters({ uiFlags: 'integrations/getUIFlags' }),
integration() {
return this.$store.getters['integrations/getIntegration'](
this.integrationId
);
},
showIntegrationHooks() {
return !this.uiFlags.isFetching && !isEmptyObject(this.integration);
},
integrationType() {
return this.integration.allow_multiple_hooks ? 'multiple' : 'single';
},
isIntegrationMultiple() {
return this.integrationType === 'multiple';
},
isIntegrationSingle() {
return this.integrationType === 'single';
},
showAddButton() {
return this.showIntegrationHooks && this.isIntegrationMultiple;
},
@@ -120,14 +121,14 @@ export default {
<div v-if="showIntegrationHooks" class="w-full">
<div v-if="isIntegrationMultiple">
<MultipleIntegrationHooks
:integration="integration"
:integration-id="integrationId"
@delete="openDeletePopup"
/>
</div>
<div v-if="isIntegrationSingle">
<SingleIntegrationHooks
:integration="integration"
:integration-id="integrationId"
@add="openAddHookModal"
@delete="openDeletePopup"
/>
@@ -135,7 +136,7 @@ export default {
</div>
<woot-modal :show.sync="showAddHookModal" :on-close="hideAddHookModal">
<NewHook :integration="integration" @close="hideAddHookModal" />
<NewHook :integration-id="integrationId" @close="hideAddHookModal" />
</woot-modal>
<woot-delete-modal

View File

@@ -1,14 +1,18 @@
<script>
import { mapGetters } from 'vuex';
import hookMixin from './hookMixin';
import { useIntegrationHook } from 'dashboard/composables/useIntegrationHook';
export default {
mixins: [hookMixin],
props: {
integration: {
type: Object,
default: () => ({}),
integrationId: {
type: String,
required: true,
},
},
setup(props) {
const { integration, isHookTypeInbox, hasConnectedHooks } =
useIntegrationHook(props.integrationId);
return { integration, isHookTypeInbox, hasConnectedHooks };
},
computed: {
...mapGetters({
globalConfig: 'globalConfig/get',

View File

@@ -2,16 +2,22 @@
<script>
import { mapGetters } from 'vuex';
import { useAlert } from 'dashboard/composables';
import hookMixin from './hookMixin';
import { useIntegrationHook } from 'dashboard/composables/useIntegrationHook';
export default {
mixins: [hookMixin],
props: {
integration: {
type: Object,
default: () => ({}),
integrationId: {
type: String,
required: true,
},
},
setup(props) {
const { integration, isHookTypeInbox } = useIntegrationHook(
props.integrationId
);
return { integration, isHookTypeInbox };
},
data() {
return {
endPoint: '',

View File

@@ -1,13 +1,18 @@
<script>
import hookMixin from './hookMixin';
import { useIntegrationHook } from 'dashboard/composables/useIntegrationHook';
export default {
mixins: [hookMixin],
props: {
integration: {
type: Object,
default: () => ({}),
integrationId: {
type: String,
required: true,
},
},
setup(props) {
const { integration, hasConnectedHooks } = useIntegrationHook(
props.integrationId
);
return { integration, hasConnectedHooks };
},
};
</script>