-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: [1/n] Teams Downgrade Flow Experiment #27617
Open
surbhi-posthog
wants to merge
1
commit into
master
Choose a base branch
from
teams
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+124
−13
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { LemonButton, LemonModal } from '@posthog/lemon-ui' | ||
import { useActions, useValues } from 'kea' | ||
|
||
import { downgradeLogic } from './downgradeLogic' | ||
|
||
export function DowngradeModal(): JSX.Element | null { | ||
const { isDowngradeModalOpen, currentAddon } = useValues(downgradeLogic) | ||
const { hideDowngradeModal, handleDowngrade } = useActions(downgradeLogic) | ||
|
||
if (!currentAddon) { | ||
return null | ||
} | ||
|
||
return ( | ||
<LemonModal | ||
isOpen={isDowngradeModalOpen} | ||
onClose={hideDowngradeModal} | ||
title={`Unsubscribe from ${currentAddon.name}`} | ||
description="Your team is actively using these features and will lose access to it immediately" | ||
footer={ | ||
<> | ||
<LemonButton type="secondary" onClick={hideDowngradeModal}> | ||
Cancel | ||
</LemonButton> | ||
<LemonButton type="primary" status="danger" onClick={handleDowngrade}> | ||
Unsubscribe | ||
</LemonButton> | ||
</> | ||
} | ||
> | ||
<div className="mt-2 mb-6">TODO: Add features that are used here</div> | ||
</LemonModal> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea' | ||
import { FEATURE_FLAGS, UNSUBSCRIBE_SURVEY_ID } from 'lib/constants' | ||
import { featureFlagLogic } from 'lib/logic/featureFlagLogic' | ||
|
||
import { BillingProductV2AddonType } from '~/types' | ||
|
||
import { billingProductLogic } from './billingProductLogic' | ||
import type { downgradeLogicType } from './downgradeLogicType' | ||
|
||
export interface ShowDowngradeModalPayload { | ||
addon: BillingProductV2AddonType | ||
} | ||
|
||
export const downgradeLogic = kea<downgradeLogicType>([ | ||
path(['scenes', 'billing', 'downgradeLogic']), | ||
|
||
connect({ | ||
values: [featureFlagLogic, ['featureFlags']], | ||
}), | ||
|
||
actions({ | ||
showDowngradeModal: (payload: ShowDowngradeModalPayload) => ({ payload }), | ||
hideDowngradeModal: true, | ||
handleDowngrade: true, | ||
}), | ||
|
||
reducers({ | ||
isDowngradeModalOpen: [ | ||
false, | ||
{ | ||
showDowngradeModal: () => true, | ||
hideDowngradeModal: () => false, | ||
}, | ||
], | ||
currentAddon: [ | ||
null as BillingProductV2AddonType | null, | ||
{ | ||
showDowngradeModal: (_, { payload }) => payload.addon, | ||
hideDowngradeModal: () => null, | ||
}, | ||
], | ||
}), | ||
|
||
selectors({ | ||
isUserInExperiment: [ | ||
(s) => [s.featureFlags], | ||
(featureFlags): boolean => { | ||
return featureFlags[FEATURE_FLAGS.TEAMS_DOWNGRADE_FLOW] === 'test' | ||
}, | ||
], | ||
}), | ||
|
||
listeners(({ actions, values }) => ({ | ||
handleDowngrade: async () => { | ||
if (values.currentAddon) { | ||
const logic = billingProductLogic({ product: values.currentAddon }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some random kea related questions: How does this work with pulling in a logic directly, do we need to mount it? Is this a common kea pattern, or is it more common to use connect? Not sure if using connect is possible here given you need to pass a product? |
||
logic.actions.setSurveyResponse('$survey_response_1', values.currentAddon.type) | ||
logic.actions.reportSurveyShown(UNSUBSCRIBE_SURVEY_ID, values.currentAddon.type) | ||
} | ||
actions.hideDowngradeModal() | ||
}, | ||
})), | ||
]) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: make this more specific e.g.
isUserInDowngradeFlowExperiment