Skip to content

Commit

Permalink
Fix icon position
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Oct 11, 2023
1 parent fab25ed commit 3b4d5b7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 104 deletions.
95 changes: 0 additions & 95 deletions frontend/src/scenes/notebooks/Nodes/NotebookNodeFlag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,101 +123,6 @@ const Component = ({ attributes, updateAttributes }: NotebookNodeProps<NotebookN
</div>
</>
) : null}

{/* <LemonDivider className="my-0" />
<div className="p-2 mr-1 flex justify-end gap-2">
{canCreateEarlyAccessFeature && (
<LemonButton
type="secondary"
size="small"
icon={<IconRocketLaunch />}
loading={newEarlyAccessFeatureLoading}
onClick={(e) => {
// prevent expanding the node if it isn't expanded
e.stopPropagation()
if (!hasEarlyAccessFeatures) {
createEarlyAccessFeature()
} else {
if ((featureFlag?.features?.length || 0) <= 0) {
return
}
if (!shouldDisableInsertEarlyAccessFeature(nextNode) && featureFlag.features) {
insertAfter(buildEarlyAccessFeatureContent(featureFlag.features[0].id))
}
}
}}
disabledReason={
shouldDisableInsertEarlyAccessFeature(nextNode) &&
'Early access feature already exists below'
}
>
{hasEarlyAccessFeatures ? 'View' : 'Create'} early access feature
</LemonButton>
)}
<LemonButton
type="secondary"
size="small"
icon={<IconSurveys />}
loading={newSurveyLoading}
onClick={(e) => {
// prevent expanding the node if it isn't expanded
e.stopPropagation()
if (!hasSurveys) {
createSurvey()
} else {
if ((featureFlag?.surveys?.length || 0) <= 0) {
return
}
if (!shouldDisableInsertSurvey(nextNode) && featureFlag.surveys) {
insertAfter(buildSurveyContent(featureFlag.surveys[0].id))
}
}
}}
disabledReason={shouldDisableInsertSurvey(nextNode) && 'Survey already exists below'}
>
{hasSurveys ? 'View' : 'Create'} survey
</LemonButton>
<LemonButton
type="secondary"
size="small"
icon={<IconFlag />}
onClick={(e) => {
// prevent expanding the node if it isn't expanded
e.stopPropagation()
if (nextNode?.type.name !== NotebookNodeType.FeatureFlagCodeExample) {
insertAfter(buildCodeExampleContent(id))
}
}}
disabledReason={
nextNode?.type.name === NotebookNodeType.FeatureFlagCodeExample &&
'Code example already exists below'
}
>
Show implementation
</LemonButton>
<LemonButton
onClick={(e) => {
// prevent expanding the node if it isn't expanded
e.stopPropagation()
if (nextNode?.type.name !== NotebookNodeType.RecordingPlaylist) {
insertAfter(buildPlaylistContent(recordingFilterForFlag))
}
}}
type="secondary"
size="small"
icon={<IconRecording />}
disabledReason={
nextNode?.type.name === NotebookNodeType.RecordingPlaylist &&
'Recording playlist already exists below'
}
>
View Replays
</LemonButton>
</div> */}
</BindLogic>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/notebooks/Notebook/notebookLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ export const notebookLogic = kea<notebookLogicType>([

exportJSON: () => {
const file = new File(
[JSON.stringify(values.editor?.getJSON())],
[JSON.stringify(values.editor?.getJSON(), null, 2)],
`${slugify(values.title ?? 'untitled')}.ph-notebook.json`,
{ type: 'application/json' }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ export function NotebookSelectButton({ children, ...props }: NotebookSelectButto

const button = (
<LemonButton
icon={<IconJournalPlus />}
icon={
<IconWithCount count={notebooksContainingResource.length ?? 0} showZero={false}>
<IconJournalPlus />
</IconWithCount>
}
data-attr={nodeLogic ? 'notebooks-add-button-in-a-notebook' : 'notebooks-add-button'}
sideIcon={null}
{...props}
Expand All @@ -224,13 +228,7 @@ export function NotebookSelectButton({ children, ...props }: NotebookSelectButto

return (
<FlaggedFeature flag={FEATURE_FLAGS.NOTEBOOKS} match>
{nodeLogic ? (
button
) : (
<IconWithCount count={notebooksContainingResource.length ?? 0} showZero={false}>
<NotebookSelectPopover {...props}>{button}</NotebookSelectPopover>
</IconWithCount>
)}
{nodeLogic ? button : <NotebookSelectPopover {...props}>{button}</NotebookSelectPopover>}
</FlaggedFeature>
)
}
6 changes: 6 additions & 0 deletions posthog/api/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ def _filter_request(self, request: request.Request, queryset: QuerySet) -> Query
nested_structure = basic_structure | List[Dict[str, basic_structure]]

presence_match_structure: basic_structure | nested_structure = [{"type": f"ph-{target}"}]

# We try to parse the match as a number in case as it will be an ID
try:
match = int(match)
except (ValueError, TypeError):
pass
id_match_structure: basic_structure | nested_structure = [{"attrs": {"id": match}}]
if target == "replay-timestamp":
# replay timestamps are not at the top level, they're one-level down in a content array
Expand Down

0 comments on commit 3b4d5b7

Please sign in to comment.