Skip to content

Commit

Permalink
Merge branch 'main' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelfact committed Oct 23, 2024
2 parents cbfc178 + 499d940 commit 6114aaf
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 43 deletions.
6 changes: 3 additions & 3 deletions app/hackathons/features/issues-wrapper/issues-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ export function IssuesWrapper({ projectId, hackathonId, queryParams, Wrapper = F
key={issue.id}
title={issue.title}
githubLink={issue.htmlUrl}
status={issue.getApplicationStatus()}
status={issue.getApplicationStatus(user?.githubUserId ?? 0)}
applyActionProps={{
onClick: () =>
handleOpenDrawer({
issueId: issue.id,
applicationId: issue.currentUserApplication?.id ?? "",
applicationId: issue.getCurrentUserApplicationId(user?.githubUserId ?? 0) ?? "",
projectId,
}),
children: <Translate token="v2.pages.hackathons.details.issues.card.apply" />,
Expand All @@ -95,7 +95,7 @@ export function IssuesWrapper({ projectId, hackathonId, queryParams, Wrapper = F
onClick: () =>
handleOpenDrawer({
issueId: issue.id,
applicationId: issue.currentUserApplication?.id ?? "",
applicationId: issue.getCurrentUserApplicationId(user?.githubUserId ?? 0) ?? "",
projectId,
}),
children: <Translate token="v2.pages.hackathons.details.issues.card.viewApplication" />,
Expand Down
3 changes: 3 additions & 0 deletions app/p/[slug]/applications/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Flex from "src/components/Utils/Flex";
import { getOrgsWithUnauthorizedRepos } from "src/utils/getOrgsWithUnauthorizedRepos";

import { withLeadRequired } from "components/features/auth0/guards/lead-guard";
import { NewAppHelper } from "components/features/new-app-helper/new-app-helper";
import { PosthogOnMount } from "components/features/posthog/components/posthog-on-mount/posthog-on-mount";
import { withClientOnly } from "components/layout/client-only/client-only";

Expand Down Expand Up @@ -45,6 +46,8 @@ function ProjectApplicationsPage() {
) : null}
</div>

<NewAppHelper projectSlug={slug} />

{!project?.indexingComplete && !isLoadingProject ? <StillFetchingBanner /> : null}

{project && hasOrgsWithUnauthorizedRepos ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ import { Typography } from "components/layout/typography/typography";

import { NEXT_ROUTER } from "constants/router";

import { useCurrentUser } from "hooks/users/use-current-user/use-current-user";

import { ApplyButton } from "./components/apply-button/apply-button";
import { TIssueCard } from "./issue-card.types";

export function IssueCard({ issue, onDrawerOpen }: TIssueCard.Props) {
const isMd = useMediaQuery(`(min-width: ${viewportConfig.breakpoints.md}px)`);
const { user } = useCurrentUser();

const hasApplied = Boolean(issue.currentUserApplication);
const hasApplied = Boolean(issue.applicants.find(applicant => applicant.githubUserId === user?.githubUserId));

const {
clientBootstrap: { authProvider },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { Flex } from "components/layout/flex/flex";
import { Icon } from "components/layout/icon/icon";
import { Typography } from "components/layout/typography/typography";

import { useCurrentUser } from "hooks/users/use-current-user/use-current-user";

import { EmptyState } from "./components/empty-state/empty-state";
import { IssueCard } from "./components/issue-card/issue-card";
import { TGoodFirstIssues } from "./good-first-issues.types";
Expand All @@ -20,6 +22,8 @@ export function GoodFirstIssues({ projectId }: TGoodFirstIssues.Props) {
const applyIssueDrawerState = useApplyIssueDrawerState();
const [, setApplyIssueDrawerState] = applyIssueDrawerState;

const { user } = useCurrentUser();

const { data, isLoading, isError, hasNextPage, fetchNextPage, isFetchingNextPage } =
ProjectApi.queries.useProjectGoodFirstIssuesInfiniteList({
params: { projectId },
Expand Down Expand Up @@ -57,7 +61,8 @@ export function GoodFirstIssues({ projectId }: TGoodFirstIssues.Props) {
setApplyIssueDrawerState({
isOpen: true,
issueId: issue.id,
applicationId: issue.currentUserApplication?.id ?? "",
applicationId: issue.applicants.find(applicant => applicant.githubUserId === user?.githubUserId)
?.applicationId,
});
}}
/>
Expand Down
29 changes: 29 additions & 0 deletions components/features/new-app-helper/new-app-helper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { BaseLink } from "components/layout/base-link/base-link";
import { Helper } from "components/molecules/helper";

export function NewAppHelper({ projectSlug }: { projectSlug: string }) {
return (
<Helper
title={{
translate: {
token: "v2.features.banners.newApp.title",
},
}}
text={{
translate: {
token: "v2.features.banners.newApp.text",
},
}}
endButton={{
as: BaseLink,
htmlProps: {
href: "https://admin.onlydust.com/manage-projects/" + projectSlug,
},
variant: "primary",
translate: {
token: "v2.features.banners.newApp.button",
},
}}
/>
);
}
12 changes: 7 additions & 5 deletions components/molecules/helper/adapters/default/default.adapter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ export function HelperDefaultAdapter<C extends ElementType = "div">({

return (
<Component {...htmlProps} className={cn(slots.base(), classNames?.base)}>
{startContent}
<RenderWithProps Component={Avatar} props={avatar} overrideProps={{ size: "xl", shape: "square" }} />
<div className="flex flex-col items-start justify-start gap-1">
<RenderWithProps Component={Typo} props={title} overrideProps={{ size: "m", variant: "brand" }} />
<RenderWithProps Component={Typo} props={text} overrideProps={{ size: "s" }} />
<div className={"flex gap-4"}>
{startContent}
<RenderWithProps Component={Avatar} props={avatar} overrideProps={{ size: "xl", shape: "square" }} />
<div className="flex flex-col items-start justify-start gap-1">
<RenderWithProps Component={Typo} props={title} overrideProps={{ size: "m", variant: "brand" }} />
<RenderWithProps Component={Typo} props={text} overrideProps={{ size: "s" }} />
</div>
</div>
<div className={cn(slots.endContainer(), classNames?.endContainer)}>
<RenderWithProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { tv } from "tailwind-variants";

export const HelperDefaultVariants = tv({
slots: {
base: "flex h-auto w-full flex-row gap-4 rounded-xl bg-brand-1 p-4 text-text-1",
base: "flex h-auto w-full flex-col gap-4 rounded-xl bg-brand-1 p-4 text-text-1",
endContainer: "flex flex-1 flex-row items-center justify-end gap-3",
},
variants: {
Expand Down
18 changes: 11 additions & 7 deletions core/domain/issue/models/issue-list-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { components } from "src/__generated/api";
export type GithubIssueListItemResponse = components["schemas"]["GithubIssuePageItemResponse"];

export interface IssueListInterface extends GithubIssueListItemResponse {
getApplicationStatus(): IssueApplicationStatus;
getApplicationStatus(githubUserId: number): IssueApplicationStatus;
isAssigned(): boolean;
isApplied(): boolean;
isUserApplied(githubUserId: number): boolean;
getFirstAssignee(): GithubIssueListItemResponse["assignees"][0];
getCurrentUserApplicationId(githubUserId: number): string;
}
export class IssueList implements IssueListInterface {
applicants!: GithubIssueListItemResponse["applicants"];
Expand All @@ -17,7 +18,6 @@ export class IssueList implements IssueListInterface {
body!: GithubIssueListItemResponse["body"];
closedAt!: GithubIssueListItemResponse["closedAt"];
createdAt!: GithubIssueListItemResponse["createdAt"];
currentUserApplication!: GithubIssueListItemResponse["currentUserApplication"];
htmlUrl!: GithubIssueListItemResponse["htmlUrl"];
id!: GithubIssueListItemResponse["id"];
labels!: GithubIssueListItemResponse["labels"];
Expand All @@ -34,16 +34,20 @@ export class IssueList implements IssueListInterface {
return this.assignees.length > 0;
}

isApplied(): boolean {
return !!this.currentUserApplication;
isUserApplied(githubUserId: number): boolean {
return this.applicants.some(applicant => applicant.githubUserId === githubUserId);
}

getApplicationStatus(): IssueApplicationStatus {
getCurrentUserApplicationId(githubUserId: number): string {
return this.applicants.find(applicant => applicant.githubUserId === githubUserId)?.applicationId ?? "";
}

getApplicationStatus(githubUserId: number): IssueApplicationStatus {
if (this.isAssigned()) {
return "assigned";
}

if (this.isApplied()) {
if (this.isUserApplied(githubUserId)) {
return "applied";
}

Expand Down
25 changes: 0 additions & 25 deletions core/domain/issue/models/issue-model.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/_pages/ProjectDetails/Contributions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import CheckboxCircleLine from "src/icons/CheckboxCircleLine";
import { ContributionStatus, OrderBy } from "src/types";
import { getOrgsWithUnauthorizedRepos } from "src/utils/getOrgsWithUnauthorizedRepos";

import { NewAppHelper } from "components/features/new-app-helper/new-app-helper";
import { PosthogOnMount } from "components/features/posthog/components/posthog-on-mount/posthog-on-mount";
import { Icon } from "components/layout/icon/icon";
import { Translate } from "components/layout/translate/translate";
Expand Down Expand Up @@ -225,6 +226,8 @@ export default function Contributions() {
) : null}
</div>

<NewAppHelper projectSlug={slug} />

{!project?.indexingComplete && !isLoadingProject ? <StillFetchingBanner /> : null}

{project && hasOrgsWithUnauthorizedRepos ? (
Expand Down
3 changes: 3 additions & 0 deletions src/_pages/ProjectDetails/Contributors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { RewardDisabledReason } from "src/types";
import { getOrgsWithUnauthorizedRepos } from "src/utils/getOrgsWithUnauthorizedRepos";

import { Card } from "components/ds/card/card";
import { NewAppHelper } from "components/features/new-app-helper/new-app-helper";
import { PosthogOnMount } from "components/features/posthog/components/posthog-on-mount/posthog-on-mount";
import { EmptyState } from "components/layout/placeholders/empty-state/empty-state";

Expand Down Expand Up @@ -127,6 +128,8 @@ export default function Contributors() {
</div>
</Title>

{isProjectLeader ? <NewAppHelper projectSlug={slug} /> : null}

{!project?.indexingComplete ? <StillFetchingBanner /> : null}

{isProjectLeader && hasOrgsWithUnauthorizedRepos ? (
Expand Down
3 changes: 3 additions & 0 deletions src/_pages/ProjectDetails/Rewards/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Skeleton from "src/components/Skeleton";
import Flex from "src/components/Utils/Flex";
import { getOrgsWithUnauthorizedRepos } from "src/utils/getOrgsWithUnauthorizedRepos";

import { NewAppHelper } from "components/features/new-app-helper/new-app-helper";
import { PosthogOnMount } from "components/features/posthog/components/posthog-on-mount/posthog-on-mount";
import { EmptyState } from "components/layout/placeholders/empty-state/empty-state";

Expand Down Expand Up @@ -141,6 +142,8 @@ const RewardList: React.FC = () => {
) : null}
</div>

<NewAppHelper projectSlug={slug} />

{project && !project?.indexingComplete ? <StillFetchingBanner /> : null}

{hasOrgsWithUnauthorizedRepos ? (
Expand Down
5 changes: 5 additions & 0 deletions translations/v2/en/features/banners.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,10 @@
"hasToUpdatePayoutPreferencesDescription": "Please update your payout preferences to another billing profile (self-employed or organisation) to receive new rewards.",
"addBillingProfileButtonLabel": "Add new billing profile",
"updatePayoutPreferencesButtonLabel": "Update payout preferences"
},
"newApp": {
"title": "Discover the New Project Management Interface",
"text": "Streamline your project management with our new interface designed specifically for maintainers. Easily manage your contributors, track contributions, review applicants, and allocate rewards all in one place.",
"button": "Go to new app"
}
}

0 comments on commit 6114aaf

Please sign in to comment.