Skip to content

Commit e625f48

Browse files
committed
fix: after rebase
1 parent 6fdaf25 commit e625f48

File tree

4 files changed

+34
-63
lines changed

4 files changed

+34
-63
lines changed

src/components/v5/common/CompletedAction/partials/PaymentBuilder/partials/PaymentBuilderTable/PaymentBuilderTable.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ const PaymentBuilderTable: FC<PaymentBuilderTableProps> = ({
304304
return [...populatedItems, ...placeholderItems];
305305
}, [expendituresGlobalClaimDelay, items, expectedNumberOfPayouts]);
306306

307-
const newDataWithChanges = useMemo(() => {
307+
const dataWithChanges = useMemo(() => {
308308
if (!expenditureSlotChanges) {
309309
return data.sort((a, b) => a.id - b.id);
310310
}
@@ -352,14 +352,14 @@ const PaymentBuilderTable: FC<PaymentBuilderTableProps> = ({
352352
];
353353
}, [expenditureSlotChanges, data]);
354354

355-
const filteredData = newDataWithChanges.filter((item) =>
355+
const filteredData = dataWithChanges.filter((item) =>
356356
BigNumber.from(item.amount).gt(0),
357357
);
358358

359-
const dataToShow = isEditStepActive ? newDataWithChanges : filteredData;
359+
const dataToShow = isEditStepActive ? dataWithChanges : filteredData;
360360

361361
const columns = useGetPaymentBuilderColumns({
362-
data: newDataWithChanges,
362+
data: dataWithChanges,
363363
status,
364364
slots: items,
365365
finalizedTimestamp,
@@ -383,14 +383,17 @@ const PaymentBuilderTable: FC<PaymentBuilderTableProps> = ({
383383

384384
if (isEditStepActive && tableRefCurrent) {
385385
const tableRows = tableRefCurrent.querySelectorAll('tbody > tr');
386+
const expandedRows = tableRefCurrent.querySelectorAll(
387+
'tbody > tr.expanded-below',
388+
);
386389
const tableBodys = tableRefCurrent.querySelectorAll('tbody');
387390

388-
const changedItemsCount = newDataWithChanges.filter(
391+
const changedItemsCount = dataWithChanges.filter(
389392
(item) => item.newValues,
390393
).length;
391394
const lastChangedTableRow =
392395
tableRows[changedItemsCount + expandedRowsIds.length - 1];
393-
const hasAllRowsChanged = changedItemsCount === newDataWithChanges.length;
396+
const hasAllRowsChanged = changedItemsCount === dataWithChanges.length;
394397
const rowsBeforeLastChanged = Array.from(tableRows).slice(
395398
0,
396399
changedItemsCount - 1,
@@ -402,7 +405,7 @@ const PaymentBuilderTable: FC<PaymentBuilderTableProps> = ({
402405
});
403406
}
404407

405-
const editedRowsLength = changedItemsCount + expandedRowsIds.length;
408+
const editedRowsLength = changedItemsCount + expandedRows.length;
406409
setAllRowsChanged(hasAllRowsChanged);
407410

408411
if (isTablet) {
@@ -417,8 +420,12 @@ const PaymentBuilderTable: FC<PaymentBuilderTableProps> = ({
417420
tableRows.forEach((row, index) => {
418421
if (index < editedRowsLength) {
419422
row.classList.add('edited');
423+
if (index === editedRowsLength - 1) {
424+
row.classList.add('last-expanded-row');
425+
}
420426
} else {
421427
row.classList.remove('edited');
428+
row.classList.remove('last-expanded-row');
422429
}
423430
});
424431
}
@@ -475,13 +482,14 @@ const PaymentBuilderTable: FC<PaymentBuilderTableProps> = ({
475482
'last-row',
476483
'edited',
477484
'tablet-edited',
485+
'last-expanded-row',
478486
);
479487
});
480488
};
481489
}
482490

483491
return () => {};
484-
}, [isEditStepActive, newDataWithChanges, expandedRowsIds, isTablet]);
492+
}, [isEditStepActive, dataWithChanges, expandedRowsIds, isTablet]);
485493

486494
return (
487495
<div className="mt-7" ref={tableRef}>
@@ -515,7 +523,7 @@ const PaymentBuilderTable: FC<PaymentBuilderTableProps> = ({
515523
!isTablet && allRowsChanged,
516524
},
517525
{
518-
'[&_tr.last-edited-row>td]:border-b-1 [&_tr.last-edited-row>td]:border [&_tr.last-edited-row>td]:border-l-0 [&_tr.last-edited-row>td]:border-r-0 [&_tr.last-edited-row>td]:border-t-0 [&_tr.last-edited-row>td]:border-blue-400':
526+
'[&_tr.last-expanded-row>td]:border-b-1 [&_tr.last-expanded-row>td]:border [&_tr.last-expanded-row>td]:border-l-0 [&_tr.last-expanded-row>td]:border-r-0 [&_tr.last-expanded-row>td]:border-t-0 [&_tr.last-expanded-row>td]:border-blue-400':
519527
!isTablet && !allRowsChanged,
520528
},
521529
)}

src/components/v5/common/CompletedAction/partials/PaymentBuilder/partials/PaymentBuilderWidget/PaymentBuilderWidget.tsx

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useAppContext } from '~context/AppContext/AppContext.ts';
77
import { useColonyContext } from '~context/ColonyContext/ColonyContext.ts';
88
import { usePaymentBuilderContext } from '~context/PaymentBuilderContext/PaymentBuilderContext.ts';
99
import {
10+
type ColonyActionFragment,
1011
ExpenditureStatus,
1112
ExpenditureType,
1213
useGetColonyExpendituresQuery,
@@ -18,8 +19,7 @@ import { type LockExpenditurePayload } from '~redux/sagas/expenditures/lockExpen
1819
import Numeral from '~shared/Numeral/Numeral.tsx';
1920
import SpinnerLoader from '~shared/Preloaders/SpinnerLoader.tsx';
2021
import { DecisionMethod } from '~types/actions.ts';
21-
import { type ColonyAction, type ExpenditureAction } from '~types/graphql.ts';
22-
import { type MultiSigAction } from '~types/motions.ts';
22+
import { type ExpenditureAction } from '~types/graphql.ts';
2323
import { notMaybe, notNull } from '~utils/arrays/index.ts';
2424
import { MotionState } from '~utils/colonyMotions.ts';
2525
import {
@@ -70,7 +70,6 @@ import {
7070
segregateFundingActions,
7171
segregateEditActions,
7272
} from './utils.ts';
73-
import MotionWidgetSkeleton from '~v5/shared/MotionWidgetSkeleton/MotionWidgetSkeleton.tsx';
7473

7574
const PaymentBuilderWidget: FC<PaymentBuilderWidgetProps> = ({ action }) => {
7675
const { colony, refetchColony } = useColonyContext();
@@ -390,15 +389,15 @@ const PaymentBuilderWidget: FC<PaymentBuilderWidgetProps> = ({ action }) => {
390389
<MotionBox transactionId={selectedFundingMotion.transactionHash} />
391390
)}
392391

393-
{selectedFundingMultiSig &&
394-
isMultiSig(selectedFundingAction as ColonyAction) && (
395-
<MultiSigFunding
396-
action={selectedFundingAction as MultiSigAction}
397-
onMultiSigRejected={() => {
398-
setExpectedStepKey(null);
399-
}}
400-
/>
401-
)}
392+
{selectedFundingMultiSig && selectedFundingAction.multiSigData && (
393+
<MultiSigFunding
394+
action={selectedFundingAction as ColonyActionFragment}
395+
onMultiSigRejected={() => {
396+
setExpectedStepKey(null);
397+
}}
398+
multiSigData={selectedFundingAction.multiSigData}
399+
/>
400+
)}
402401

403402
{selectedFundingAction &&
404403
isSelectedActionInCurrentActions &&
@@ -536,42 +535,6 @@ const PaymentBuilderWidget: FC<PaymentBuilderWidgetProps> = ({ action }) => {
536535
),
537536
};
538537

539-
const getFundingStepContent = () => {
540-
if (selectedFundingMotion) {
541-
return (
542-
<MotionBox transactionId={selectedFundingMotion.transactionHash} />
543-
);
544-
}
545-
// since the multisig widget doesn't fetch its own action we need to handle the loader here
546-
if (selectedFundingMultiSig) {
547-
if (loadingAction || !fundingAction) {
548-
return <MotionWidgetSkeleton />;
549-
}
550-
551-
if (fundingAction && fundingAction.multiSigData) {
552-
return (
553-
<MultiSigFunding
554-
action={fundingAction}
555-
multiSigData={fundingAction.multiSigData}
556-
onMultiSigRejected={() => {
557-
setExpectedStepKey(null);
558-
}}
559-
/>
560-
);
561-
}
562-
563-
console.warn(
564-
"The provided assumed multiSig action doesn't pass the type guard, something is wrong",
565-
);
566-
return null;
567-
}
568-
569-
if (selectedFundingAction) {
570-
return <ActionWithPermissionsInfo action={selectedFundingAction} />;
571-
}
572-
return null;
573-
};
574-
575538
const items: StepperItem<ExpenditureStep>[] = [
576539
{
577540
key: ExpenditureStep.Create,

src/context/PaymentBuilderContext/PaymentBuilderContext.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ export const PaymentBuilderContext = createContext<{
5555
selectedFinalizeAction: null,
5656
setSelectedFinalizeAction: noop,
5757
setSelectedReleaseAction: noop,
58-
selectedMilestones: [],
59-
setSelectedMilestones: noop,
6058
selectedEditingAction: null,
6159
setSelectedEditingAction: noop,
6260
currentStep: null,

src/context/PaymentBuilderContext/PaymentBuilderContextProvider.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ const PaymentBuilderContextProvider: FC<PropsWithChildren> = ({ children }) => {
4747
ExpenditureType | undefined
4848
>(undefined);
4949

50+
const [selectedEditingAction, setSelectedEditingAction] =
51+
useState<ExpenditureAction | null>(null);
52+
const [currentStep, setCurrentStep] = useState<
53+
ExpenditureStep | string | null
54+
>(null);
55+
5056
const value = useMemo(
5157
() => ({
5258
toggleOnFundingModal,
@@ -65,8 +71,6 @@ const PaymentBuilderContextProvider: FC<PropsWithChildren> = ({ children }) => {
6571
selectedExpenditureMotion: null,
6672
expectedStepKey,
6773
setExpectedStepKey,
68-
selectedMilestones,
69-
setSelectedMilestones,
7074
selectedEditingAction,
7175
setSelectedEditingAction,
7276
currentStep,
@@ -93,8 +97,6 @@ const PaymentBuilderContextProvider: FC<PropsWithChildren> = ({ children }) => {
9397
expectedExpenditureType,
9498
isReleaseModalOpen,
9599
expectedStepKey,
96-
selectedMilestones,
97-
setSelectedMilestones,
98100
selectedEditingAction,
99101
setSelectedEditingAction,
100102
currentStep,

0 commit comments

Comments
 (0)