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

Add timelines #681

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
34 changes: 8 additions & 26 deletions core/domain/contribution/models/contribution-event-model.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,24 @@
import { ContributionEventType } from "@/core/domain/contribution/models/contribution.types";
import { ContributionEventTypeUnion } from "@/core/domain/contribution/models/contribution.types";
import { components } from "@/core/infrastructure/marketplace-api-client-adapter/__generated/api";

export type ContributionEventResponse = components["schemas"]["ContributionEventResponse"];

export interface ContributionEventInterface extends ContributionEventResponse {
getEventType(): ContributionEventType | undefined;
getEventType(): ContributionEventTypeUnion | undefined;
}

export class ContributionEvent implements ContributionEventInterface {
timestamp!: ContributionEventResponse["timestamp"];
assigneeAdded!: ContributionEventResponse["assigneeAdded"];
assigneeRemoved!: ContributionEventResponse["assigneeRemoved"];
opened!: ContributionEventResponse["opened"];
merged!: ContributionEventResponse["merged"];
closed!: ContributionEventResponse["closed"];
issueLinked!: ContributionEventResponse["issueLinked"];
issueUnlinked!: ContributionEventResponse["issueUnlinked"];
type!: ContributionEventResponse["type"];
assignee!: ContributionEventResponse["assignee"];
mergedBy!: ContributionEventResponse["mergedBy"];
linkedIssueContributionUuid!: ContributionEventResponse["linkedIssueContributionUuid"];

constructor(props: ContributionEventResponse) {
Object.assign(this, props);
}

getEventType(): ContributionEventType | undefined {
switch (true) {
case !!this.assigneeAdded:
return ContributionEventType.CONTRIBUTOR_ASSIGNED;
case !!this.assigneeRemoved:
return ContributionEventType.CONTRIBUTOR_REMOVED;
case !!this.opened:
return ContributionEventType.PR_CREATED;
case !!this.merged:
return ContributionEventType.TO_REVIEW;
case !!this.closed:
return ContributionEventType.CLOSED;
case !!this.issueLinked:
return ContributionEventType.ISSUE_CREATED;
default:
return undefined;
}
getEventType(): ContributionEventTypeUnion | undefined {
return this.type;
}
}
15 changes: 9 additions & 6 deletions core/domain/contribution/models/contribution.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GetContributionsResponse } from "@/core/domain/contribution/contribution-contract.types";
import { ContributionEventResponse } from "@/core/domain/contribution/models/contribution-event-model";

type status = GetContributionsResponse["contributions"][0]["activityStatus"];

Expand All @@ -15,14 +16,16 @@ export type ContributionActivityStatusUnion = keyof typeof ContributionActivityS
export type ContributionGithubStatusUnion = GetContributionsResponse["contributions"][0]["githubStatus"];
export type ContributionTypeUnion = GetContributionsResponse["contributions"][0]["type"];

export type ContributionEventTypeUnion = ContributionEventResponse["type"];

export enum ContributionEventType {
PR_CREATED = "PR_CREATED",
CONTRIBUTOR_ASSIGNED = "CONTRIBUTOR_ASSIGNED",
CONTRIBUTOR_REMOVED = "CONTRIBUTOR_REMOVED",
ISSUE_CREATED = "ISSUE_CREATED",
TO_REVIEW = "TO_REVIEW",
CLOSED = "CLOSED",
REWARDED = "REWARDED",
PR_CREATED = "PR_CREATED",
ISSUE_ASSIGNED = "ISSUE_ASSIGNED",
PR_MERGED = "PR_MERGED",
ISSUE_CLOSED = "ISSUE_CLOSED",
LINKED_ISSUE_CREATED = "LINKED_ISSUE_CREATED",
LINKED_ISSUE_ASSIGNED = "LINKED_ISSUE_ASSIGNED",
}

export enum ContributionAs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ContributionClientAdapter implements ContributionStoragePort {
routes = {
getContributions: "contributions",
getContributionById: "contributions/:contributionUuid",
getContributionEvent: "contributions/:contributionId/events",
getContributionEvent: "contributions/:contributionUuid/events",
} as const;

getContributions = ({ queryParams }: FirstParameter<ContributionStoragePort["getContributions"]>) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CircleCheck, CircleDashed, CircleDollarSign, CircleDotDashed, UserRoundPlus, UserX } from "lucide-react";
import { CircleCheck, CircleDashed, GitMerge, UserRoundPlus } from "lucide-react";
import { useMemo } from "react";

import { ContributionReactQueryAdapter } from "@/core/application/react-query-adapter/contribution";
Expand All @@ -20,26 +20,26 @@ export function Timeline({ id }: TimelineProps) {
const dateKernelPort = bootstrap.getDateKernelPort();

const { data: events } = ContributionReactQueryAdapter.client.useGetContributionEvents({
pathParams: { contributionId: id },
pathParams: { contributionUuid: id },
});

function getTranslate(event: ContributionEventInterface): TranslateProps | undefined {
const type = event.getEventType();
switch (type) {
case ContributionEventType.CONTRIBUTOR_ASSIGNED:
return { token: "panels:contribution.timeline.items.contributorAssigned" };
case ContributionEventType.PR_CREATED:
return { token: "panels:contribution.timeline.items.prCreated" };
case ContributionEventType.CONTRIBUTOR_REMOVED:
return { token: "panels:contribution.timeline.items.contributorRemoved" };
case ContributionEventType.ISSUE_CREATED:
return { token: "panels:contribution.timeline.items.issueCreated" };
case ContributionEventType.TO_REVIEW:
return { token: "panels:contribution.timeline.items.toReview" };
case ContributionEventType.CLOSED:
return { token: "panels:contribution.timeline.items.closed" };
case ContributionEventType.REWARDED:
return { token: "panels:contribution.timeline.items.rewarded" };
return { token: "panels:contribution.timeline.items.ISSUE_CREATED" };
case ContributionEventType.PR_CREATED:
return { token: "panels:contribution.timeline.items.PR_CREATED" };
case ContributionEventType.ISSUE_ASSIGNED:
return { token: "panels:contribution.timeline.items.ISSUE_ASSIGNED" };
case ContributionEventType.PR_MERGED:
return { token: "panels:contribution.timeline.items.PR_MERGED" };
case ContributionEventType.ISSUE_CLOSED:
return { token: "panels:contribution.timeline.items.ISSUE_CLOSED" };
case ContributionEventType.LINKED_ISSUE_CREATED:
return { token: "panels:contribution.timeline.items.LINKED_ISSUE_CREATED" };
case ContributionEventType.LINKED_ISSUE_ASSIGNED:
return { token: "panels:contribution.timeline.items.LINKED_ISSUE_ASSIGNED" };
default:
return undefined;
}
Expand All @@ -48,20 +48,20 @@ export function Timeline({ id }: TimelineProps) {
function getIcon(event: ContributionEventInterface) {
const type = event.getEventType();
switch (type) {
case ContributionEventType.CONTRIBUTOR_ASSIGNED:
return { component: UserRoundPlus };
case ContributionEventType.PR_CREATED:
return { component: CircleDashed };
case ContributionEventType.CONTRIBUTOR_REMOVED:
return { component: UserX };
case ContributionEventType.ISSUE_CREATED:
return { component: CircleDashed };
case ContributionEventType.TO_REVIEW:
return { component: CircleDotDashed };
case ContributionEventType.CLOSED:
case ContributionEventType.LINKED_ISSUE_CREATED:
return { component: CircleDashed };
case ContributionEventType.ISSUE_ASSIGNED:
return { component: UserRoundPlus };
case ContributionEventType.LINKED_ISSUE_ASSIGNED:
return { component: UserRoundPlus };
case ContributionEventType.ISSUE_CLOSED:
return { component: CircleCheck };
case ContributionEventType.REWARDED:
return { component: CircleDollarSign };
case ContributionEventType.PR_CREATED:
return { component: CircleDashed };
case ContributionEventType.PR_MERGED:
return { component: GitMerge };
default:
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"timeline": {
"title": "Timeline",
"items": {
"prCreated": "PR Created",
"contributorAssigned": "Contributor assigned",
"contributorRemoved": "Contributor removed",
"issueCreated": "Issue Created",
"toReview": "To review",
"closed": "Closed",
"rewarded": "Rewarded"
"ISSUE_CREATED": "Issue created",
"PR_CREATED": "PR Created",
"ISSUE_ASSIGNED": "Issue assigned",
"PR_MERGED": "PR Merged",
"ISSUE_CLOSED": "Issue closed",
"LINKED_ISSUE_CREATED": "Linked issue created",
"LINKED_ISSUE_ASSIGNED": "Linked issue assigned"
}
},
"contributors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ContributionsPanelData } from "@/shared/panels/contribution-sidepanel/c

import { Helper } from "./_features/helper/helper";
import { RewardedCardWrapper } from "./_features/rewarded-card-wrapper/rewarded-card-wrapper";
import { Timeline } from "./_features/timeline/timeline";

export function useContributionsSidepanel() {
return useSinglePanelContext<ContributionsPanelData>("contribution-details");
Expand Down Expand Up @@ -57,8 +58,7 @@ function useContributionBlocksAsMaintainer({ contribution, helperState }: UseCon
<IssueOverview contribution={contribution} />
<RewardedCardWrapper contribution={contribution} />
<Assignees showRemove={true} contribution={contribution} />
{/* KEEP THIS */}
{/*<Timeline id={contribution.id} />*/}
<Timeline id={contribution.id} />
</>
);
}
Expand All @@ -75,8 +75,7 @@ function useContributionBlocksAsMaintainer({ contribution, helperState }: UseCon
<RewardedCardWrapper contribution={contribution} />
<LinkedIssues issues={contribution.linkedIssues} />
<Assignees contribution={contribution} />
{/* KEEP THIS */}
{/*<Timeline id={contribution.id} />*/}
<Timeline id={contribution.id} />
</>
);
}
Expand All @@ -87,8 +86,7 @@ function useContributionBlocksAsMaintainer({ contribution, helperState }: UseCon
<IssueOverview contribution={contribution} />
<RewardedCardWrapper contribution={contribution} />
<Assignees contribution={contribution} />
{/* KEEP THIS */}
{/*<Timeline id={contribution.id} />*/}
<Timeline id={contribution.id} />
</>
);
}
Expand Down Expand Up @@ -142,7 +140,7 @@ function useContributionBlocksAsContributor({ contribution }: UseContributionBlo
<RewardedCardWrapper contribution={contribution} recipientIds={recipientIds} />
<UserCard title={{ translate: { token: "panels:contribution.userCard.assignedBy" } }} user={assignedBy} />
<Description description={contribution.githubBody} />
{/*// Timeline*/}
<Timeline id={contribution.id} />
</>
);
}
Expand All @@ -155,7 +153,7 @@ function useContributionBlocksAsContributor({ contribution }: UseContributionBlo
<LinkedIssues issues={contribution.linkedIssues} />
<RewardedCardWrapper contribution={contribution} recipientIds={recipientIds} />
<Description description={contribution.githubBody} />
{/*// Timeline*/}
<Timeline id={contribution.id} />
</>
);
}
Expand All @@ -172,7 +170,7 @@ function useContributionBlocksAsContributor({ contribution }: UseContributionBlo
user={contribution.mergedBy}
/>
<Description description={contribution.githubBody} />
{/*// Timeline*/}
<Timeline id={contribution.id} />
</>
);
}
Expand Down