Skip to content

Commit

Permalink
fix: realign uninstalled extension warning to look the same at all steps
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubcolony committed Oct 29, 2024
1 parent 50c56ff commit 3b7c942
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,15 @@ const PaymentBuilderWidget: FC<PaymentBuilderWidgetProps> = ({ action }) => {
(motion) =>
!motion.isFinalized && !motion.motionStateHistory.hasFailedNotFinalizable,
);
const shouldShowFundingButton =
!isAnyFundingMotionInProgress && !isExpenditureFunded;

const shouldShowUninstalledExtensionBox =
isStagedExpenditure &&
const hasUninstalledExtension =
expenditure?.stagedExpenditureAddress &&
stagedExpenditureAddress !== expenditure.stagedExpenditureAddress;

const shouldShowFundingButton =
!isAnyFundingMotionInProgress &&
!isExpenditureFunded &&
!hasUninstalledExtension;

const {
motionState: releaseMotionState,
refetchMotionState: refetchReleaseMotionState,
Expand Down Expand Up @@ -309,7 +311,7 @@ const PaymentBuilderWidget: FC<PaymentBuilderWidgetProps> = ({ action }) => {
content:
expenditureStep === ExpenditureStep.Review ? (
<>
{shouldShowUninstalledExtensionBox ? (
{hasUninstalledExtension ? (
<UninstalledExtensionBox />
) : (
<StepDetailsBlock
Expand Down Expand Up @@ -371,71 +373,68 @@ const PaymentBuilderWidget: FC<PaymentBuilderWidgetProps> = ({ action }) => {
) : null,
},
content: (
<>
{shouldShowUninstalledExtensionBox ? (
<UninstalledExtensionBox />
) : (
<div className="flex flex-col gap-2">
{sortedFundingActions.length > 0 && (
<FundingRequests actions={sortedFundingActions} />
)}
<div className="flex flex-col gap-2">
{hasUninstalledExtension &&
expenditureStep === ExpenditureStep.Funding && (
<UninstalledExtensionBox />
)}

{selectedFundingMotion && (
<MotionBox
transactionId={selectedFundingMotion.transactionHash}
/>
)}
{sortedFundingActions.length > 0 && (
<FundingRequests actions={sortedFundingActions} />
)}

{selectedFundingAction && !selectedFundingMotion && (
<ActionWithPermissionsInfo action={selectedFundingAction} />
)}
{selectedFundingMotion && (
<MotionBox transactionId={selectedFundingMotion.transactionHash} />
)}

{shouldShowFundingButton && (
<StepDetailsBlock
text={formatText({
id: 'expenditure.fundingStage.info',
})}
content={
<>
{expectedStepKey === ExpenditureStep.Release ? (
<IconButton
className="w-full"
rounded="s"
text={{ id: 'button.pending' }}
icon={
<span className="ml-1.5 flex shrink-0">
<SpinnerGap className="animate-spin" size={14} />
</span>
}
/>
) : (
<Button
className="w-full"
onClick={showFundingModal}
text={formatText({
id: 'expenditure.fundingStage.button',
})}
/>
)}
</>
}
/>
)}
</div>
{selectedFundingAction && !selectedFundingMotion && (
<ActionWithPermissionsInfo action={selectedFundingAction} />
)}
</>

{shouldShowFundingButton && (
<StepDetailsBlock
text={formatText({
id: 'expenditure.fundingStage.info',
})}
content={
<>
{expectedStepKey === ExpenditureStep.Release ? (
<IconButton
className="w-full"
rounded="s"
text={{ id: 'button.pending' }}
icon={
<span className="ml-1.5 flex shrink-0">
<SpinnerGap className="animate-spin" size={14} />
</span>
}
/>
) : (
<Button
className="w-full"
onClick={showFundingModal}
text={formatText({
id: 'expenditure.fundingStage.button',
})}
/>
)}
</>
}
/>
)}
</div>
),
},
{
key: ExpenditureStep.Release,
heading: { label: formatText({ id: 'expenditure.releaseStage.label' }) },
content: (
<>
{shouldShowUninstalledExtensionBox ? (
<UninstalledExtensionBox />
) : (
{expenditureStep === ExpenditureStep.Release ? (
<>
{expenditureStep === ExpenditureStep.Release ? (
{hasUninstalledExtension ? (
<UninstalledExtensionBox />
) : (
<StepDetailsBlock
text={formatText({
id: 'expenditure.releaseStage.info',
Expand All @@ -451,25 +450,25 @@ const PaymentBuilderWidget: FC<PaymentBuilderWidgetProps> = ({ action }) => {
/>
}
/>
) : (
)}
</>
) : (
<>
{finalizedAt ? (
<>
{finalizedAt ? (
<>
{finalizingActions?.items[0]?.initiatorAddress ===
ownerAddress ? (
<FinalizeByPaymentCreatorInfo
userAdddress={expenditure?.ownerAddress}
/>
) : (
<ActionWithPermissionsInfo
action={finalizingActions?.items[0]}
/>
)}
</>
{finalizingActions?.items[0]?.initiatorAddress ===
ownerAddress ? (
<FinalizeByPaymentCreatorInfo
userAdddress={expenditure?.ownerAddress}
/>
) : (
<div />
<ActionWithPermissionsInfo
action={finalizingActions?.items[0]}
/>
)}
</>
) : (
<div />
)}
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,18 @@ const StagedPaymentStep: FC<StagedPaymentStepProps> = ({

return (
<>
{!isCorrectExtensionInstalled && (
<StepDetailsBlock
text={formatText(MSG.extensionUninstalled)}
content={
<div className="-m-[1.125rem] bg-negative-100 p-[1.125rem] text-sm text-negative-400">
{formatText(MSG.extensionDescription)}
</div>
}
/>
)}

<div className="flex flex-col gap-2">
{!isCorrectExtensionInstalled && (
<StepDetailsBlock
text={formatText(MSG.extensionUninstalled)}
content={
<div className="-m-[1.125rem] bg-negative-100 p-[1.125rem] text-sm text-negative-400">
{formatText(MSG.extensionDescription)}
</div>
}
/>
)}

{releaseActions.length > 0 && (
<ReleaseActions expenditure={expenditure} actions={releaseActions} />
)}
Expand Down

0 comments on commit 3b7c942

Please sign in to comment.