@@ -3,10 +3,6 @@ import React, {createRef, FC, RefObject, useContext} from 'react'
33import { useParams , useHistory } from 'react-router-dom'
44import 'src/flows/components/FlowContextMenu.scss'
55
6- // Selector
7- import { getMe } from 'src/me/selectors'
8- import { useSelector , useDispatch } from 'react-redux'
9-
106// Components
117import {
128 Appearance ,
@@ -25,75 +21,22 @@ import {PROJECT_NAME, PROJECT_NAME_PLURAL} from 'src/flows'
2521
2622// Utils
2723import { event } from 'src/cloud/utils/reporting'
28-
29- import {
30- addPinnedItem ,
31- deletePinnedItemByParam ,
32- PinnedItemTypes ,
33- } from 'src/shared/contexts/pinneditems'
34- import { isFlagEnabled } from 'src/shared/utils/featureFlag'
3524import { CLOUD } from 'src/shared/constants'
3625
37- import {
38- pinnedItemFailure ,
39- pinnedItemSuccess ,
40- } from 'src/shared/copy/notifications'
41- import { notify } from 'src/shared/actions/notifications'
42-
4326interface Props {
4427 id : string
4528 name : string
46- isPinned : boolean
4729}
4830
49- const FlowContextMenu : FC < Props > = ( { id, name , isPinned } ) => {
31+ const FlowContextMenu : FC < Props > = ( { id} ) => {
5032 const { remove, clone} = useContext ( FlowListContext )
5133 const { orgID} = useParams < { orgID : string } > ( )
52- const me = useSelector ( getMe )
5334 const history = useHistory ( )
54- const dispatch = useDispatch ( )
55-
56- const handleDeletePinnedItem = async ( ) => {
57- try {
58- await deletePinnedItemByParam ( id )
59- dispatch ( notify ( pinnedItemSuccess ( 'notebook' , 'deleted' ) ) )
60- } catch ( err ) {
61- dispatch ( notify ( pinnedItemFailure ( err . message , 'delete' ) ) )
62- }
63- }
64-
65- const handleAddPinnedItem = async ( ) => {
66- try {
67- await addPinnedItem ( {
68- orgID : orgID ,
69- userID : me . id ,
70- metadata : {
71- flowID : id ,
72- name,
73- } ,
74- type : PinnedItemTypes . Notebook ,
75- } )
76- dispatch ( notify ( pinnedItemSuccess ( 'notebook' , 'added' ) ) )
77- } catch ( err ) {
78- dispatch ( notify ( pinnedItemFailure ( err . message , 'create' ) ) )
79- }
80- }
81-
82- const handlePinFlow = ( ) => {
83- if ( isPinned ) {
84- // delete from pinned item list
85- handleDeletePinnedItem ( )
86- } else {
87- // add to pinned item list
88- handleAddPinnedItem ( )
89- }
90- }
9135
9236 const handleDelete = ( ) => {
9337 event ( 'delete_notebook' , {
9438 context : 'list' ,
9539 } )
96- deletePinnedItemByParam ( id )
9740 remove ( id )
9841 }
9942
@@ -134,7 +77,7 @@ const FlowContextMenu: FC<Props> = ({id, name, isPinned}) => {
13477 enableDefaultStyles = { false }
13578 style = { { minWidth : '112px' } }
13679 triggerRef = { settingsRef }
137- contents = { onHide => (
80+ contents = { _ => (
13881 < List >
13982 < List . Item
14083 onClick = { handleClone }
@@ -144,19 +87,6 @@ const FlowContextMenu: FC<Props> = ({id, name, isPinned}) => {
14487 >
14588 Clone
14689 </ List . Item >
147- { isFlagEnabled ( 'pinnedItems' ) && CLOUD && (
148- < List . Item
149- onClick = { ( ) => {
150- handlePinFlow ( )
151- onHide ( )
152- } }
153- size = { ComponentSize . Small }
154- style = { { fontWeight : 500 } }
155- testID = "context-pin-flow"
156- >
157- { isPinned ? 'Unpin' : 'Pin' }
158- </ List . Item >
159- ) }
16090 </ List >
16191 ) }
16292 />
0 commit comments