Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track merge and unmerge operations in frontend #2532

Merged
merged 24 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
454eb76
todo
skwowet Jul 17, 2024
ade1eea
Add step in mergeAction to track operation
skwowet Jul 19, 2024
9870b37
make prettier happi
skwowet Jul 19, 2024
0a69bc9
fix linter
skwowet Jul 19, 2024
67f5e4e
Merge branch 'crowd-linux' into improve/LFX-1410
skwowet Jul 19, 2024
1f8056c
rm setStep method
skwowet Jul 19, 2024
8de56f8
Merge branch 'improve/LFX-1410' of github.com:CrowdDotDev/crowd.dev i…
skwowet Jul 19, 2024
78c2738
add mergeAction endpoint
skwowet Jul 31, 2024
a6f133b
endpoint response and QA
skwowet Jul 31, 2024
b8adfcc
Merge branch 'crowd-linux' into improve/LFX-1410
skwowet Jul 31, 2024
6e6fa8d
make linter happy
skwowet Jul 31, 2024
c61f6de
Frontend display for syncing activities
gaspergrom Aug 1, 2024
2caf36a
improve endpoint structure and payload
skwowet Aug 1, 2024
e8526f2
Merge branch 'improve/LFX-1410' of github.com:CrowdDotDev/crowd.dev i…
skwowet Aug 1, 2024
5839097
resolve pr comments
skwowet Aug 2, 2024
55683fa
Merge branch 'crowd-linux' into improve/LFX-1410
skwowet Aug 2, 2024
47ec91b
prettiefy the code
skwowet Aug 2, 2024
b189c39
Finalize frontend
gaspergrom Aug 2, 2024
3a12ba9
interested only in most recent one
skwowet Aug 2, 2024
ef4b6b2
Merge branch 'improve/LFX-1410' of github.com:CrowdDotDev/crowd.dev i…
skwowet Aug 2, 2024
17cb46b
fix frontend to use org type
skwowet Aug 2, 2024
3bda4f1
Merge branch 'crowd-linux' into improve/LFX-1410
skwowet Aug 2, 2024
15a6243
Merge branch 'crowd-linux' into improve/LFX-1410
skwowet Aug 2, 2024
06a6edd
Fix texts
gaspergrom Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
<template>
<div v-if="props.contributor.activitySycning?.state === MergeActionState.IN_PROGRESS" class="pt-12 flex flex-col items-center">
<lf-icon name="loader-4-line" :size="40" class="text-gray-300 animate-spin" />
<h6 class="text-center py-3">
Syncing activities...
</h6>
<p class="text-center text-medium text-gray-500">
Re-syncing all the activities as this person was recently
{{ props.contributor.activitySycning?.operationType === 'merge' ? 'merged' : 'unmerged' }}.<br>
This process may take some minutes.
</p>
</div>
<div v-else-if="props.contributor.activitySycning?.state === MergeActionState.ERROR" class="pt-12 flex flex-col items-center">
<lf-icon name="error-warning-line" :size="40" class="text-gray-300" />
<h6 class="text-center py-3">
Error syncing activities
</h6>
<p class="text-center text-medium text-gray-500">
An error occurred while syncing this profile activities.<br>
Please contact our support team.
</p>
</div>
<app-activity-timeline
v-else
:entity="props.contributor"
entity-type="member"
:show-affiliations="true"
Expand All @@ -12,6 +34,8 @@
import { Contributor } from '@/modules/contributor/types/Contributor';
import AppActivityTimeline from '@/modules/activity/components/activity-timeline.vue';
import { useRoute } from 'vue-router';
import { MergeActionState } from '@/shared/modules/merge/types/MemberActions';
import LfIcon from '@/ui-kit/icon/Icon.vue';

const props = defineProps<{
contributor: Contributor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@
<p class="text-tiny text-secondary-300 mb-2">
# of activities
</p>
<p class="text-small text-gray-600">
<lf-loading
v-if="props.contributor.activitySycning?.state === MergeActionState.IN_PROGRESS"
:count="1"
height="1rem"
width="4rem"
class="rounded"
/>
<p v-else class="text-small text-gray-600">
{{ props.contributor.activityCount && formatNumber(props.contributor.activityCount) || '-' }}
</p>
</article>
Expand All @@ -57,6 +64,8 @@ import { formatNumber } from '@/utils/number';
import LfContributorEngagementLevel from '@/modules/contributor/components/shared/contributor-engagement-level.vue';
import LfContributorSentiment from '@/modules/contributor/components/shared/contributor-sentiment.vue';
import { Contributor } from '@/modules/contributor/types/Contributor';
import LfLoading from '@/ui-kit/loading/Loading.vue';
import { MergeActionState } from '@/shared/modules/merge/types/MemberActions';

const props = defineProps<{
contributor: Contributor,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<div v-if="inProgress" class="mr-4 z-50">
<lf-tooltip
placement="bottom"
:content="`Re-syncing all the activities as this profile was recently
${ props.contributor.activitySycning?.operationType === 'merge' ? 'merged' : 'unmerged' }. This process may take some minutes.`"
>
<div class="flex items-center gap-1.5 cursor-default">
<lf-icon name="loader-4-fill" :size="16" class="text-secondary-400 animate-spin" />
<p class="text-small text-secondary-400 font-semibold">
Syncing activities...
</p>
</div>
</lf-tooltip>
</div>
</template>

<script setup lang="ts">
import LfTooltip from '@/ui-kit/tooltip/Tooltip.vue';
import { Contributor } from '@/modules/contributor/types/Contributor';
import { computed } from 'vue';
import { MergeActionState } from '@/shared/modules/merge/types/MemberActions';
import LfIcon from '@/ui-kit/icon/Icon.vue';

const props = defineProps<{
contributor: Contributor,
}>();

const inProgress = computed(() => props.contributor.activitySycning?.state === MergeActionState.IN_PROGRESS);
</script>

<script lang="ts">
export default {
name: 'LfContributorSyncingActivities',
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<lf-contributor-details-header :contributor="contributor" />
</div>
<div class="flex items-center">
<lf-contributor-last-enrichment :contributor="contributor" class="mr-4" />
<lf-contributor-syncing-activities v-if="contributor.activitySycning?.state === MergeActionState.IN_PROGRESS" :contributor="contributor" />
<lf-contributor-last-enrichment v-else :contributor="contributor" class="mr-4" />
<div @mouseover.stop @mouseout.stop>
<lf-contributor-details-actions :contributor="contributor" @reload="fetchContributor()" />
</div>
Expand Down Expand Up @@ -48,7 +49,15 @@
Overview
</lf-tab>
<lf-tab v-model="tabs" name="activities">
Activities
<div class="flex items-center gap-1">
Activities
<lf-icon
v-if="contributor.activitySycning?.state === MergeActionState.ERROR"
name="error-warning-line"
:size="16"
class="text-red-500"
/>
</div>
</lf-tab>
<lf-tab v-model="tabs" name="notes">
Notes
Expand Down Expand Up @@ -100,6 +109,8 @@ import LfContributorDetailsHeader from '@/modules/contributor/components/details
import LfContributorDetailsActions from '@/modules/contributor/components/details/contributor-details-actions.vue';
import LfContributorLastEnrichment from '@/modules/contributor/components/shared/contributor-last-enrichment.vue';
import { useContributorStore } from '@/modules/contributor/store/contributor.store';
import LfContributorSyncingActivities from '@/modules/contributor/components/shared/contributor-syncing-activities.vue';
import { MergeActionState } from '@/shared/modules/merge/types/MemberActions';

const { getMemberCustomAttributes } = useMemberStore();

Expand Down
15 changes: 15 additions & 0 deletions frontend/src/modules/contributor/store/contributor.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,31 @@ import { useLfSegmentsStore } from '@/modules/lf/segments/store';
import { storeToRefs } from 'pinia';
import { ContributorApiService } from '@/modules/contributor/services/contributor.api.service';
import { Contributor } from '@/modules/contributor/types/Contributor';
import { MergeActionsService } from '@/shared/modules/merge/services/merge-actions.service';
import { MergeAction } from '@/shared/modules/merge/types/MemberActions';

export default {
getContributor(id: string): Promise<Contributor> {
const { selectedProjectGroup } = storeToRefs(useLfSegmentsStore());

return ContributorApiService.find(id, [selectedProjectGroup.value?.id as string])
.then((contributor) => {
this.contributor = contributor;
this.getContributorMergeActions(id);
return Promise.resolve(contributor);
});
},
getContributorMergeActions(id: string): Promise<MergeAction[]> {
return MergeActionsService.list(id)
.then((mergeActions) => {
this.contributor = {
...this.contributor,
// eslint-disable-next-line no-nested-ternary
activitySycning: mergeActions.length > 0 ? mergeActions[0] : null,
};
return Promise.resolve(mergeActions);
});
},
updateContributor(id: string, data: Partial<Contributor>) {
const { selectedProjectGroup } = storeToRefs(useLfSegmentsStore());
return ContributorApiService.update(id, data, [selectedProjectGroup.value?.id as string])
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/modules/contributor/types/Contributor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Organization } from '@/modules/organization/types/Organization';
import { MergeAction } from '@/shared/modules/merge/types/MemberActions';

export interface ContributorAttribute {
default: string;
Expand Down Expand Up @@ -82,5 +83,6 @@ export interface Contributor {
id: string;
name: string;
activityCount: string;
}[]
}[],
activitySycning: MergeAction | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ import LfButton from '@/ui-kit/button/Button.vue';
import AppMemberMergeSimilarity from '@/modules/member/components/suggestions/member-merge-similarity.vue';
import useProductTracking from '@/shared/modules/monitoring/useProductTracking';
import { EventType, FeatureEventKey } from '@/shared/modules/monitoring/types/event';
import { useContributorStore } from '@/modules/contributor/store/contributor.store';
import { MemberService } from '../member-service';

const props = defineProps({
Expand All @@ -164,6 +165,7 @@ const props = defineProps({
const emit = defineEmits(['reload']);

const { trackEvent } = useProductTracking();
const { getContributorMergeActions } = useContributorStore();

const membersToMerge = ref([]);
const primary = ref(0);
Expand Down Expand Up @@ -248,7 +250,7 @@ const ignoreSuggestion = () => {
MemberService.addToNoMerge(...membersToMerge.value.members)
.then(() => {
Message.success('Merging suggestion ignored successfully');

getContributorMergeActions();
const nextIndex = offset.value >= (count.value - 1) ? Math.max(count.value - 2, 0) : offset.value;
fetch(nextIndex);
changed.value = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ import { storeToRefs } from 'pinia';
import useProductTracking from '@/shared/modules/monitoring/useProductTracking';
import { EventType, FeatureEventKey } from '@/shared/modules/monitoring/types/event';
import LfIcon from '@/ui-kit/icon/Icon.vue';
import { useContributorStore } from '@/modules/contributor/store/contributor.store';
import AppMemberSuggestionsDetails from './suggestions/member-merge-suggestions-details.vue';

const props = defineProps({
Expand All @@ -292,6 +293,7 @@ const { doFind } = mapActions('member');

const lsSegmentsStore = useLfSegmentsStore();
const { selectedProjectGroup } = storeToRefs(lsSegmentsStore);
const { getContributorMergeActions } = useContributorStore();

const unmerging = ref(false);
const fetchingPreview = ref(false);
Expand Down Expand Up @@ -364,6 +366,7 @@ const unmerge = () => {

MemberService.unmerge(props.modelValue?.id, preview.value)
.then(() => {
getContributorMergeActions(props.modelValue?.id);
Message.info(
"We're finalizing profiles merging. We will let you know once the process is completed.",
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
<template>
<div v-if="props.organization.activitySycning?.state === MergeActionState.IN_PROGRESS" class="pt-12 flex flex-col items-center">
<lf-icon name="loader-4-line" :size="40" class="text-gray-300 animate-spin" />
<h6 class="text-center py-3">
Syncing activities...
</h6>
<p class="text-center text-medium text-gray-500">
Re-syncing all the activities as this organization was recently
{{ props.organization.activitySycning?.operationType === 'merge' ? 'merged' : 'unmerged' }}.<br>
This process may take some minutes.
</p>
</div>
<div v-else-if="props.organization.activitySycning?.state === MergeActionState.ERROR" class="pt-12 flex flex-col items-center">
<lf-icon name="error-warning-line" :size="40" class="text-gray-300" />
<h6 class="text-center py-3">
Error syncing activities
</h6>
<p class="text-center text-medium text-gray-500">
An error occurred while syncing this organization activities.<br>
Please contact our support team.
</p>
</div>
<app-activity-timeline
v-else
:entity="{
...props.organization,
organizations: [props.organization],
Expand All @@ -12,6 +34,8 @@
<script setup lang="ts">
import { Organization } from '@/modules/organization/types/Organization';
import AppActivityTimeline from '@/modules/activity/components/activity-timeline.vue';
import LfIcon from '@/ui-kit/icon/Icon.vue';
import { MergeActionState } from '@/shared/modules/merge/types/MemberActions';

const props = defineProps<{
organization: Organization,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
<p class="text-tiny text-secondary-300 mb-2">
# of activities
</p>
<p class="text-small text-gray-600">
<lf-loading
v-if="props.organization.activitySycning?.state === MergeActionState.IN_PROGRESS"
:count="1"
height="1rem"
width="4rem"
class="rounded"
/>
<p v-else class="text-small text-gray-600">
{{ props.organization.activityCount && formatNumber(props.organization.activityCount) || '-' }}
</p>
</article>
Expand All @@ -43,6 +50,8 @@ import { Organization } from '@/modules/organization/types/Organization';
import pluralize from 'pluralize';
import { onMounted, ref } from 'vue';
import { MemberService } from '@/modules/member/member-service';
import { MergeActionState } from '@/shared/modules/merge/types/MemberActions';
import LfLoading from '@/ui-kit/loading/Loading.vue';

const props = defineProps<{
organization: Organization,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ import useProductTracking from '@/shared/modules/monitoring/useProductTracking';
import { EventType, FeatureEventKey } from '@/shared/modules/monitoring/types/event';
import { Platform } from '@/shared/modules/platform/types/Platform';
import LfIcon from '@/ui-kit/icon/Icon.vue';
import { useOrganizationStore } from '@/modules/organization/store/pinia';

const props = defineProps({
modelValue: {
Expand All @@ -218,6 +219,8 @@ const fetchingPreview = ref(false);
const preview = ref(null);
const selectedIdentity = ref(null);

const { getOrganizationMergeActions } = useOrganizationStore();

const parseIdentityValues = (identity) => {
const splittedIdentity = identity.value?.split(':');

Expand Down Expand Up @@ -315,6 +318,7 @@ const unmerge = () => {

OrganizationService.unmerge(props.modelValue?.id, preview.value)
.then(() => {
getOrganizationMergeActions(props.modelValue?.id);
Message.info(
'We’re syncing all activities of the unmerged organization. We will let you know once the process is completed.',
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<div v-if="props.organization.activitySycning?.state === MergeActionState.IN_PROGRESS" class="mr-4 z-50">
<lf-tooltip
placement="bottom"
:content="`Re-syncing all the activities as this organization was recently
${props.organization.activitySycning?.operationType === 'merge' ? 'merged' : 'unmerged'}. This process may take some minutes.`"
>
<div class="flex items-center gap-1.5 cursor-default">
<lf-icon name="loader-4-fill" :size="16" class="text-secondary-400 animate-spin" />
<p class="text-small text-secondary-400 font-semibold">
Syncing activities...
</p>
</div>
</lf-tooltip>
</div>
</template>

<script setup lang="ts">
import LfTooltip from '@/ui-kit/tooltip/Tooltip.vue';
import { MergeActionState } from '@/shared/modules/merge/types/MemberActions';
import LfIcon from '@/ui-kit/icon/Icon.vue';
import { Organization } from '@/modules/organization/types/Organization';

const props = defineProps<{
organization: Organization,
}>();
</script>

<script lang="ts">
export default {
name: 'LfOrganizationSyncingActivities',
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
<lf-organization-details-header :organization="organization" />
</div>
<div class="flex items-center">
<lf-organization-last-enrichment :organization="organization" class="mr-4" />
<lf-organization-syncing-activities
v-if="organization.activitySycning?.state === MergeActionState.IN_PROGRESS"
:organization="organization"
class="mr-4"
/>
<lf-organization-last-enrichment v-else :organization="organization" class="mr-4" />
<div @mouseover.stop @mouseout.stop>
<lf-organization-details-actions :organization="organization" @reload="fetchOrganization()" />
</div>
Expand Down Expand Up @@ -60,7 +65,15 @@
People
</lf-tab>
<lf-tab v-model="tabs" name="activities">
Activities
<div class="flex items-center gap-1">
Activities
<lf-icon
v-if="organization.activitySycning?.state === MergeActionState.ERROR"
name="error-warning-line"
:size="16"
class="text-red-500"
/>
</div>
</lf-tab>
</lf-tabs>
</div>
Expand Down Expand Up @@ -112,6 +125,9 @@ import LfOrganizationDetailsEmails from '@/modules/organization/components/detai
import { useOrganizationStore } from '@/modules/organization/store/pinia';
import LfOrganizationDetailsContributors
from '@/modules/organization/components/details/organization-details-contributors.vue';
import LfOrganizationSyncingActivities
from '@/modules/organization/components/shared/organization-syncing-activities.vue';
import { MergeActionState } from '@/shared/modules/merge/types/MemberActions';

const lsSegmentsStore = useLfSegmentsStore();
const { selectedProjectGroup } = storeToRefs(lsSegmentsStore);
Expand Down
Loading
Loading