Skip to content

Commit d4f0dcd

Browse files
committed
feat: add edit to payment builder action
1 parent 03c80d5 commit d4f0dcd

File tree

37 files changed

+2277
-284
lines changed

37 files changed

+2277
-284
lines changed

src/components/v5/common/ActionSidebar/ActionSidebar.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const ActionSidebar: FC<PropsWithChildren<ActionSidebarProps>> = ({
6565
} = useGetActionData(transactionId);
6666

6767
const {
68+
isEditMode,
6869
actionSidebarToggle: [
6970
isActionSidebarOpen,
7071
{ toggle: toggleActionSidebarOff, registerContainerRef },
@@ -262,7 +263,7 @@ const ActionSidebar: FC<PropsWithChildren<ActionSidebarProps>> = ({
262263
ref={registerContainerRef}
263264
>
264265
<div className="relative">
265-
<div className="flex w-full items-center justify-between border-b border-gray-200 px-6 py-4">
266+
<div className="flex w-full items-center justify-between px-6 py-4">
266267
<div className="flex items-center gap-2">
267268
<button
268269
type="button"
@@ -293,6 +294,7 @@ const ActionSidebar: FC<PropsWithChildren<ActionSidebarProps>> = ({
293294
!isMotion &&
294295
!isMultiSig &&
295296
!expenditure &&
297+
!isEditMode &&
296298
!loadingExpenditure && (
297299
<PillsBase
298300
className="bg-success-100 text-success-400"
@@ -310,6 +312,25 @@ const ActionSidebar: FC<PropsWithChildren<ActionSidebarProps>> = ({
310312
{(!!isMotion || !!isMultiSig) && motionState && (
311313
<MotionOutcomeBadge motionState={motionState} />
312314
)}
315+
{!!expenditure && isEditMode && (
316+
<Tooltip
317+
tooltipContent={
318+
<span className="font-medium">
319+
{formatText({
320+
id: 'expenditure.edit.tooltip',
321+
})}
322+
</span>
323+
}
324+
placement="bottom-start"
325+
>
326+
<PillsBase
327+
className="bg-warning-100 text-warning-400"
328+
isCapitalized={false}
329+
>
330+
{formatText({ id: 'badge.edit' })}
331+
</PillsBase>
332+
</Tooltip>
333+
)}
313334
</div>
314335
)}
315336
{isMobile && getShareButton()}

src/components/v5/common/ActionSidebar/partials/ActionSidebarContent/ActionSidebarContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ const ActionSidebarContent: FC<ActionSidebarContentProps> = ({
283283

284284
return (
285285
<div
286-
className={clsx('flex w-full flex-grow', {
286+
className={clsx('flex w-full flex-grow border-t border-gray-200', {
287287
'flex-col-reverse overflow-auto sm:overflow-hidden md:flex-row':
288288
!!transactionId,
289289
'overflow-hidden': !transactionId,

src/components/v5/common/ActionSidebar/partials/Motions/Motions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ const Motions: FC<MotionsProps> = ({ transactionId }) => {
339339
>
340340
<Stepper<Steps>
341341
activeStepKey={activeStepKey}
342-
setActiveStepKey={setActiveStepKey}
342+
setActiveStepKey={(key: Steps) => setActiveStepKey(key)}
343343
items={items}
344344
/>
345345
</MotionProvider>

src/components/v5/common/ActionSidebar/partials/MultiSigSidebar/partials/MultiSigWidget/MultiSigWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const MultiSigWidget: FC<MultiSigWidgetProps> = ({ action }) => {
146146
<Stepper<MultiSigState>
147147
items={items}
148148
activeStepKey={activeStepKey}
149-
setActiveStepKey={setActiveStepKey}
149+
setActiveStepKey={(key: MultiSigState) => setActiveStepKey(key)}
150150
/>
151151
</div>
152152
);

src/components/v5/common/CompletedAction/CompletedAction.tsx

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import clsx from 'clsx';
22
import React from 'react';
33

4+
import { useActionSidebarContext } from '~context/ActionSidebarContext/ActionSidebarContext.ts';
45
import { useColonyContext } from '~context/ColonyContext/ColonyContext.ts';
56
import { ColonyActionType } from '~gql';
67
import { ExtendedColonyActionType } from '~types/actions.ts';
@@ -14,12 +15,14 @@ import MultiSigSidebar from '../ActionSidebar/partials/MultiSigSidebar/MultiSigS
1415
import AddVerifiedMembers from './partials/AddVerifiedMembers/index.ts';
1516
import CreateDecision from './partials/CreateDecision/index.ts';
1617
import EditColonyDetails from './partials/EditColonyDetails/index.ts';
18+
import ExitEditModeModal from './partials/ExitEditModeModal/ExitEditModeModal.tsx';
1719
import ManageReputation from './partials/ManageReputation/index.ts';
1820
import ManageTeam from './partials/ManageTeam/index.ts';
1921
import ManageTokens from './partials/ManageTokens/ManageTokens.tsx';
2022
import MintTokens from './partials/MintTokens/index.ts';
2123
import PaymentBuilderWidget from './partials/PaymentBuilder/partials/PaymentBuilderWidget/PaymentBuilderWidget.tsx';
2224
import PaymentBuilder from './partials/PaymentBuilder/PaymentBuilder.tsx';
25+
import PaymentBuilderEdit from './partials/PaymentBuilderEdit/PaymentBuilderEdit.tsx';
2326
import RemoveVerifiedMembers from './partials/RemoveVerifiedMembers/index.ts';
2427
import SetUserRoles from './partials/SetUserRoles/index.ts';
2528
import SimplePayment from './partials/SimplePayment/index.ts';
@@ -39,6 +42,13 @@ const CompletedAction = ({ action }: CompletedActionProps) => {
3942
const { colony } = useColonyContext();
4043

4144
const actionType = getExtendedActionType(action, colony.metadata);
45+
const {
46+
isEditMode,
47+
cancelEditModalToggle: [
48+
isCancelModalOpen,
49+
{ toggleOff: toggleOffCancelModal },
50+
],
51+
} = useActionSidebarContext();
4252

4353
const getActionContent = () => {
4454
switch (actionType) {
@@ -156,36 +166,47 @@ const CompletedAction = ({ action }: CompletedActionProps) => {
156166
}
157167
};
158168

169+
const getEditContent = () => {
170+
switch (actionType) {
171+
case ColonyActionType.CreateExpenditure:
172+
return <PaymentBuilderEdit action={action} />;
173+
default:
174+
return <div>Not implemented yet</div>;
175+
}
176+
};
177+
159178
return (
160-
<div className="flex flex-grow flex-col-reverse justify-end overflow-auto sm:flex-row sm:justify-start">
161-
<div
162-
className={clsx('w-full overflow-y-auto px-6 pb-6 pt-8', {
163-
'sm:w-[calc(100%-23.75rem)]': action.isMotion,
164-
})}
165-
>
166-
{getActionContent()}
167-
</div>
179+
<>
180+
<div className="relative flex flex-grow flex-col-reverse justify-end overflow-auto sm:flex-row sm:justify-start">
181+
<div
182+
className={clsx(
183+
'w-full overflow-y-auto px-6 pb-6 pt-8 sm:border sm:border-gray-200',
184+
{
185+
'sm:w-[calc(100%-23.75rem)]': action.isMotion,
186+
'mb-[8.5rem] sm:mb-[5.5rem] sm:border-warning-400': isEditMode,
187+
'sm:border-b-0 sm:border-l-0': !isEditMode,
188+
},
189+
)}
190+
>
191+
{isEditMode ? getEditContent() : getActionContent()}
192+
</div>
168193

169-
<div
170-
className={`
171-
w-full
172-
border-b
173-
border-b-gray-200
174-
bg-gray-25
175-
px-6
176-
py-8
177-
sm:h-full
178-
sm:w-[23.75rem]
179-
sm:flex-shrink-0
180-
sm:overflow-y-auto
181-
sm:border-b-0
182-
sm:border-l
183-
sm:border-l-gray-200
184-
`}
185-
>
186-
{getSidebarWidgetContent()}
194+
<div
195+
className={clsx(
196+
'w-full border-b border-b-gray-200 bg-gray-25 px-6 py-8 sm:h-full sm:w-[23.75rem] sm:flex-shrink-0 sm:overflow-y-auto sm:border-b-0 sm:border-t sm:border-gray-200',
197+
{
198+
'border-b-warning-400': isEditMode,
199+
},
200+
)}
201+
>
202+
{getSidebarWidgetContent()}
203+
</div>
187204
</div>
188-
</div>
205+
<ExitEditModeModal
206+
isOpen={isCancelModalOpen}
207+
onClose={toggleOffCancelModal}
208+
/>
209+
</>
189210
);
190211
};
191212

0 commit comments

Comments
 (0)