-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notebook): Allow creating early access from notebooks (#17264)
- Loading branch information
1 parent
7dcfb52
commit 5fdb0f6
Showing
5 changed files
with
119 additions
and
5 deletions.
There are no files selected for viewing
Binary file modified
BIN
-469 Bytes
(99%)
...napshots__/scenes-app-recordings--recordings-play-list-no-pinned-recordings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
43 changes: 43 additions & 0 deletions
43
frontend/src/scenes/notebooks/Nodes/NotebookNodeFlagLogic.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,43 @@ | ||
import { connect, kea, key, listeners, path, props, selectors } from 'kea' | ||
import { JSONContent, Node } from '../Notebook/utils' | ||
import { FeatureFlagLogicProps, featureFlagLogic } from 'scenes/feature-flags/featureFlagLogic' | ||
import { buildEarlyAccessFeatureContent } from './NotebookNodeEarlyAccessFeature' | ||
import { NotebookNodeType } from '~/types' | ||
|
||
import type { notebookNodeFlagLogicType } from './NotebookNodeFlagLogicType' | ||
|
||
export type NotebookNodeFlagLogicProps = { | ||
id: FeatureFlagLogicProps['id'] | ||
insertAfter: (content: JSONContent) => void | ||
} | ||
|
||
export const notebookNodeFlagLogic = kea<notebookNodeFlagLogicType>([ | ||
props({} as NotebookNodeFlagLogicProps), | ||
path((key) => ['scenes', 'notebooks', 'Notebook', 'Nodes', 'notebookNodeFlagLogic', key]), | ||
key(({ id }) => id), | ||
|
||
connect((props: NotebookNodeFlagLogicProps) => ({ | ||
actions: [featureFlagLogic({ id: props.id }), ['createEarlyAccessFeatureSuccess']], | ||
values: [featureFlagLogic({ id: props.id }), ['featureFlag', 'hasEarlyAccessFeatures']], | ||
})), | ||
listeners(({ props }) => ({ | ||
createEarlyAccessFeatureSuccess: async ({ newEarlyAccessFeature }) => { | ||
props.insertAfter(buildEarlyAccessFeatureContent(newEarlyAccessFeature.id)) | ||
}, | ||
})), | ||
selectors({ | ||
shouldDisableInsertEarlyAccessFeature: [ | ||
(s) => [s.featureFlag, s.hasEarlyAccessFeatures], | ||
(featureFlag, hasEarlyAccessFeatures) => | ||
(nextNode: Node | null): boolean => { | ||
return ( | ||
(nextNode?.type.name === NotebookNodeType.EarlyAccessFeature && | ||
hasEarlyAccessFeatures && | ||
featureFlag.features && | ||
nextNode?.attrs.id === featureFlag.features[0].id) || | ||
false | ||
) | ||
}, | ||
], | ||
}), | ||
]) |