Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -26,7 +26,7 @@
:entity="props.contributor"
entity-type="member"
show-affiliations
:selected-segment="subProjectId || null"
:selected-segment="subProjectId || undefined"
class="max-w-full"
/>
</template>
Expand All @@ -47,10 +47,11 @@ const route = useRoute();

const timeline = ref<InstanceType<typeof AppActivityTimeline> | null>(null);

const { subProjectId } = route.query;
// shortcut: ignores array query values, as on main. revisit: when route queries are typed.
const subProjectId = route.query.subProjectId as string | undefined;

const loadMore = () => {
timeline.value.fetchActivities();
timeline.value?.fetchActivities();
};

// eslint-disable-next-line vue/define-macros-order -- plain <script> below counts as last, https://eslint.vuejs.org/rules/define-macros-order.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { computed } from 'vue';
import { contributorDetailsHeaderProfilePlatforms } from '@/modules/contributor/config/details-header-profile-platforms';
import LfContributorEditName from '@/modules/contributor/components/edit/contributor-edit-name.vue';
import type { Contributor } from '@/modules/contributor/types/Contributor';
import type { Platform } from '@/shared/modules/platform/types/Platform';
import useContributorHelpers from '@/modules/contributor/helpers/contributor.helpers';
import LfContributorWorkPosition from '@/modules/contributor/components/shared/contributor-work-position.vue';
import LfContributorDetailsHeaderProfiles
Expand All @@ -56,7 +57,7 @@ const {
} = useContributorHelpers();

const hasHeaderIdentities = computed(
() => (props.contributor.identities || []).some((i) => contributorDetailsHeaderProfilePlatforms.includes(i.platform)),
() => (props.contributor.identities || []).some((i) => contributorDetailsHeaderProfilePlatforms.includes(i.platform as Platform)),
);

const organization = computed(() => activeProfileOrganization(props.contributor));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const selectedIdentity = ref<string | null>(null);

const addIdentity = ref<boolean>(false);
const addIdentityTemplate = ref<Partial<ContributorIdentity> | null>(null);
const editIdentity = ref<Partial<ContributorIdentity> | null>(null);
const editIdentity = ref<ContributorIdentity | null>(null);

const unmerge = (identityId: string) => {
if (identityId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ opacity-0 invisible transition group-hover:visible group-hover:opacity-100 z-30
<a
v-for="identity of idents"
:key="`${platform}-${identity.value}`"
:href="identity.url"
:href="identity.url ?? undefined"
class="flex items-center justify-between p-2 transition"
:class="identity.url ? 'hover:bg-gray-50' : ''"
target="_blank"
Expand Down Expand Up @@ -80,6 +80,7 @@ import useContributorHelpers from '@/modules/contributor/helpers/contributor.hel
import { contributorDetailsHeaderProfilePlatforms } from '@/modules/contributor/config/details-header-profile-platforms';
import type { Contributor } from '@/modules/contributor/types/Contributor';
import { lfIdentities } from '@/config/identities';
import type { Platform } from '@/shared/modules/platform/types/Platform';

const props = defineProps<{
contributor: Contributor,
Expand All @@ -88,10 +89,10 @@ const props = defineProps<{
const { identities } = useContributorHelpers();

const platformIdentities = computed(() => {
const data = {};
const data: Record<string, ReturnType<typeof identities>> = {};
contributorDetailsHeaderProfilePlatforms.forEach((p) => { data[p] = []; });
identities(props.contributor).forEach((i) => {
if (contributorDetailsHeaderProfilePlatforms.includes(i.platform)) {
if (contributorDetailsHeaderProfilePlatforms.includes(i.platform as Platform)) {
data[i.platform].push(i);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,17 @@ const isAffilationEditOpen = ref<boolean>(false);
const getAffiliations = (projectId: string) => (props.contributor.affiliations || [])
.filter((affiliation) => affiliation.segmentId === projectId)
.reduce((obj: Record<string, ContributorAffiliation[]>, aff: ContributorAffiliation) => {
if (!obj[aff.organizationId]) {
// shortcut: a null organizationId keys as "null", as on main. revisit: when affiliations carry no null orgs.
const orgId = aff.organizationId as string;
if (!obj[orgId]) {
return {
...obj,
[aff.organizationId]: [aff],
[orgId]: [aff],
};
}
return {
...obj,
[aff.organizationId]: [...obj[aff.organizationId], aff],
[orgId]: [...obj[orgId], aff],
};
}, {});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ import LfBadge from '@/ui-kit/badge/Badge.vue';
import { dateHelper } from '@/shared/date-helper/date-helper';

const props = defineProps<{
project: any,
project: { affiliations: Record<string, ContributorAffiliation[]> },
}>();

const { selectedProjectGroup } = storeToRefs(useLfSegmentsStore());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const props = defineProps<{
sorting: string,
}>();

const emit = defineEmits<{(e: 'update:sorting', value: string)}>();
const emit = defineEmits<{(e: 'update:sorting', value: string): void}>();

const sortBy = computed({
get: () => props.sorting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ import LfButton from '@/ui-kit/button/Button.vue';
import LfIcon from '@/ui-kit/icon/Icon.vue';
import LfInput from '@/ui-kit/input/Input.vue';
import LfField from '@/ui-kit/field/Field.vue';
import type { Contributor, ContributorIdentity } from '@/modules/contributor/types/Contributor';
import type { CreateContributorIdentity, CreateContributorPayload } from '@/modules/contributor/types/Contributor';
import LfTooltip from '@/ui-kit/tooltip/Tooltip.vue';
import useVuelidate from '@vuelidate/core';
import { required } from '@vuelidate/validators';
Expand Down Expand Up @@ -161,11 +161,7 @@ const { memberIdentities } = useIdentitiesHelpers();

const { selectedProjectGroup } = storeToRefs(useLfSegmentsStore());

type ContributorAddIdentity = ContributorIdentity & {
// image: string,
// prefix: string,
// placeholder: string,
}
type ContributorAddIdentity = CreateContributorIdentity;

const platformList: ContributorAddIdentity[] = memberIdentities
.map((config: IdentityConfig) => ({
Expand Down Expand Up @@ -199,7 +195,7 @@ const rules = {
required,
},
email: {
required: (value: ContributorAddIdentity[]) => value.some((i) => i.length),
required: (value: string[]) => value.some((i) => i.length),
},
identities: {
required: (value: ContributorAddIdentity[]) => value.some((i) => i.value.length),
Expand All @@ -222,7 +218,7 @@ const createContributor = () => {
return;
}

const data: Partial<Contributor> = {
const data: CreateContributorPayload = {
displayName: form.name,
identities: [
...form.identities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const isEdit = computed(() => !!props.organization);
const sending = ref<boolean>(false);

interface ConrtibutorWorkHistoryForm {
organization: Organization | null,
organization: (Organization & { label?: string }) | null,
title: string;
dateStart: string | null;
dateEnd: string | null;
Expand Down Expand Up @@ -210,21 +210,6 @@ const updateWorkExperience = () => {
});
}

let orgs: Organization[] = [...(props.contributor.organizations || [])];
if (isEdit.value) {
orgs = orgs.map((o: Organization) => {
if (o.id === props.organization?.id
&& o.memberOrganizations?.title === props.organization?.memberOrganizations?.title
&& o.memberOrganizations?.dateStart === props.organization?.memberOrganizations?.dateStart
&& o.memberOrganizations?.dateEnd === props.organization?.memberOrganizations?.dateEnd) {
return data;
}
return o;
});
} else {
orgs.push(data);
}

sending.value = true;

(isEdit.value
Expand Down
50 changes: 29 additions & 21 deletions frontend/src/modules/contributor/helpers/contributor.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,37 @@ const useContributorHelpers = () => {
// Mirrors sortActiveOrganizations in services/libs/data-access-layer/src/members/dataProcessor.ts
const activeProfileOrganization = (contributor: Contributor) => {
const time = (date?: string) => (date ? new Date(date).getTime() : 0);
const range = (mo: MemberOrganization) => (mo.dateEnd ? time(mo.dateEnd) : Date.parse('9999-12-31')) - time(mo.dateStart);
const range = (mo: MemberOrganization) =>
(mo.dateEnd ? time(mo.dateEnd) : Date.parse('9999-12-31')) - time(mo.dateStart);

return (contributor.organizations || [])
.filter((org) => !org.memberOrganizations.dateEnd)
.sort((a, b) => {
const aMo = a.memberOrganizations;
const bMo = b.memberOrganizations;
const rank = Number(bMo.affiliationOverride?.allowAffiliation !== false)
- Number(aMo.affiliationOverride?.allowAffiliation !== false)
|| Number(bMo.affiliationOverride?.isPrimaryWorkExperience === true)
- Number(aMo.affiliationOverride?.isPrimaryWorkExperience === true)
|| Number(!!bMo.dateStart) - Number(!!aMo.dateStart);
return (
(contributor.organizations || [])
.filter((org) => !org.memberOrganizations.dateEnd)
.sort((a, b) => {
const aMo = a.memberOrganizations;
const bMo = b.memberOrganizations;
const rank =
Number(bMo.affiliationOverride?.allowAffiliation !== false) -
Number(aMo.affiliationOverride?.allowAffiliation !== false) ||
Number(bMo.affiliationOverride?.isPrimaryWorkExperience === true) -
Number(aMo.affiliationOverride?.isPrimaryWorkExperience === true) ||
Number(!!bMo.dateStart) - Number(!!aMo.dateStart);

if (rank) {
return rank;
}
if (aMo.dateStart) {
return range(bMo) - range(aMo) || aMo.id.localeCompare(bMo.id);
}
return time(b.createdAt) - time(a.createdAt)
|| (a.displayName || '').localeCompare(b.displayName || '', undefined, { sensitivity: 'base' })
|| aMo.id.localeCompare(bMo.id);
})[0] || null;
if (rank) {
return rank;
}
if (aMo.dateStart) {
return range(bMo) - range(aMo) || aMo.id.localeCompare(bMo.id);
}
return (
time(b.createdAt) - time(a.createdAt) ||
(a.displayName || '').localeCompare(b.displayName || '', undefined, {
sensitivity: 'base',
}) ||
aMo.id.localeCompare(bMo.id)
);
})[0] || null
);
};

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,11 @@ const fetchContributor = () => {
});
};

const controlScroll = (e: {
target: { scrollTop: any; clientHeight: any; scrollHeight: number };
}) => {
const controlScroll = (e: Event) => {
const target = e.target as HTMLElement;
if (
e.target.scrollTop + e.target.clientHeight
>= e.target.scrollHeight - 10
target.scrollTop + target.clientHeight
>= target.scrollHeight - 10
) {
if (tabs.value === 'activities') {
activities.value.loadMore();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { storeToRefs } from 'pinia';
import authAxios from '@/shared/axios/auth-axios';
import type { Contributor } from '@/modules/contributor/types/Contributor';
import type { Contributor, CreateContributorPayload } from '@/modules/contributor/types/Contributor';
import { useLfSegmentsStore } from '@/modules/lf/segments/store';

const getSegments = () => {
Expand Down Expand Up @@ -54,7 +54,7 @@ export class ContributorApiService {
).then(({ data }) => Promise.resolve(data));
}

static async create(data: Partial<Contributor>, segments: string[]) {
static async create(data: CreateContributorPayload, segments: string[]) {
const response = await authAxios.post(
'/member',
{
Expand Down
21 changes: 13 additions & 8 deletions frontend/src/modules/contributor/types/Contributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface ContributorAttribute {
}

export interface ContributorMaintainerRole {
id: string
id: string;
dateEnd: string | null;
dateStart: string;
memberId: string;
Expand Down Expand Up @@ -92,13 +92,13 @@ export interface Contributor {
activeDaysCount: string;
activeOn: string[] | null;
activityCount: string;
activityTypes:string[] | null;
attributes: Record<string, ContributorAttribute>
activityTypes: string[] | null;
attributes: Record<string, ContributorAttribute>;
averageSentiment: number | null;
contributions: ContributorContribution[]
contributions: ContributorContribution[];
createdAt: string;
displayName: string;
emails: string[]
emails: string[];
id: string;
identities: ContributorIdentity[];
importHash: string | null;
Expand All @@ -108,11 +108,11 @@ export interface Contributor {
noMergeIds: string[] | null;
numberOfOpenSourceContributions: number | null;
organizations: Organization[];
reach:ContributorReach;
reach: ContributorReach;
score: number;
toMergeIds: string[] | null;
updatedAt: string;
username: Record<string, string[]>
username: Record<string, string[]>;
verifiedEmails: string[];
unverifiedEmails: string[];
affiliations: ContributorAffiliation[];
Expand All @@ -121,7 +121,12 @@ export interface Contributor {
id: string;
name: string;
activityCount: string;
}[],
}[];
maintainerRoles: ContributorMaintainerRole[];
activitySycning: MergeAction | null;
}

export type CreateContributorPayload = Omit<Partial<Contributor>, 'identities'> & {
identities?: CreateContributorIdentity[];
manuallyCreated?: boolean;
};
2 changes: 1 addition & 1 deletion frontend/typecheck-baseline.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "errors": 160 }
{ "errors": 121 }
Loading