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

hide deleted properties in proposal milestones #5184

Merged
merged 3 commits into from
Feb 19, 2025
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
1 change: 1 addition & 0 deletions components/[pageId]/DocumentPage/DocumentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
}
}
},
[router.query, showCard]

Check warning on line 201 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Test apps

React Hook useCallback has missing dependencies: 'insideModal', 'navigateToSpacePath', and 'updateURLQuery'. Either include them or remove the dependency array

Check warning on line 201 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Test apps

React Hook useCallback has missing dependencies: 'insideModal', 'navigateToSpacePath', and 'updateURLQuery'. Either include them or remove the dependency array

Check warning on line 201 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Test app

React Hook useCallback has missing dependencies: 'insideModal', 'navigateToSpacePath', and 'updateURLQuery'. Either include them or remove the dependency array

Check warning on line 201 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Validate code

React Hook useCallback has missing dependencies: 'insideModal', 'navigateToSpacePath', and 'updateURLQuery'. Either include them or remove the dependency array
);

function onConnectionEvent(event: ConnectionEvent) {
Expand All @@ -220,7 +220,7 @@
dispatch(blockLoad({ blockId: page.parentId as string }));
}
}
}, [page.id]);

Check warning on line 223 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Test apps

React Hook useEffect has missing dependencies: 'card', 'dispatch', 'page.parentId', and 'page?.type'. Either include them or remove the dependency array

Check warning on line 223 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Test apps

React Hook useEffect has missing dependencies: 'card', 'dispatch', 'page.parentId', and 'page?.type'. Either include them or remove the dependency array

Check warning on line 223 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Test app

React Hook useEffect has missing dependencies: 'card', 'dispatch', 'page.parentId', and 'page?.type'. Either include them or remove the dependency array

Check warning on line 223 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Validate code

React Hook useEffect has missing dependencies: 'card', 'dispatch', 'page.parentId', and 'page?.type'. Either include them or remove the dependency array

// reset error and sidebar state whenever page id changes
useEffect(() => {
Expand All @@ -246,7 +246,7 @@
printRef
});
}
}, [printRef, _printRef]);

Check warning on line 249 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Test apps

React Hook useEffect has a missing dependency: 'setPageProps'. Either include it or remove the dependency array

Check warning on line 249 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Test apps

React Hook useEffect has a missing dependency: 'setPageProps'. Either include it or remove the dependency array

Check warning on line 249 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Test app

React Hook useEffect has a missing dependency: 'setPageProps'. Either include it or remove the dependency array

Check warning on line 249 in components/[pageId]/DocumentPage/DocumentPage.tsx

View workflow job for this annotation

GitHub Actions / Validate code

React Hook useEffect has a missing dependency: 'setPageProps'. Either include it or remove the dependency array

const containerWidthRef = useRef<HTMLDivElement>(null);
const { width: containerWidth = 0 } = useResizeObserver({ ref: containerWidthRef });
Expand Down Expand Up @@ -465,6 +465,7 @@
<FormFieldAnswers
milestoneProps={{
containerWidth,
proposalCreatedAt: new Date(page.createdAt),
pendingRewards: proposal.fields?.pendingRewards || [],
requiredTemplateId: proposal.fields?.rewardsTemplateId,
reviewers: proposal.evaluations.map((e) => e.reviewers.filter((r) => !r.systemRole)).flat(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
requiredTemplateId?: string | null;
variant?: 'solid_button' | 'card_property'; // solid_button is used for form proposals
isProposalTemplate?: boolean;
proposalCreatedAt: Date;
};

export function ProposalRewardsTable({
Expand All @@ -55,13 +56,13 @@
assignedSubmitters,
requiredTemplateId,
variant,
isProposalTemplate
isProposalTemplate,
proposalCreatedAt
}: ProposalRewardsTableProps) {
const { space } = useCurrentSpace();
const { boardBlock, isLoading } = useRewardsBoard();
const { rewards: allRewards, isLoading: isLoadingRewards } = useRewards();
const { pages, loadingPages } = usePages();
const { navigateToSpacePath } = useCharmRouter();
const { getFeatureTitle } = useSpaceFeatures();
const {
createNewReward,
Expand All @@ -88,6 +89,14 @@
});
const { showPage } = usePageDialog();

// the date of the proposal is important for the board view to hide properties that were deleted before the proposal was created
const boardWithProposalCreatedAt = useMemo(() => {
return {
...boardBlock!,
createdAt: proposalCreatedAt.getTime()
};
}, [boardBlock, proposalCreatedAt]);

const tableView = useMemo(() => {
const rewardTypesUsed = (pendingRewards || []).reduce<Set<RewardType>>((acc, page) => {
if (page.reward.rewardType) {
Expand All @@ -96,12 +105,12 @@
return acc;
}, new Set());
return getProposalRewardsView({
board: boardBlock,
board: boardWithProposalCreatedAt,
spaceId: space?.id,
rewardTypes: [...rewardTypesUsed],
includeStatus: rewardIds.length > 0
});
}, [space?.id, boardBlock, pendingRewards, rewardIds.length]);
}, [space?.id, pendingRewards, boardWithProposalCreatedAt, rewardIds.length]);

const publishedRewards = useMemo(
() => rewardIds.map((rId) => allRewards?.find((r) => r.id === rId)).filter(isTruthy),
Expand All @@ -112,7 +121,7 @@
publishedRewards.length > 0
? getCardsFromPublishedRewards(publishedRewards, pages, space?.domain)
: getCardsFromPendingRewards(pendingRewards || [], space?.id, space?.domain),
[pendingRewards, space?.id, pages, publishedRewards]

Check warning on line 124 in components/proposals/ProposalPage/components/ProposalProperties/components/ProposalRewards/ProposalRewardsTable.tsx

View workflow job for this annotation

GitHub Actions / Test apps

React Hook useMemo has a missing dependency: 'space?.domain'. Either include it or remove the dependency array

Check warning on line 124 in components/proposals/ProposalPage/components/ProposalProperties/components/ProposalRewards/ProposalRewardsTable.tsx

View workflow job for this annotation

GitHub Actions / Test apps

React Hook useMemo has a missing dependency: 'space?.domain'. Either include it or remove the dependency array

Check warning on line 124 in components/proposals/ProposalPage/components/ProposalProperties/components/ProposalRewards/ProposalRewardsTable.tsx

View workflow job for this annotation

GitHub Actions / Test app

React Hook useMemo has a missing dependency: 'space?.domain'. Either include it or remove the dependency array

Check warning on line 124 in components/proposals/ProposalPage/components/ProposalProperties/components/ProposalRewards/ProposalRewardsTable.tsx

View workflow job for this annotation

GitHub Actions / Validate code

React Hook useMemo has a missing dependency: 'space?.domain'. Either include it or remove the dependency array
);

const canCreatePendingRewards = !readOnly && !publishedRewards.length;
Expand Down Expand Up @@ -158,7 +167,7 @@
boardType='rewards'
hideCalculations
setSelectedPropertyId={() => {}}
board={boardBlock!}
board={boardWithProposalCreatedAt}
activeView={tableView}
cards={cards}
views={[]}
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions stories/ProposalsPage/ProposalRewards.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function ProposalRewards() {
pendingRewards={pendingRewards}
reviewers={[]}
assignedSubmitters={[]}
proposalCreatedAt={new Date()}
variant='solid_button'
isProposalTemplate={true}
rewardIds={[]}
Expand Down
Loading