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

Remove IssueReference and IssueDependency logic #3031

Closed
wants to merge 3 commits into from
Closed
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 @@ -5,13 +5,7 @@ import HowItWorks from '@/components/Pledge/HowItWorks'
import IssueCard from '@/components/Pledge/IssueCard'
import PledgeCheckoutPanel from '@/components/Pledge/PledgeCheckoutPanel'
import { useTrafficRecordPageView } from '@/utils/traffic'
import {
Issue,
Pledger,
PullRequest,
RewardsSummary,
Visibility,
} from '@polar-sh/sdk'
import { Issue, Pledger, RewardsSummary, Visibility } from '@polar-sh/sdk'
import { WhiteCard } from 'polarkit/components/ui/Cards'
import { Banner } from 'polarkit/components/ui/molecules'
import posthog from 'posthog-js'
Expand All @@ -23,14 +17,12 @@ const ClientPage = ({
pledgers,
gotoURL,
rewards,
pullRequests,
}: {
issue: Issue
htmlBody?: string
pledgers: Pledger[]
gotoURL?: string
rewards?: RewardsSummary
pullRequests?: PullRequest[]
}) => {
useTrafficRecordPageView({ organization: issue.repository.organization })

Expand Down Expand Up @@ -70,7 +62,6 @@ const ClientPage = ({
pledgers={pledgers}
currentPledgeAmount={amount}
rewards={rewards}
pullRequests={pullRequests}
/>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,47 +189,6 @@ export const PullRequests: Story = {
...issue,
upfront_split_to_contributors: 75,
},
pullRequests: [
{
id: 'x',
number: 123,
title: 'I am a pull request! Here we gooooooooo!',
additions: 500,
deletions: 200,
is_merged: false,
is_closed: false,
},
{
id: 'x',
number: 12322,
title: 'I am a merged pull request!',
additions: 500,
deletions: 200,
is_merged: true,
is_closed: true,
author: {
login: 'baz',
html_url: 'x',
id: 132,
avatar_url: 'https://avatars.githubusercontent.com/u/47952?v=4',
},
},
{
id: 'x',
number: 12322,
title: 'I am a closed pull request!',
additions: 10,
deletions: 200,
is_merged: false,
is_closed: true,
author: {
login: 'baz',
html_url: 'x',
id: 132,
avatar_url: 'https://avatars.githubusercontent.com/u/47952?v=4',
},
},
],
},
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { getServerSideAPI } from '@/utils/api'
import { redirectToCanonicalDomain } from '@/utils/nav'
import {
Issue,
Pledger,
PullRequest,
ResponseError,
RewardsSummary,
} from '@polar-sh/sdk'
import { Issue, Pledger, ResponseError, RewardsSummary } from '@polar-sh/sdk'
import { Metadata, ResolvingMetadata } from 'next'
import { headers } from 'next/headers'
import { notFound } from 'next/navigation'
Expand Down Expand Up @@ -81,7 +75,6 @@ export default async function Page({
let issueHTMLBody: string | undefined
let pledgers: Pledger[] = []
let rewards: RewardsSummary | undefined
let pulls: PullRequest[] = []

const api = getServerSideAPI()

Expand All @@ -93,20 +86,17 @@ export default async function Page({
cacheConfig,
)

const [bodyResponse, pledgeSummary, rewardsSummary, pullRequests] =
await Promise.all([
api.issues.getBody({ id: issue.id }, { next: { revalidate: 60 } }), // Cache for 60s
api.pledges.summary({ issueId: issue.id }, cacheConfig),
api.rewards.summary({ issueId: issue.id }, cacheConfig),
api.pullRequests.search({ referencesIssueId: issue.id }, cacheConfig),
])
const [bodyResponse, pledgeSummary, rewardsSummary] = await Promise.all([
api.issues.getBody({ id: issue.id }, { next: { revalidate: 60 } }), // Cache for 60s
api.pledges.summary({ issueId: issue.id }, cacheConfig),
api.rewards.summary({ issueId: issue.id }, cacheConfig),
])

issueHTMLBody = bodyResponse
pledgers = pledgeSummary.pledges
.map(({ pledger }) => pledger)
.filter((p): p is Pledger => !!p)
rewards = rewardsSummary
pulls = pullRequests.items || []
} catch (e) {
if (e instanceof ResponseError && e.response.status === 404) {
notFound()
Expand All @@ -131,7 +121,6 @@ export default async function Page({
pledgers={pledgers}
rewards={rewards}
gotoURL={undefined}
pullRequests={pulls}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export default function ClientPage() {
<IssueListItem
key={ps[0].issue.id}
issue={ps[0].issue}
references={[]}
pledges={ps}
canAddRemovePolarLabel={false}
showLogo={true}
Expand All @@ -99,7 +98,6 @@ export default function ClientPage() {
<IssueListItem
key={ps[0].issue.id}
issue={ps[0].issue}
references={[]}
pledges={ps}
canAddRemovePolarLabel={false}
showLogo={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ const EmbedIssue = (props: { src: string }) => {
<div className="not-prose dark:bg-polar-800 border-bg-gray-100 dark:border:bg-polar-700 my-2 overflow-hidden rounded-2xl border bg-white">
<IssueListItem
issue={issue}
references={[]}
pledges={[]}
key={issue.id}
canAddRemovePolarLabel={false}
Expand Down
1 change: 0 additions & 1 deletion clients/apps/web/src/components/Feed/Recommended.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const Recommended = () => {
{issues.data?.items?.map((issue) => (
<IssueListItem
issue={issue}
references={[]}
pledges={[]}
key={issue.id}
canAddRemovePolarLabel={false}
Expand Down
29 changes: 4 additions & 25 deletions clients/apps/web/src/components/Finance/SplitRewardModal.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { useAuth } from '@/hooks'
import { Author, ConfirmIssueSplit } from '@polar-sh/sdk'
import {
useIssueMarkConfirmed,
useListPledesForIssue,
useListPullsReferencingIssue,
} from 'polarkit/hooks'
import { ConfirmIssueSplit } from '@polar-sh/sdk'
import { useIssueMarkConfirmed, useListPledesForIssue } from 'polarkit/hooks'
import { useState } from 'react'
import Spinner from '../Shared/Spinner'
import Split, { Contributor, Share } from './Split'
import SplitNotify from './SplitNotify'

const SplitRewardModal = (props: { issueId: string; onClose: () => void }) => {
const pledges = useListPledesForIssue(props.issueId)
const pulls = useListPullsReferencingIssue(props.issueId)

const { currentUser } = useAuth()

Expand Down Expand Up @@ -90,23 +85,7 @@ const SplitRewardModal = (props: { issueId: string; onClose: () => void }) => {
]
: []

const pullRequestContributors: Contributor[] = pulls.data?.items
? pulls.data.items
.map((pr) => pr.author)
.filter((a): a is Author => !!a)
.map((a) => {
return {
username: a.login,
avatar_url: a.avatar_url,
is_suggested_from_contributions: true,
}
})
: []

const contributors: Contributor[] = [
...selfOrgContributors,
...pullRequestContributors,
]
const contributors: Contributor[] = [...selfOrgContributors]

const tmpShares: Share[] = contributors.map((c) => {
return {
Expand All @@ -119,7 +98,7 @@ const SplitRewardModal = (props: { issueId: string; onClose: () => void }) => {
...new Map(tmpShares.map((item) => [item.username, item])).values(),
]

if (!pledges.isFetched || !pulls.isFetched) {
if (!pledges.isFetched) {
return <Spinner />
}

Expand Down
1 change: 0 additions & 1 deletion clients/apps/web/src/components/Issues/IssueList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ const IssueListPage = (props: {
{props.page.data.map((issue) => (
<IssueListItem
issue={issue.attributes}
references={issue.references || []}
pledges={issue.pledges || []}
pledgesSummary={issue.pledges_summary}
rewards={issue.rewards}
Expand Down
14 changes: 2 additions & 12 deletions clients/apps/web/src/components/Issues/IssueListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

import { ModalBox, Modal as ModernModal } from '@/components/Modal'
import { useToastLatestPledged } from '@/hooks/stripe'
import {
Issue,
IssueReferenceRead,
Pledge,
PledgesTypeSummaries,
Reward,
} from '@polar-sh/sdk'
import { Issue, Pledge, PledgesTypeSummaries, Reward } from '@polar-sh/sdk'
import { api } from 'polarkit/api'
import {
IssueActivityBox,
Expand All @@ -25,7 +19,6 @@ import { AddBadgeButton } from './IssuePromotionModal'

const IssueListItem = (props: {
issue: Issue
references: IssueReferenceRead[]
pledges: Array<Pledge>
pledgesSummary?: PledgesTypeSummaries
checkJustPledged?: boolean
Expand Down Expand Up @@ -55,8 +48,6 @@ const IssueListItem = (props: {
}

const havePledge = mergedPledges.length > 0
const haveReference = props.references && props.references?.length > 0
const havePledgeOrReference = havePledge || haveReference

const [showDisputeModalForPledge, setShowDisputeModalForPledge] = useState<
Pledge | undefined
Expand Down Expand Up @@ -96,13 +87,12 @@ const IssueListItem = (props: {
</>
}
/>
{havePledgeOrReference && (
{havePledge && (
<IssueActivityBox>
<IssueListItemDecoration
issue={props.issue}
pledges={mergedPledges}
pledgesSummary={props.pledgesSummary}
references={props.references}
showDisputeAction={true}
onDispute={onDispute}
showConfirmPledgeAction={true}
Expand Down
4 changes: 1 addition & 3 deletions clients/apps/web/src/components/Pledge/IssueCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react'

import { issue, issueBodyHTML, pledger, pullRequest } from 'polarkit/testdata'
import { issue, issueBodyHTML, pledger } from 'polarkit/testdata'
import IssueCard from './IssueCard'

const meta: Meta<typeof IssueCard> = {
Expand Down Expand Up @@ -272,7 +272,6 @@ export const RewardedSplitPulls: Story = {
},
],
},
pullRequests: [pullRequest, pullRequest],
},
}

Expand All @@ -284,6 +283,5 @@ export const Pulls: Story = {
issue: {
...issue,
},
pullRequests: [pullRequest, pullRequest],
},
}
6 changes: 0 additions & 6 deletions clients/apps/web/src/components/Pledge/IssueCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ const IssueCard = ({
pledgers,
currentPledgeAmount,
rewards,
pullRequests,
}: {
issue: Issue
htmlBody?: string
pledgers: Pledger[]
currentPledgeAmount: number
rewards?: RewardsSummary
pullRequests?: PullRequest[]
}) => {
const url = githubIssueUrl(
issue.repository.organization.name,
Expand Down Expand Up @@ -206,10 +204,6 @@ const IssueCard = ({
)}
</div>
) : null}

{pullRequests && pullRequests.length > 0 && (
<PullRequests pulls={pullRequests} />
)}
</div>
)
}
Expand Down
1 change: 0 additions & 1 deletion clients/apps/web/src/components/Pledge/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export const Status = (props: {
<IssueListItem
issue={pledge.issue}
pledges={[pledge]}
references={[]}
checkJustPledged={false}
canAddRemovePolarLabel={false}
showPledgeAction={true}
Expand Down
Loading
Loading