33 * License: MS-RSL – see LICENSE.md for details
44 */
55
6- import { Space } from "antd" ;
6+ import { Space , Tooltip } from "antd" ;
77import * as immutable from "immutable" ;
8- import { throttle } from "lodash" ;
9- import React , { useEffect , useRef , useState } from "react" ;
8+ import React , { useEffect , useState } from "react" ;
109import { FormattedMessage , useIntl } from "react-intl" ;
11-
1210import { Button , ButtonToolbar } from "@cocalc/frontend/antd-bootstrap" ;
1311import { Gap , Icon } from "@cocalc/frontend/components" ;
1412import { useStudentProjectFunctionality } from "@cocalc/frontend/course" ;
@@ -20,8 +18,6 @@ import { file_actions, ProjectActions } from "@cocalc/frontend/project_store";
2018import * as misc from "@cocalc/util/misc" ;
2119import { COLORS } from "@cocalc/util/theme" ;
2220
23- import { useProjectContext } from "../context" ;
24-
2521const ROW_INFO_STYLE = {
2622 color : COLORS . GRAY ,
2723 height : "22px" ,
@@ -45,10 +41,6 @@ interface Props {
4541
4642export const ActionBar : React . FC < Props > = ( props : Props ) => {
4743 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 ) ;
5244 const [ select_entire_directory , set_select_entire_directory ] = useState <
5345 "hidden" | "check" | "clear"
5446 > ( "hidden" ) ;
@@ -76,34 +68,6 @@ export const ActionBar: React.FC<Props> = (props: Props) => {
7668 }
7769 } , [ props . checked_files , props . listing , select_entire_directory ] ) ;
7870
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-
10771 function clear_selection ( ) : void {
10872 props . actions . set_all_files_unchecked ( ) ;
10973 if ( select_entire_directory !== "hidden" ) {
@@ -255,10 +219,12 @@ export const ActionBar: React.FC<Props> = (props: Props) => {
255219 } ;
256220
257221 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 >
262228 ) ;
263229 }
264230
@@ -337,7 +303,7 @@ export const ActionBar: React.FC<Props> = (props: Props) => {
337303 }
338304 return (
339305 < div style = { { flex : "1 0 auto" } } >
340- < div ref = { buttonRef } style = { { flex : "1 0 auto" } } >
306+ < div style = { { flex : "1 0 auto" } } >
341307 < ButtonToolbar style = { { whiteSpace : "nowrap" , padding : "0" } } >
342308 < Space . Compact >
343309 { props . project_is_running ? render_check_all_button ( ) : undefined }
0 commit comments