3
3
* License: MS-RSL – see LICENSE.md for details
4
4
*/
5
5
6
- import { Space } from "antd" ;
6
+ import { Space , Tooltip } from "antd" ;
7
7
import * as immutable from "immutable" ;
8
- import { throttle } from "lodash" ;
9
- import React , { useEffect , useRef , useState } from "react" ;
8
+ import React , { useEffect , useState } from "react" ;
10
9
import { FormattedMessage , useIntl } from "react-intl" ;
11
-
12
10
import { Button , ButtonToolbar } from "@cocalc/frontend/antd-bootstrap" ;
13
11
import { Gap , Icon } from "@cocalc/frontend/components" ;
14
12
import { useStudentProjectFunctionality } from "@cocalc/frontend/course" ;
@@ -20,8 +18,6 @@ import { file_actions, ProjectActions } from "@cocalc/frontend/project_store";
20
18
import * as misc from "@cocalc/util/misc" ;
21
19
import { COLORS } from "@cocalc/util/theme" ;
22
20
23
- import { useProjectContext } from "../context" ;
24
-
25
21
const ROW_INFO_STYLE = {
26
22
color : COLORS . GRAY ,
27
23
height : "22px" ,
@@ -45,10 +41,6 @@ interface Props {
45
41
46
42
export const ActionBar : React . FC < Props > = ( props : Props ) => {
47
43
const intl = useIntl ( ) ;
48
- const [ showLabels , setShowLabels ] = useState < boolean > ( true ) ;
49
- const { mainWidthPx } = useProjectContext ( ) ;
50
- const buttonRef = useRef < HTMLDivElement > ( null ) ;
51
- const widthThld = useRef < number > ( 0 ) ;
52
44
const [ select_entire_directory , set_select_entire_directory ] = useState <
53
45
"hidden" | "check" | "clear"
54
46
> ( "hidden" ) ;
@@ -76,34 +68,6 @@ export const ActionBar: React.FC<Props> = (props: Props) => {
76
68
}
77
69
} , [ props . checked_files , props . listing , select_entire_directory ] ) ;
78
70
79
- useEffect ( ( ) => {
80
- const btnbar = buttonRef . current ;
81
- if ( btnbar == null ) return ;
82
- const resizeObserver = new ResizeObserver (
83
- throttle (
84
- ( entries ) => {
85
- if ( entries . length > 0 ) {
86
- const width = entries [ 0 ] . contentRect . width ;
87
- // TODO: this "+100" is sloppy. This makes it much better than before
88
- // (e.g. german buttons were cutoff all the time), but could need more tweaking
89
- if ( showLabels && width > mainWidthPx + 100 ) {
90
- setShowLabels ( false ) ;
91
- widthThld . current = width ;
92
- } else if ( ! showLabels && width < widthThld . current - 1 ) {
93
- setShowLabels ( true ) ;
94
- }
95
- }
96
- } ,
97
- 100 ,
98
- { leading : false , trailing : true } ,
99
- ) ,
100
- ) ;
101
- resizeObserver . observe ( btnbar ) ;
102
- return ( ) => {
103
- resizeObserver . disconnect ( ) ;
104
- } ;
105
- } , [ mainWidthPx , buttonRef . current ] ) ;
106
-
107
71
function clear_selection ( ) : void {
108
72
props . actions . set_all_files_unchecked ( ) ;
109
73
if ( select_entire_directory !== "hidden" ) {
@@ -255,10 +219,12 @@ export const ActionBar: React.FC<Props> = (props: Props) => {
255
219
} ;
256
220
257
221
return (
258
- < Button onClick = { handle_click } disabled = { disabled } key = { name } >
259
- < Icon name = { obj . icon } /> { " " }
260
- { showLabels ? `${ intl . formatMessage ( obj . name ) } ...` : "" }
261
- </ Button >
222
+ < Tooltip title = { intl . formatMessage ( obj . name ) } >
223
+ < Button onClick = { handle_click } disabled = { disabled } key = { name } >
224
+ < Icon name = { obj . icon } />
225
+ </ Button >
226
+
227
+ </ Tooltip >
262
228
) ;
263
229
}
264
230
@@ -337,7 +303,7 @@ export const ActionBar: React.FC<Props> = (props: Props) => {
337
303
}
338
304
return (
339
305
< div style = { { flex : "1 0 auto" } } >
340
- < div ref = { buttonRef } style = { { flex : "1 0 auto" } } >
306
+ < div style = { { flex : "1 0 auto" } } >
341
307
< ButtonToolbar style = { { whiteSpace : "nowrap" , padding : "0" } } >
342
308
< Space . Compact >
343
309
{ props . project_is_running ? render_check_all_button ( ) : undefined }
0 commit comments