Skip to content
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(Surveys): Add a survey preview to global settings page #25603

Merged
merged 19 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bb0c8cb
add a survey preview to global settings page
Phanatic Oct 15, 2024
2854b49
Merge branch 'master' into global-settings-survey-preview
Phanatic Oct 15, 2024
e84bea2
Update UI snapshots for `chromium` (2)
github-actions[bot] Oct 15, 2024
1172f84
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 15, 2024
cd565b5
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 15, 2024
c5dedf1
hide template preview if not available
Phanatic Oct 17, 2024
adbdcda
Merge branch 'master' into global-settings-survey-preview
Phanatic Oct 17, 2024
66c9fd7
Update UI snapshots for `chromium` (2)
github-actions[bot] Oct 17, 2024
ac65152
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 17, 2024
fdd138a
Update UI snapshots for `chromium` (2)
github-actions[bot] Oct 17, 2024
85adb37
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 17, 2024
c54768b
Merge branch 'master' into global-settings-survey-preview
Phanatic Oct 17, 2024
166fbc3
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 17, 2024
e7d42b1
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 17, 2024
a0e00d0
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 17, 2024
f5a5ea5
Merge branch 'master' into global-settings-survey-preview
Phanatic Oct 17, 2024
67e787b
Merge branch 'master' into global-settings-survey-preview
Phanatic Oct 18, 2024
48c4e51
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 18, 2024
c6276b2
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 18, 2024
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 20 additions & 4 deletions frontend/src/scenes/surveys/Surveys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ import stringWithWBR from 'lib/utils/stringWithWBR'
import { useState } from 'react'
import { LinkedHogFunctions } from 'scenes/pipeline/hogfunctions/list/LinkedHogFunctions'
import { SceneExport } from 'scenes/sceneTypes'
import { SurveyAppearancePreview } from 'scenes/surveys/SurveyAppearancePreview'
import { Customization } from 'scenes/surveys/SurveyCustomization'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'

import { ActivityScope, ProductKey, ProgressStatus, Survey } from '~/types'

import { defaultSurveyAppearance, SurveyQuestionLabel } from './constants'
import { defaultSurveyAppearance, NEW_SURVEY, SurveyQuestionLabel } from './constants'
import { openSurveysSettingsDialog } from './SurveySettings'
import { getSurveyStatus, surveysLogic, SurveysTabs } from './surveysLogic'

Expand Down Expand Up @@ -69,6 +70,12 @@ export function Surveys(): JSX.Element {
const [editableSurveyConfig, setEditableSurveyConfig] = useState(
currentTeam?.survey_config?.appearance || defaultSurveyAppearance
)

const [templatedSurvey, setTemplatedSurvey] = useState(NEW_SURVEY)

if (templatedSurvey.appearance === defaultSurveyAppearance) {
templatedSurvey.appearance = editableSurveyConfig
}
const shouldShowEmptyState = !surveysLoading && surveys.length === 0
const showLinkedHogFunctions = useFeatureFlag('HOG_FUNCTIONS_LINKED')

Expand Down Expand Up @@ -152,9 +159,8 @@ export function Surveys(): JSX.Element {
</LemonButton>
)}
</div>
<div className="flex flex-col overflow-hidden flex-1">
<LemonDivider />

<LemonDivider />
<div className="flex align-top mb-2 gap-2">
<Customization
key="survey-settings-customization"
appearance={editableSurveyConfig}
Expand All @@ -166,8 +172,18 @@ export function Surveys(): JSX.Element {
...editableSurveyConfig,
...appearance,
})
setTemplatedSurvey({
...templatedSurvey,
...{ appearance: appearance },
})
}}
/>
<div className="flex-1" />
<div className="mt-10 mr-5">
{globalSurveyAppearanceConfigAvailable && (
<SurveyAppearancePreview survey={templatedSurvey} previewPageIndex={0} />
)}
</div>
</div>
</>
)}
Expand Down
Loading