@@ -4,13 +4,13 @@ import { createElement } from 'preact';
4
4
import propTypes from 'prop-types' ;
5
5
6
6
import { useStoreProxy } from '../store/use-store' ;
7
- import uiConstants from '../ui-constants' ;
8
7
import { withServices } from '../service-context' ;
9
8
10
9
import NewNoteBtn from './NewNoteBtn' ;
11
10
12
11
/**
13
12
* @typedef {import('../../types/config').MergedConfig } MergedConfig
13
+ * @typedef {import('../../types/sidebar').TabName } TabName
14
14
*/
15
15
16
16
/**
@@ -98,54 +98,57 @@ function SelectionTabs({ isLoading, settings }) {
98
98
const orphanCount = store . orphanCount ( ) ;
99
99
const isWaitingToAnchorAnnotations = store . isWaitingToAnchorAnnotations ( ) ;
100
100
101
+ /**
102
+ * @param {TabName } tabId
103
+ */
101
104
const selectTab = tabId => {
102
105
store . clearSelection ( ) ;
103
106
store . selectTab ( tabId ) ;
104
107
} ;
105
108
106
109
const showAnnotationsUnavailableMessage =
107
- selectedTab === uiConstants . TAB_ANNOTATIONS &&
110
+ selectedTab === 'annotation' &&
108
111
annotationCount === 0 &&
109
112
! isWaitingToAnchorAnnotations ;
110
113
111
- const showNotesUnavailableMessage =
112
- selectedTab === uiConstants . TAB_NOTES && noteCount === 0 ;
114
+ const showNotesUnavailableMessage = selectedTab === 'note' && noteCount === 0 ;
113
115
114
116
return (
115
117
< div className = "SelectionTabs-container" >
116
118
< div className = "SelectionTabs" role = "tablist" >
117
119
< Tab
118
120
count = { annotationCount }
119
121
isWaitingToAnchor = { isWaitingToAnchorAnnotations }
120
- isSelected = { selectedTab === uiConstants . TAB_ANNOTATIONS }
122
+ isSelected = { selectedTab === 'annotation' }
121
123
label = "Annotations"
122
- onSelect = { ( ) => selectTab ( uiConstants . TAB_ANNOTATIONS ) }
124
+ onSelect = { ( ) => selectTab ( 'annotation' ) }
123
125
>
124
126
Annotations
125
127
</ Tab >
126
128
< Tab
127
129
count = { noteCount }
128
130
isWaitingToAnchor = { isWaitingToAnchorAnnotations }
129
- isSelected = { selectedTab === uiConstants . TAB_NOTES }
131
+ isSelected = { selectedTab === 'note' }
130
132
label = "Page notes"
131
- onSelect = { ( ) => selectTab ( uiConstants . TAB_NOTES ) }
133
+ onSelect = { ( ) => selectTab ( 'note' ) }
132
134
>
133
135
Page Notes
134
136
</ Tab >
135
137
{ orphanCount > 0 && (
136
138
< Tab
137
139
count = { orphanCount }
138
140
isWaitingToAnchor = { isWaitingToAnchorAnnotations }
139
- isSelected = { selectedTab === uiConstants . TAB_ORPHANS }
141
+ isSelected = { selectedTab === 'orphan' }
140
142
label = "Orphans"
141
- onSelect = { ( ) => selectTab ( uiConstants . TAB_ORPHANS ) }
143
+ onSelect = { ( ) => selectTab ( 'orphan' ) }
142
144
>
143
145
Orphans
144
146
</ Tab >
145
147
) }
146
148
</ div >
147
- { selectedTab === uiConstants . TAB_NOTES &&
148
- settings . enableExperimentalNewNoteButton && < NewNoteBtn /> }
149
+ { selectedTab === 'note' && settings . enableExperimentalNewNoteButton && (
150
+ < NewNoteBtn />
151
+ ) }
149
152
{ ! isLoading && showNotesUnavailableMessage && (
150
153
< div className = "SelectionTabs__message" >
151
154
There are no page notes in this group.
0 commit comments