@@ -22,34 +22,16 @@ import {getSortedResources} from 'src/shared/utils/sort'
2222import { getMe } from 'src/me/selectors'
2323import { getOrg } from 'src/organizations/selectors'
2424
25- // Contexts
26- import {
27- addPinnedItem ,
28- deletePinnedItemByParam ,
29- PinnedItemTypes ,
30- } from 'src/shared/contexts/pinneditems'
31-
3225// Utils
3326import { event } from 'src/cloud/utils/reporting'
3427import { isFlagEnabled } from 'src/shared/utils/featureFlag'
35- import { CLOUD } from 'src/shared/constants'
3628import { notify } from 'src/shared/actions/notifications'
3729
3830// Constants
3931import { GLOBAL_HEADER_HEIGHT } from 'src/identity/components/GlobalHeader/constants'
4032
4133import { PaginationNav } from '@influxdata/clockface'
4234
43- import {
44- pinnedItemFailure ,
45- pinnedItemSuccess ,
46- } from 'src/shared/copy/notifications'
47-
48- let getPinnedItems
49- if ( CLOUD ) {
50- getPinnedItems = require ( 'src/shared/contexts/pinneditems' ) . getPinnedItems
51- }
52-
5335interface OwnProps {
5436 pageHeight : number
5537 pageWidth : number
@@ -74,7 +56,6 @@ interface OwnProps {
7456interface State {
7557 taskLabelsEdit : Task
7658 isEditingTaskLabels : boolean
77- pinnedItems : any [ ]
7859}
7960
8061type ReduxProps = ConnectedProps < typeof connector >
@@ -86,7 +67,6 @@ class TasksList extends PureComponent<Props, State> implements Pageable {
8667 private memGetSortedResources =
8768 memoizeOne < typeof getSortedResources > ( getSortedResources )
8869
89- private isComponentMounted : boolean
9070 private paginationRef : RefObject < HTMLDivElement >
9171
9272 public currentPage : number = 1
@@ -98,14 +78,12 @@ class TasksList extends PureComponent<Props, State> implements Pageable {
9878 this . state = {
9979 taskLabelsEdit : null ,
10080 isEditingTaskLabels : false ,
101- pinnedItems : [ ] ,
10281 }
10382
10483 this . paginationRef = createRef < HTMLDivElement > ( )
10584 }
10685
10786 public componentDidMount ( ) {
108- this . isComponentMounted = true
10987 const params = new URLSearchParams ( window . location . search )
11088 const urlPageNumber = parseInt ( params . get ( 'page' ) , 10 )
11189
@@ -116,9 +94,6 @@ class TasksList extends PureComponent<Props, State> implements Pageable {
11694 }
11795
11896 this . props . checkTaskLimits ( )
119- if ( CLOUD && isFlagEnabled ( 'pinnedItems' ) ) {
120- this . updatePinnedItems ( )
121- }
12297 }
12398
12499 public componentDidUpdate ( ) {
@@ -129,10 +104,6 @@ class TasksList extends PureComponent<Props, State> implements Pageable {
129104 }
130105 }
131106
132- public componentWillUnmount ( ) {
133- this . isComponentMounted = false
134- }
135-
136107 public render ( ) {
137108 const heightWithPagination =
138109 this . paginationRef ?. current ?. clientHeight ||
@@ -175,48 +146,6 @@ class TasksList extends PureComponent<Props, State> implements Pageable {
175146 )
176147 }
177148
178- public updatePinnedItems = ( ) => {
179- getPinnedItems ( )
180- . then ( res => {
181- if ( this . isComponentMounted ) {
182- this . setState ( prev => ( { ...prev , pinnedItems : res } ) )
183- }
184- } )
185- . catch ( err => console . error ( err ) )
186- }
187-
188- public handlePinTask = async ( taskID : string , name : string ) => {
189- const { org, me} = this . props
190-
191- // add to pinned item list
192- try {
193- await addPinnedItem ( {
194- orgID : org . id ,
195- userID : me . id ,
196- metadata : {
197- taskID,
198- name,
199- } ,
200- type : PinnedItemTypes . Task ,
201- } )
202- this . props . sendNotification ( pinnedItemSuccess ( 'task' , 'added' ) )
203- this . updatePinnedItems ( )
204- } catch ( err ) {
205- this . props . sendNotification ( pinnedItemFailure ( err . message , 'add' ) )
206- }
207- }
208-
209- public handleUnpinTask = async ( taskID : string ) => {
210- // delete from pinned item list
211- try {
212- await deletePinnedItemByParam ( taskID )
213- this . props . sendNotification ( pinnedItemSuccess ( 'task' , 'deleted' ) )
214- this . updatePinnedItems ( )
215- } catch ( err ) {
216- this . props . sendNotification ( pinnedItemFailure ( err . message , 'delete' ) )
217- }
218- }
219-
220149 public paginate = page => {
221150 this . currentPage = page
222151 const url = new URL ( location . href )
@@ -260,14 +189,6 @@ class TasksList extends PureComponent<Props, State> implements Pageable {
260189 onUpdate = { this . props . onUpdate }
261190 onRunTask = { this . props . onRunTask }
262191 onFilterChange = { this . props . onFilterChange }
263- onPinTask = { this . handlePinTask }
264- onUnpinTask = { this . handleUnpinTask }
265- isPinned = {
266- this . state . pinnedItems ?. length &&
267- ! ! this . state . pinnedItems . find (
268- item => item ?. metadata . taskID === task . id
269- )
270- }
271192 />
272193 )
273194 }
0 commit comments