Skip to content

Commit 58906eb

Browse files
Merge remote-tracking branch 'upstream/main' into feature/LW-8937-Load-multi-delegation-logic-for-Ledger-device-using-experimental-feature-for-testing-only
2 parents 61e6498 + 660082b commit 58906eb

File tree

4 files changed

+37
-10
lines changed

4 files changed

+37
-10
lines changed

packages/common/src/analytics/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export enum PostHogAction {
7474
StakingBrowsePoolsStakePoolDetailStakeAllOnThisPoolClick = 'staking | browse pools | stake pool detail | stake all on this pool | click',
7575
StakingBrowsePoolsStakePoolDetailAddStakingPoolClick = 'staking | browse pools | stake pool detail | add staking pool | click',
7676
StakingBrowsePoolsStakePoolDetailUnselectPoolClick = 'staking | browse pools | stake pool detail | unselect pool | click',
77+
StakingBrowsePoolsStakePoolDetailManageDelegation = 'staking | browse pools | stake pool detail | manage delegation | click',
7778
StakingBrowsePoolsStakeClick = 'staking | browse pools | stake | click',
7879
StakingBrowsePoolsUnselectClick = 'staking | browse pools | unselect | click',
7980
StakingBrowsePoolsClearClick = 'staking | browse pools | clear | click',

packages/staking/src/features/Drawer/StakePoolDetail.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@ const makeActionButtons = (
209209
): ActionButtonSpec[] =>
210210
(
211211
[
212+
manageDelegation && {
213+
callback: tmpNoop,
214+
dataTestId: 'stake-pool-details-manage-delegation-btn',
215+
label: t('drawer.details.manageDelegation'),
216+
...getSpecOverride(manageDelegation),
217+
},
212218
stakeOnThisPool && {
213219
callback: tmpNoop,
214220
dataTestId: 'stake-pool-details-stake-btn',
@@ -233,12 +239,6 @@ const makeActionButtons = (
233239
label: t('drawer.details.unselectPool'),
234240
...getSpecOverride(unselectPool),
235241
},
236-
manageDelegation && {
237-
callback: tmpNoop,
238-
dataTestId: 'stake-pool-details-manage-delegation-btn',
239-
label: t('drawer.details.manageDelegation'),
240-
...getSpecOverride(manageDelegation),
241-
},
242242
] as (ActionButtonSpec | false)[]
243243
).filter(Boolean) as ActionButtonSpec[];
244244

@@ -291,13 +291,19 @@ export const StakePoolDetailFooter = ({ popupView }: StakePoolDetailFooterProps)
291291
});
292292
}, [viewedStakePool, analytics, portfolioMutators]);
293293

294+
const onManageDelegationClick = useCallback(() => {
295+
if (!viewedStakePool) return;
296+
analytics.sendEventToPostHog(PostHogAction.StakingBrowsePoolsStakePoolDetailManageDelegation);
297+
portfolioMutators.executeCommand({
298+
type: 'ManageDelegationFromDetails',
299+
});
300+
}, [viewedStakePool, analytics, portfolioMutators]);
301+
294302
const actionButtons = useMemo(
295303
() =>
296304
makeActionButtons(t, {
297305
addStakingPool: ableToSelect && !selectionsEmpty && { callback: onSelectClick },
298-
// TODO: disabling this button for now
299-
// eslint-disable-next-line sonarjs/no-redundant-boolean
300-
manageDelegation: false && poolInCurrentPortfolio,
306+
manageDelegation: poolInCurrentPortfolio && { callback: onManageDelegationClick },
301307
selectForMultiStaking: ableToSelect && selectionsEmpty && { callback: onSelectClick },
302308
stakeOnThisPool: selectionsEmpty && ableToStakeOnlyOnThisPool && { callback: onStakeOnThisPool },
303309
unselectPool: poolSelected && { callback: onUnselectClick },
@@ -306,6 +312,7 @@ export const StakePoolDetailFooter = ({ popupView }: StakePoolDetailFooterProps)
306312
t,
307313
ableToSelect,
308314
selectionsEmpty,
315+
onManageDelegationClick,
309316
onSelectClick,
310317
poolInCurrentPortfolio,
311318
ableToStakeOnlyOnThisPool,

packages/staking/src/features/store/delegationPortfolioStore/stateMachine/commands.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export type DrawerFailure = {
100100
type: 'DrawerFailure';
101101
};
102102

103+
export type ManageDelegationFromDetails = {
104+
type: 'ManageDelegationFromDetails';
105+
};
106+
103107
export type HwSkipToSuccess = {
104108
type: 'HwSkipToSuccess';
105109
};
@@ -123,7 +127,12 @@ export type BrowsePoolsCommand =
123127

124128
export type CurrentPoolDetailsCommand = CancelDrawer;
125129

126-
export type PoolDetailsCommand = CancelDrawer | SelectPoolFromDetails | UnselectPoolFromDetails | BeginSingleStaking;
130+
export type PoolDetailsCommand =
131+
| CancelDrawer
132+
| SelectPoolFromDetails
133+
| UnselectPoolFromDetails
134+
| BeginSingleStaking
135+
| ManageDelegationFromDetails;
127136

128137
export type PortfolioManagementPreferencesCommand =
129138
| CancelDrawer

packages/staking/src/features/store/delegationPortfolioStore/stateMachine/processExpandedViewCases.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
GoToOverview,
2121
HwSkipToFailure,
2222
HwSkipToSuccess,
23+
ManageDelegationFromDetails,
2324
ManagePortfolio,
2425
NewPortfolioConfirmationCommand,
2526
NewPortfolioFailureCommand,
@@ -226,6 +227,15 @@ export const processExpandedViewCases: Handler = (params) =>
226227
...atomicStateMutators.cancelDrawer({ state, targetFlow: DelegationFlow.BrowsePools }),
227228
viewedStakePool: undefined,
228229
})),
230+
ManageDelegationFromDetails: handler<ManageDelegationFromDetails, StatePoolDetails, StatePortfolioManagement>(
231+
({ state }) => ({
232+
...state,
233+
activeDelegationFlow: DelegationFlow.PortfolioManagement,
234+
activeDrawerStep: DrawerManagementStep.Preferences,
235+
draftPortfolio: currentPortfolioToDraft(state.currentPortfolio),
236+
viewedStakePool: undefined,
237+
})
238+
),
229239
SelectPoolFromDetails: handler<SelectPoolFromDetails, StatePoolDetails, StateBrowsePools>(
230240
({ state, command: { data } }) => ({
231241
...state,

0 commit comments

Comments
 (0)