Skip to content

Commit 9abbe30

Browse files
authored
feat(idpe-15219): remove pinned items from flows (#5783)
1 parent 19dd517 commit 9abbe30

File tree

5 files changed

+6
-127
lines changed

5 files changed

+6
-127
lines changed

src/flows/components/FlowCard.tsx

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, {FC, useContext} from 'react'
22
import {useParams, useHistory} from 'react-router-dom'
3-
import {useDispatch} from 'react-redux'
43

54
// Components
65
import {ResourceCard} from '@influxdata/clockface'
@@ -9,29 +8,19 @@ import {DEFAULT_PROJECT_NAME, PROJECT_NAME_PLURAL} from 'src/flows'
98
import {FlowListContext} from 'src/flows/context/flow.list'
109

1110
// Utils
12-
import {updatePinnedItemByParam} from 'src/shared/contexts/pinneditems'
13-
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
14-
import {CLOUD} from 'src/shared/constants'
15-
import {
16-
pinnedItemFailure,
17-
pinnedItemSuccess,
18-
} from 'src/shared/copy/notifications'
19-
import {notify} from 'src/shared/actions/notifications'
2011
import {shouldOpenLinkInNewTab} from 'src/utils/crossPlatform'
2112
import {safeBlankLinkOpen} from 'src/utils/safeBlankLinkOpen'
2213

2314
interface Props {
2415
id: string
25-
isPinned: boolean
2616
}
2717

28-
const FlowCard: FC<Props> = ({id, isPinned}) => {
18+
const FlowCard: FC<Props> = ({id}) => {
2919
const {update, flows} = useContext(FlowListContext)
3020
const flow = flows[id]
3121
const {orgID} = useParams<{orgID: string}>()
3222

3323
const history = useHistory()
34-
const dispatch = useDispatch()
3524

3625
const flowUrl = `/orgs/${orgID}/${PROJECT_NAME_PLURAL.toLowerCase()}/${id}`
3726

@@ -43,21 +32,11 @@ const FlowCard: FC<Props> = ({id, isPinned}) => {
4332
}
4433
}
4534

46-
const contextMenu = (
47-
<FlowContextMenu id={id} name={flow.name} isPinned={isPinned} />
48-
)
35+
const contextMenu = <FlowContextMenu id={id} name={flow.name} />
4936

5037
const handleRenameNotebook = async (name: string) => {
5138
flow.name = name
5239
await update(id, flow)
53-
if (isFlagEnabled('pinnedItems') && CLOUD && isPinned) {
54-
try {
55-
updatePinnedItemByParam(id, {name})
56-
dispatch(notify(pinnedItemSuccess('notebook', 'updated')))
57-
} catch (err) {
58-
dispatch(notify(pinnedItemFailure(err.message, 'update')))
59-
}
60-
}
6140
}
6241

6342
const meta = []

src/flows/components/FlowCards.tsx

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {FC, useEffect, useState} from 'react'
1+
import React, {FC} from 'react'
22

33
import {
44
ResourceList,
@@ -12,12 +12,6 @@ import FlowCard from 'src/flows/components/FlowCard'
1212
import {PROJECT_NAME_PLURAL} from 'src/flows'
1313
import {FlowList} from 'src/types/flows'
1414
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
15-
import {CLOUD} from 'src/shared/constants'
16-
17-
let getPinnedItems
18-
if (CLOUD) {
19-
getPinnedItems = require('src/shared/contexts/pinneditems').getPinnedItems
20-
}
2115

2216
interface Props {
2317
flows: FlowList
@@ -33,29 +27,13 @@ const NoMatches = () => {
3327
}
3428

3529
const FlowCards: FC<Props> = ({flows, search}) => {
36-
const [pinnedItems, setPinnedItems] = useState([])
37-
38-
useEffect(() => {
39-
if (isFlagEnabled('pinnedItems') && CLOUD) {
40-
getPinnedItems()
41-
.then(res => setPinnedItems(res))
42-
.catch(err => {
43-
console.error(err.message)
44-
})
45-
}
46-
}, [flows])
47-
4830
const body = (
4931
<ResourceList>
5032
<ResourceList.Body
5133
emptyState={!!search ? <NoMatches /> : <FlowsIndexEmpty />}
5234
>
5335
{Object.keys(flows.flows).map(id => (
54-
<FlowCard
55-
key={id}
56-
id={id}
57-
isPinned={!!pinnedItems.find(item => item?.metadata.flowID === id)}
58-
/>
36+
<FlowCard key={id} id={id} />
5937
))}
6038
</ResourceList.Body>
6139
</ResourceList>

src/flows/components/FlowContextMenu.tsx

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import React, {createRef, FC, RefObject, useContext} from 'react'
33
import {useParams, useHistory} from 'react-router-dom'
44
import '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
117
import {
128
Appearance,
@@ -25,75 +21,22 @@ import {PROJECT_NAME, PROJECT_NAME_PLURAL} from 'src/flows'
2521

2622
// Utils
2723
import {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'
3524
import {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-
4326
interface 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
/>

src/flows/components/header/MenuButton.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {useHistory} from 'react-router-dom'
2121
// Utils
2222
import {event} from 'src/cloud/utils/reporting'
2323
import {getOrg} from 'src/organizations/selectors'
24-
import {deletePinnedItemByParam} from 'src/shared/contexts/pinneditems'
2524
import {downloadImage} from 'src/shared/utils/download'
2625

2726
// Constants
@@ -66,7 +65,6 @@ const MenuButton: FC<Props> = ({handleResetShare}) => {
6665
event('delete_notebook', {
6766
context: 'notebook',
6867
})
69-
await deletePinnedItemByParam(flow.id)
7068
await deleteNotebook()
7169
setLoading(RemoteDataState.Done)
7270
history.push(`/orgs/${orgID}/${PROJECT_NAME_PLURAL.toLowerCase()}`)

src/flows/components/header/index.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import MenuButton from 'src/flows/components/header/MenuButton'
3232
import {getNotebooksShare, postNotebooksShare} from 'src/client/notebooksRoutes'
3333
import {event} from 'src/cloud/utils/reporting'
3434
import {serialize} from 'src/flows/context/flow.list'
35-
import {updatePinnedItemByParam} from 'src/shared/contexts/pinneditems'
3635
import {getOrg} from 'src/organizations/selectors'
3736
import {showOverlay} from 'src/overlays/actions/overlays'
3837

@@ -86,11 +85,6 @@ const FlowHeader: FC = () => {
8685

8786
const handleRename = (name: string) => {
8887
updateOther({name})
89-
try {
90-
updatePinnedItemByParam(flow.id, {name})
91-
} catch (err) {
92-
console.error(err)
93-
}
9488
}
9589

9690
const generateLink = async () => {

0 commit comments

Comments
 (0)