Skip to content
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 packages/common/src/analytics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export enum PostHogAction {
StakingBrowsePoolsStakePoolDetailStakeAllOnThisPoolClick = 'staking | browse pools | stake pool detail | stake all on this pool | click',
StakingBrowsePoolsStakePoolDetailAddStakingPoolClick = 'staking | browse pools | stake pool detail | add staking pool | click',
StakingBrowsePoolsStakePoolDetailUnselectPoolClick = 'staking | browse pools | stake pool detail | unselect pool | click',
StakingBrowsePoolsStakePoolDetailManageDelegation = 'staking | browse pools | stake pool detail | manage delegation | click',
StakingBrowsePoolsStakeClick = 'staking | browse pools | stake | click',
StakingBrowsePoolsUnselectClick = 'staking | browse pools | unselect | click',
StakingBrowsePoolsClearClick = 'staking | browse pools | clear | click',
Expand Down
25 changes: 16 additions & 9 deletions packages/staking/src/features/Drawer/StakePoolDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ const makeActionButtons = (
): ActionButtonSpec[] =>
(
[
manageDelegation && {
callback: tmpNoop,
dataTestId: 'stake-pool-details-manage-delegation-btn',
label: t('drawer.details.manageDelegation'),
...getSpecOverride(manageDelegation),
},
stakeOnThisPool && {
callback: tmpNoop,
dataTestId: 'stake-pool-details-stake-btn',
Expand All @@ -233,12 +239,6 @@ const makeActionButtons = (
label: t('drawer.details.unselectPool'),
...getSpecOverride(unselectPool),
},
manageDelegation && {
callback: tmpNoop,
dataTestId: 'stake-pool-details-manage-delegation-btn',
label: t('drawer.details.manageDelegation'),
...getSpecOverride(manageDelegation),
},
] as (ActionButtonSpec | false)[]
).filter(Boolean) as ActionButtonSpec[];

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

const onManageDelegationClick = useCallback(() => {
if (!viewedStakePool) return;
analytics.sendEventToPostHog(PostHogAction.StakingBrowsePoolsStakePoolDetailManageDelegation);
portfolioMutators.executeCommand({
type: 'ManageDelegationFromDetails',
});
}, [viewedStakePool, analytics, portfolioMutators]);

const actionButtons = useMemo(
() =>
makeActionButtons(t, {
addStakingPool: ableToSelect && !selectionsEmpty && { callback: onSelectClick },
// TODO: disabling this button for now
// eslint-disable-next-line sonarjs/no-redundant-boolean
manageDelegation: false && poolInCurrentPortfolio,
manageDelegation: poolInCurrentPortfolio && { callback: onManageDelegationClick },
selectForMultiStaking: ableToSelect && selectionsEmpty && { callback: onSelectClick },
stakeOnThisPool: selectionsEmpty && ableToStakeOnlyOnThisPool && { callback: onStakeOnThisPool },
unselectPool: poolSelected && { callback: onUnselectClick },
Expand All @@ -306,6 +312,7 @@ export const StakePoolDetailFooter = ({ popupView }: StakePoolDetailFooterProps)
t,
ableToSelect,
selectionsEmpty,
onManageDelegationClick,
onSelectClick,
poolInCurrentPortfolio,
ableToStakeOnlyOnThisPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export type DrawerFailure = {
type: 'DrawerFailure';
};

export type ManageDelegationFromDetails = {
type: 'ManageDelegationFromDetails';
};

export type ActivityCommand = GoToOverview | GoToBrowsePools;

export type OverviewCommand = ShowDelegatedPoolDetails | ManagePortfolio | GoToBrowsePools | GoToActivity;
Expand All @@ -115,7 +119,12 @@ export type BrowsePoolsCommand =

export type CurrentPoolDetailsCommand = CancelDrawer;

export type PoolDetailsCommand = CancelDrawer | SelectPoolFromDetails | UnselectPoolFromDetails | BeginSingleStaking;
export type PoolDetailsCommand =
| CancelDrawer
| SelectPoolFromDetails
| UnselectPoolFromDetails
| BeginSingleStaking
| ManageDelegationFromDetails;

export type PortfolioManagementPreferencesCommand =
| CancelDrawer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
GoToActivity,
GoToBrowsePools,
GoToOverview,
ManageDelegationFromDetails,
ManagePortfolio,
NewPortfolioConfirmationCommand,
NewPortfolioFailureCommand,
Expand Down Expand Up @@ -224,6 +225,15 @@ export const processExpandedViewCases: Handler = (params) =>
...atomicStateMutators.cancelDrawer({ state, targetFlow: DelegationFlow.BrowsePools }),
viewedStakePool: undefined,
})),
ManageDelegationFromDetails: handler<ManageDelegationFromDetails, StatePoolDetails, StatePortfolioManagement>(
({ state }) => ({
...state,
activeDelegationFlow: DelegationFlow.PortfolioManagement,
activeDrawerStep: DrawerManagementStep.Preferences,
draftPortfolio: currentPortfolioToDraft(state.currentPortfolio),
viewedStakePool: undefined,
})
),
SelectPoolFromDetails: handler<SelectPoolFromDetails, StatePoolDetails, StateBrowsePools>(
({ state, command: { data } }) => ({
...state,
Expand Down