-
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(onboarding): add product config screen #18720
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f203a46
stub out config screen
raquelmsmith 8600f48
saave the configuration
raquelmsmith 090ba08
fix
raquelmsmith d619a6b
Merge branch 'master' into feat/onboarding-product-config-screen
raquelmsmith 3571c68
add existing replay controls to config
raquelmsmith e04fc64
dont show any toasts in onboarding
raquelmsmith 565213d
add minimum duration option
raquelmsmith bf2906d
move dropdown
raquelmsmith 4c1e931
flag the control
raquelmsmith a20f212
Merge branch 'master' into feat/onboarding-product-config-screen
raquelmsmith 25dd07f
Merge branch 'master' into feat/onboarding-product-config-screen
raquelmsmith ec4649b
Update frontend/src/scenes/onboarding/Onboarding.tsx
raquelmsmith be01f8c
Update UI snapshots for `chromium` (1)
github-actions[bot] b54ff44
Merge branch 'feat/onboarding-product-config-screen' of https://githu…
raquelmsmith d18c625
Merge branch 'master' into feat/onboarding-product-config-screen
raquelmsmith 8f22d3c
Update UI snapshots for `chromium` (1)
github-actions[bot] bc63fe8
Update UI snapshots for `chromium` (1)
github-actions[bot] 1174790
Update UI snapshots for `chromium` (1)
github-actions[bot] b763148
Update UI snapshots for `chromium` (2)
github-actions[bot] 29ce3e8
Update UI snapshots for `chromium` (1)
github-actions[bot] cd62dfe
Update UI snapshots for `chromium` (2)
github-actions[bot] 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
68 changes: 68 additions & 0 deletions
68
frontend/src/scenes/onboarding/OnboardingProductConfiguration.tsx
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,68 @@ | ||
import { LemonSelect, LemonSwitch } from '@posthog/lemon-ui' | ||
import { useActions, useValues } from 'kea' | ||
import { useEffect } from 'react' | ||
|
||
import { OnboardingStepKey } from './onboardingLogic' | ||
import { onboardingProductConfigurationLogic, ProductConfigOption } from './onboardingProductConfigurationLogic' | ||
import { OnboardingStep } from './OnboardingStep' | ||
|
||
export const OnboardingProductConfiguration = ({ | ||
stepKey = OnboardingStepKey.PRODUCT_CONFIGURATION, | ||
options, | ||
}: { | ||
stepKey?: OnboardingStepKey | ||
options: ProductConfigOption[] | ||
}): JSX.Element | null => { | ||
const { configOptions } = useValues(onboardingProductConfigurationLogic) | ||
const { setConfigOptions, saveConfiguration } = useActions(onboardingProductConfigurationLogic) | ||
useEffect(() => { | ||
setConfigOptions(options) | ||
}, []) | ||
|
||
return configOptions ? ( | ||
<OnboardingStep title={`Set up your configuration`} stepKey={stepKey} continueAction={saveConfiguration}> | ||
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. Maybe a bit more clear to say "Configure ${product.name}"? |
||
{configOptions?.map((option: ProductConfigOption) => ( | ||
<div className="my-8" key={option.teamProperty}> | ||
{option.type == 'toggle' ? ( | ||
<> | ||
<LemonSwitch | ||
data-attr="opt-in-session-recording-switch" | ||
onChange={(checked) => { | ||
setConfigOptions( | ||
configOptions.map((o) => | ||
o.teamProperty === option.teamProperty ? { ...o, value: checked } : o | ||
) | ||
) | ||
}} | ||
label={option.title} | ||
fullWidth={true} | ||
labelClassName={'text-base font-semibold'} | ||
checked={option.value || false} | ||
/> | ||
<p className="prompt-text ml-0">{option.description}</p> | ||
</> | ||
) : ( | ||
<> | ||
<label className="text-base font-semibold">{option.title}</label> | ||
<div className="flex justify-between items-center mb-1 gap-x-4"> | ||
<p className="prompt-text m-0">{option.description}</p> | ||
<LemonSelect | ||
dropdownMatchSelectWidth={false} | ||
onChange={(v) => { | ||
setConfigOptions( | ||
configOptions.map((o) => | ||
o.teamProperty === option.teamProperty ? { ...o, value: v } : o | ||
) | ||
) | ||
}} | ||
options={option.selectOptions || []} | ||
value={option.value} | ||
/> | ||
</div> | ||
</> | ||
)} | ||
</div> | ||
))} | ||
</OnboardingStep> | ||
) : null | ||
} |
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
58 changes: 58 additions & 0 deletions
58
frontend/src/scenes/onboarding/onboardingProductConfigurationLogic.ts
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,58 @@ | ||
import { LemonSelectOptions } from '@posthog/lemon-ui' | ||
import { actions, connect, kea, listeners, path, reducers } from 'kea' | ||
import { teamLogic } from 'scenes/teamLogic' | ||
|
||
import type { onboardingProductConfigurationLogicType } from './onboardingProductConfigurationLogicType' | ||
|
||
export interface ProductConfigOptionBase { | ||
title: string | ||
description: string | ||
teamProperty: string | ||
} | ||
|
||
export interface ProductConfigurationToggle extends ProductConfigOptionBase { | ||
type: 'toggle' | ||
/** Sets the initial value. Use a team setting to reflect current state, or a static value to set a default. */ | ||
value: boolean | ||
/** If true, the value is inverted when saving, used for 'opt_out' type settings */ | ||
inverseToggle?: boolean | ||
} | ||
|
||
export interface ProductConfigurationSelect extends ProductConfigOptionBase { | ||
type: 'select' | ||
/** Sets the initial value. Use a team setting to reflect current state, or a static value to set a default. */ | ||
value: string | number | null | ||
selectOptions: LemonSelectOptions<any> | ||
} | ||
|
||
export type ProductConfigOption = ProductConfigurationToggle | ProductConfigurationSelect | ||
|
||
export const onboardingProductConfigurationLogic = kea<onboardingProductConfigurationLogicType>([ | ||
path(() => ['scenes', 'onboarding', 'onboardingProductConfigurationLogic']), | ||
connect({ | ||
actions: [teamLogic, ['updateCurrentTeam']], | ||
}), | ||
actions({ | ||
setConfigOptions: (configOptions: ProductConfigOption[]) => ({ configOptions }), | ||
saveConfiguration: true, | ||
}), | ||
reducers(() => ({ | ||
configOptions: [ | ||
[], | ||
{ | ||
setConfigOptions: (_, { configOptions }) => configOptions, | ||
}, | ||
], | ||
})), | ||
listeners(({ values, actions }) => ({ | ||
saveConfiguration: async () => { | ||
const updateConfig = {} | ||
values.configOptions.forEach((configOption) => { | ||
updateConfig[configOption.teamProperty] = configOption.inverseToggle | ||
? !configOption.value | ||
: configOption.value | ||
}) | ||
actions.updateCurrentTeam(updateConfig) | ||
}, | ||
})), | ||
]) |
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
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.
Ha, github won't let me comment on the replay lines because they've not changed 🙈
Would be cool to have the basic settings here
Ultimately we'll want the cost controls here too
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.
Yep! Planning on picking this up again today 👍