-
Notifications
You must be signed in to change notification settings - Fork 556
feat: create segment sources fake door modal #8272
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
Merged
Merged
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 hidden or 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 hidden or 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
9 changes: 9 additions & 0 deletions
9
frontend/web/components/modals/CreateSegmentSourcesModal/CreateSegmentSourcesModal.scss
This file contains hidden or 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,9 @@ | ||
| .create-segment-sources { | ||
| &__manual { | ||
| min-height: 96px; | ||
| } | ||
|
|
||
| &__source { | ||
| min-height: 110px; | ||
| } | ||
| } |
180 changes: 180 additions & 0 deletions
180
frontend/web/components/modals/CreateSegmentSourcesModal/CreateSegmentSourcesModal.tsx
This file contains hidden or 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,180 @@ | ||
| import React, { FC, useState } from 'react' | ||
| import flagsmith from '@flagsmith/flagsmith' | ||
| import classNames from 'classnames' | ||
| import AccountStore from 'common/stores/account-store' | ||
| import { colorIconAction } from 'common/theme/tokens' | ||
| import Button from 'components/base/forms/Button' | ||
| import BareButton from 'components/base/forms/BareButton' | ||
| import Chip from 'components/base/Chip' | ||
| import Icon from 'components/icons/Icon' | ||
| import './CreateSegmentSourcesModal.scss' | ||
|
Zaimwa9 marked this conversation as resolved.
|
||
|
|
||
| type SegmentSource = { | ||
| description: string | ||
| image?: string | ||
| key: string | ||
| name: string | ||
| } | ||
|
|
||
| type SelectedSegmentSource = SegmentSource | null | ||
|
|
||
| const SOURCES: SegmentSource[] = [ | ||
| { | ||
| description: | ||
| 'Upload identifiers to create a managed segment. Update members with a new upload.', | ||
| key: 'csv', | ||
| name: 'From a CSV list', | ||
| }, | ||
| { | ||
| description: | ||
| 'Sync a behavioural cohort as a managed segment, updated on schedule or real-time.', | ||
| image: '/static/images/integrations/amplitude.svg', | ||
| key: 'amplitude', | ||
| name: 'Amplitude', | ||
| }, | ||
| { | ||
| description: | ||
| 'A managed segment that updates as users enter and exit your Mixpanel cohort.', | ||
| image: '/static/images/integrations/mp.svg', | ||
| key: 'mixpanel', | ||
| name: 'Mixpanel', | ||
| }, | ||
| { | ||
| description: | ||
| 'Activate an Adobe audience as a managed segment, refreshed automatically by Adobe.', | ||
| image: '/static/images/integrations/adobe-analytics.png', | ||
| key: 'adobe_journey_manager', | ||
| name: 'Adobe Journey Manager', | ||
| }, | ||
| ] | ||
|
|
||
| type CreateSegmentSourcesModalType = { | ||
| onManual: () => void | ||
| } | ||
|
|
||
| const CreateSegmentSourcesModal: FC<CreateSegmentSourcesModalType> = ({ | ||
| onManual, | ||
| }) => { | ||
|
Zaimwa9 marked this conversation as resolved.
|
||
| const [selected, setSelected] = useState<SelectedSegmentSource>(null) | ||
| const [requested, setRequested] = useState<string[]>([]) | ||
|
|
||
| const trackSourceEvent = (event: string, source: SegmentSource) => { | ||
| flagsmith.trackEvent(event, { | ||
| metadata: { | ||
| email: AccountStore.getUser()?.email, | ||
| organisation: AccountStore.getOrganisation()?.name, | ||
| source: source.key, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| const openManual = () => { | ||
| closeModal() | ||
| onManual() | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| const selectSource = (source: SegmentSource) => { | ||
| if (selected?.key === source.key) { | ||
| return | ||
| } | ||
| setSelected(source) | ||
| trackSourceEvent('segment_source_clicked', source) | ||
| } | ||
|
|
||
| const requestAccess = () => { | ||
| if (!selected) { | ||
| return | ||
| } | ||
| trackSourceEvent('segment_source_beta_requested', selected) | ||
| setRequested((prev) => [...prev, selected.key]) | ||
| } | ||
|
|
||
| const hasRequested = !!selected && requested.includes(selected.key) | ||
|
|
||
| return ( | ||
| <div className='p-4'> | ||
| <p className='h6 fw-semibold text-muted mb-3'> | ||
| How do you want to define your segment? | ||
| </p> | ||
| <BareButton | ||
| data-test='create-segment-manually' | ||
| onClick={openManual} | ||
| className='create-segment-sources__manual w-100 rounded border-1 border-primary p-3 d-flex align-items-start gap-3 mb-3' | ||
| > | ||
| <span className='mt-1 flex-shrink-0 d-inline-flex'> | ||
| <Icon name='options-2' width={24} fill={colorIconAction} /> | ||
| </span> | ||
| <div> | ||
| <div className='fw-semibold'>Manually</div> | ||
| <div className='fs-small text-muted'> | ||
| Build rules based on traits and context values | ||
| </div> | ||
| </div> | ||
| </BareButton> | ||
| <div className='row g-0'> | ||
| {SOURCES.map((source) => { | ||
| const isSelected = selected?.key === source.key | ||
| return ( | ||
| <div key={source.key} className='col-md-6 p-1'> | ||
| <BareButton | ||
| data-test={`segment-source-${source.key}`} | ||
| aria-pressed={isSelected} | ||
| onClick={() => selectSource(source)} | ||
| className={classNames( | ||
| 'create-segment-sources__source w-100 rounded border-1 p-3 h-100 d-flex align-items-start gap-3', | ||
| { 'border-primary bg-primary-opacity-5': isSelected }, | ||
| )} | ||
| > | ||
| {source.image ? ( | ||
| <img | ||
| alt={source.name} | ||
| src={source.image} | ||
| width={24} | ||
| height={24} | ||
| className='mt-1 flex-shrink-0' | ||
| /> | ||
| ) : ( | ||
| <span className='mt-1 flex-shrink-0 d-inline-flex'> | ||
| <Icon | ||
| name='cloud-upload' | ||
| width={24} | ||
| fill={colorIconAction} | ||
| /> | ||
| </span> | ||
| )} | ||
| <div className='flex-fill'> | ||
| <div className='fw-semibold'>{source.name}</div> | ||
| <div className='fs-small text-muted'> | ||
| {source.description} | ||
| </div> | ||
| </div> | ||
| <Chip size='xs' variant='accent' className='fw-semibold'> | ||
| <Icon name='rocket' width={12} /> | ||
| Beta | ||
| </Chip> | ||
| </BareButton> | ||
| </div> | ||
| ) | ||
| })} | ||
| </div> | ||
| {!!selected && ( | ||
| <div className='d-flex justify-content-end align-items-center gap-3 mt-4'> | ||
| {hasRequested && ( | ||
| <span className='text-muted'> | ||
| Thank you! 🎉 We'll be in touch. | ||
| </span> | ||
| )} | ||
| <Button | ||
| data-test='request-beta-access' | ||
| disabled={hasRequested} | ||
| onClick={requestAccess} | ||
| > | ||
| Request access to the beta | ||
| </Button> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default CreateSegmentSourcesModal | ||
1 change: 1 addition & 0 deletions
1
frontend/web/components/modals/CreateSegmentSourcesModal/index.ts
This file contains hidden or 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 @@ | ||
| export { default } from './CreateSegmentSourcesModal' |
This file contains hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.