Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Joan Reyero committed Oct 19, 2023
1 parent 45189db commit e1f233f
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 145 deletions.
8 changes: 6 additions & 2 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

167 changes: 77 additions & 90 deletions frontend/src/modules/member/components/member-dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
class="h-10 mb-1"
:disabled="isEditLockedForSampleData"
>
<i class="ri-pencil-line text-base mr-2" /><span class="text-xs"
>Edit contact</span
>
<i class="ri-pencil-line text-base mr-2" /><span class="text-xs">Edit contact</span>
</el-dropdown-item>
</router-link>
<el-tooltip
Expand Down Expand Up @@ -65,10 +63,9 @@
:class="{
'text-gray-400': isEnrichmentDisabledForMember,
}"
>{{
member.lastEnriched ? "Re-enrich contact" : "Enrich contact"
}}</span
>
>{{
member.lastEnriched ? "Re-enrich contact" : "Enrich contact"
}}</span>
</el-dropdown-item>
</span>
</el-tooltip>
Expand All @@ -81,9 +78,10 @@
class="h-10 mb-1"
:disabled="!isFindingGitHubDisabled"
>
<span class="max-w-[16px]" color="#9CA3AF"
><i class="ri-github-fill"
/></span>
<span
class="max-w-[16px]"
color="#9CA3AF"
><i class="ri-github-fill" /></span>
<span class="ml-2 text-xs"> Find GitHub </span>
</el-dropdown-item>
<el-dropdown-item
Expand All @@ -94,9 +92,7 @@
}"
:disabled="isEditLockedForSampleData"
>
<i class="ri-group-line text-base mr-2" /><span class="text-xs"
>Merge contact</span
>
<i class="ri-group-line text-base mr-2" /><span class="text-xs">Merge contact</span>
</el-dropdown-item>

<!-- Hubspot -->
Expand Down Expand Up @@ -144,9 +140,7 @@
}"
:disabled="isEditLockedForSampleData"
>
<i class="ri-bookmark-line text-base mr-2" /><span class="text-xs"
>Mark as team contact</span
>
<i class="ri-bookmark-line text-base mr-2" /><span class="text-xs">Mark as team contact</span>
</el-dropdown-item>
<el-dropdown-item
v-if="member.attributes.isTeamMember?.default"
Expand All @@ -158,9 +152,7 @@
}"
:disabled="isEditLockedForSampleData"
>
<i class="ri-bookmark-2-line text-base mr-2" /><span class="text-xs"
>Unmark as team contact</span
>
<i class="ri-bookmark-2-line text-base mr-2" /><span class="text-xs">Unmark as team contact</span>
</el-dropdown-item>
<el-dropdown-item
v-if="!member.attributes.isBot?.default"
Expand All @@ -171,9 +163,7 @@
}"
:disabled="isEditLockedForSampleData"
>
<i class="ri-robot-line text-base mr-2" /><span class="text-xs"
>Mark as bot</span
>
<i class="ri-robot-line text-base mr-2" /><span class="text-xs">Mark as bot</span>
</el-dropdown-item>
<el-dropdown-item
v-if="member.attributes.isBot?.default"
Expand All @@ -184,9 +174,7 @@
}"
:disabled="isEditLockedForSampleData"
>
<i class="ri-robot-line text-base mr-2" /><span class="text-xs"
>Unmark as bot</span
>
<i class="ri-robot-line text-base mr-2" /><span class="text-xs">Unmark as bot</span>
</el-dropdown-item>
<el-divider class="border-gray-200" />
<el-dropdown-item
Expand All @@ -207,8 +195,7 @@
:class="{
'text-red-500': !isDeleteLockedForSampleData,
}"
>Delete contact</span
>
>Delete contact</span>
</el-dropdown-item>
</template>
</el-dropdown>
Expand All @@ -220,23 +207,23 @@
</template>
<script>
import { mapActions, mapGetters } from "vuex";
import { mapActions as piniaMapActions } from "pinia";
import { MemberService } from "@/modules/member/member-service";
import Message from "@/shared/message/message";
import { MemberPermissions } from "@/modules/member/member-permissions";
import ConfirmDialog from "@/shared/dialog/confirm-dialog";
import AppSvg from "@/shared/svg/svg.vue";
import { useMemberStore } from "@/modules/member/store/pinia";
import { CrowdIntegrations } from "@/integrations/integrations-config";
import { HubspotEntity } from "@/integrations/hubspot/types/HubspotEntity";
import { HubspotApiService } from "@/integrations/hubspot/hubspot.api.service";
import AppMemberFindGithubDrawer from "./member-find-github-drawer.vue";
import { FeatureFlag, FEATURE_FLAGS } from "@/featureFlag";
import { isEnrichmentFeatureEnabled } from "@/modules/member/member-enrichment";
import { mapActions, mapGetters } from 'vuex';
import { mapActions as piniaMapActions } from 'pinia';
import { MemberService } from '@/modules/member/member-service';
import Message from '@/shared/message/message';
import { MemberPermissions } from '@/modules/member/member-permissions';
import ConfirmDialog from '@/shared/dialog/confirm-dialog';
import AppSvg from '@/shared/svg/svg.vue';
import { useMemberStore } from '@/modules/member/store/pinia';
import { CrowdIntegrations } from '@/integrations/integrations-config';
import { HubspotEntity } from '@/integrations/hubspot/types/HubspotEntity';
import { HubspotApiService } from '@/integrations/hubspot/hubspot.api.service';
import { isEnrichmentFeatureEnabled } from '@/modules/member/member-enrichment';
import AppMemberFindGithubDrawer from './member-find-github-drawer.vue';
import { FeatureFlag, FEATURE_FLAGS } from '@/featureFlag';
export default {
name: "AppMemberDropdown",
name: 'AppMemberDropdown',
components: {
AppSvg,
AppMemberFindGithubDrawer,
Expand All @@ -247,27 +234,27 @@ export default {
default: () => {},
},
},
emits: ["merge"],
emits: ['merge'],
data() {
return {
isMergeLoading: false,
pair: [],
openFindGitHubDrawer: false,
isFindGitHubFeatureEnabled: FeatureFlag.isFlagEnabled(
FEATURE_FLAGS.findGitHub
FEATURE_FLAGS.findGitHub,
),
};
},
computed: {
...mapGetters({
currentTenant: "auth/currentTenant",
currentUser: "auth/currentUser",
currentTenant: 'auth/currentTenant',
currentUser: 'auth/currentUser',
}),
isReadOnly() {
return (
new MemberPermissions(this.currentTenant, this.currentUser).edit ===
false
new MemberPermissions(this.currentTenant, this.currentUser).edit
=== false
);
},
isEnrichmentDisabled() {
Expand All @@ -277,12 +264,12 @@ export default {
},
isFindingGitHubDisabled() {
console.log(
this.member.username?.github === undefined ||
!this.member.username?.github?.length
this.member.username?.github === undefined
|| !this.member.username?.github?.length,
);
return (
this.member.username?.github === undefined ||
!this.member.username?.github?.length
this.member.username?.github === undefined
|| !this.member.username?.github?.length
);
},
isEditLockedForSampleData() {
Expand All @@ -300,19 +287,19 @@ export default {
},
isEnrichmentActionDisabled() {
return (
this.isEnrichmentDisabledForMember ||
this.isEditLockedForSampleData ||
!this.isEnrichmentFeatureEnabled()
this.isEnrichmentDisabledForMember
|| this.isEditLockedForSampleData
|| !this.isEnrichmentFeatureEnabled()
);
},
isSyncingWithHubspot() {
return this.member.attributes?.syncRemote?.hubspot || false;
},
isHubspotConnected() {
const hubspot = CrowdIntegrations.getMappedConfig("hubspot", this.$store);
const hubspot = CrowdIntegrations.getMappedConfig('hubspot', this.$store);
const enabledFor = hubspot.settings?.enabledFor || [];
return (
hubspot.status === "done" && enabledFor.includes(HubspotEntity.MEMBERS)
hubspot.status === 'done' && enabledFor.includes(HubspotEntity.MEMBERS)
);
},
isHubspotDisabledForMember() {
Expand All @@ -323,29 +310,29 @@ export default {
},
isHubspotActionDisabled() {
return (
!this.isHubspotConnected ||
this.isHubspotDisabledForMember ||
!this.isHubspotFeatureEnabled
!this.isHubspotConnected
|| this.isHubspotDisabledForMember
|| !this.isHubspotFeatureEnabled
);
},
},
methods: {
...mapActions({
doFind: "member/doFind",
doDestroy: "member/doDestroy",
doEnrich: "member/doEnrich",
doFind: 'member/doFind',
doDestroy: 'member/doDestroy',
doEnrich: 'member/doEnrich',
}),
...piniaMapActions(useMemberStore, ["fetchMembers"]),
...piniaMapActions(useMemberStore, ['fetchMembers']),
async doDestroyWithConfirm(id) {
try {
await ConfirmDialog({
type: "danger",
title: "Delete contact",
type: 'danger',
title: 'Delete contact',
message:
"Are you sure you want to proceed? You can't undo this action",
confirmButtonText: "Confirm",
cancelButtonText: "Cancel",
icon: "ri-delete-bin-line",
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
icon: 'ri-delete-bin-line',
});
await this.doDestroy(id);
Expand All @@ -356,34 +343,34 @@ export default {
return null;
},
async handleCommand(command) {
if (command.action === "memberDelete") {
if (command.action === 'memberDelete') {
await this.doDestroyWithConfirm(command.member.id);
} else if (
command.action === "syncHubspot" ||
command.action === "stopSyncHubspot"
command.action === 'syncHubspot'
|| command.action === 'stopSyncHubspot'
) {
// Hubspot
const sync = command.action === "syncHubspot";
const sync = command.action === 'syncHubspot';
(sync
? HubspotApiService.syncMember(command.member.id)
: HubspotApiService.stopSyncMember(command.member.id)
)
.then(() => {
if (this.$route.name === "member") {
if (this.$route.name === 'member') {
this.fetchMembers({ reload: true });
} else {
this.doFind(command.member.id);
}
if (sync) {
Message.success("Contact is now syncing with HubSpot");
Message.success('Contact is now syncing with HubSpot');
} else {
Message.success("Contact syncing stopped");
Message.success('Contact syncing stopped');
}
})
.catch(() => {
Message.error("There was an error");
Message.error('There was an error');
});
} else if (command.action === "memberMarkAsTeamMember") {
} else if (command.action === 'memberMarkAsTeamMember') {
await MemberService.update(command.member.id, {
attributes: {
...command.member.attributes,
Expand All @@ -394,39 +381,39 @@ export default {
});
await this.fetchMembers({ reload: true });
Message.success("Contact updated successfully");
Message.success('Contact updated successfully');
if (this.$route.name === "member") {
if (this.$route.name === 'member') {
await this.fetchMembers({ reload: true });
} else {
this.doFind(command.member.id);
}
} else if (
command.action === "memberMarkAsBot" ||
command.action === "memberUnmarkAsBot"
command.action === 'memberMarkAsBot'
|| command.action === 'memberUnmarkAsBot'
) {
await MemberService.update(command.member.id, {
attributes: {
...command.member.attributes,
isBot: {
default: command.action === "memberMarkAsBot",
default: command.action === 'memberMarkAsBot',
},
},
});
await this.fetchMembers({ reload: true });
Message.success("Contact updated successfully");
if (this.$route.name === "member") {
Message.success('Contact updated successfully');
if (this.$route.name === 'member') {
await this.fetchMembers({ reload: true });
} else {
this.doFind(command.member.id);
}
} else if (command.action === "memberMerge") {
this.$emit("merge");
} else if (command.action === "memberEnrich") {
} else if (command.action === 'memberMerge') {
this.$emit('merge');
} else if (command.action === 'memberEnrich') {
await this.doEnrich(command.member.id);
await this.fetchMembers({ reload: true });
} else if (command.action === "memberFindGitHub") {
console.log("here");
} else if (command.action === 'memberFindGitHub') {
console.log('here');
this.openFindGitHubDrawer = true;
console.log(this.openFindGitHubDrawer);
}
Expand Down
Loading

0 comments on commit e1f233f

Please sign in to comment.