5
5
6
6
import type { ButtonProps } from "antd" ;
7
7
import { Button } from "antd" ;
8
- import { CSSProperties , FC , memo , useMemo } from "react" ;
8
+ import { CSSProperties , useMemo } from "react" ;
9
9
import { useIntl } from "react-intl" ;
10
10
11
11
import {
@@ -30,75 +30,72 @@ interface Props {
30
30
type ?: "default" ; // only used to turn off color in case of dark mode right now
31
31
}
32
32
33
- export const SaveButton : FC < Props > = memo (
34
- ( {
35
- has_unsaved_changes,
36
- has_uncommitted_changes,
37
- read_only,
38
- is_public,
39
- is_saving,
40
- no_labels,
41
- size,
42
- onClick,
43
- show_uncommitted_changes,
44
- set_show_uncommitted_changes,
45
- style,
46
- type,
47
- } : Props ) => {
48
- const intl = useIntl ( ) ;
33
+ export function SaveButton ( {
34
+ has_unsaved_changes,
35
+ has_uncommitted_changes,
36
+ read_only,
37
+ is_public,
38
+ is_saving,
39
+ no_labels,
40
+ size,
41
+ onClick,
42
+ show_uncommitted_changes,
43
+ set_show_uncommitted_changes,
44
+ style,
45
+ type,
46
+ } : Props ) {
47
+ const intl = useIntl ( ) ;
49
48
50
- const label = useMemo ( ( ) => {
51
- if ( ! no_labels ) {
52
- return intl . formatMessage (
53
- labels . frame_editors_title_bar_save_label ,
54
- { type : is_public ? "is_public" : read_only ? "read_only" : "save" } ,
55
- ) ;
56
- } else {
57
- return null ;
58
- }
59
- } , [ no_labels , is_public , read_only ] ) ;
49
+ const label = useMemo ( ( ) => {
50
+ if ( ! no_labels ) {
51
+ return intl . formatMessage ( labels . frame_editors_title_bar_save_label , {
52
+ type : is_public ? "is_public" : read_only ? "read_only" : "save" ,
53
+ } ) ;
54
+ } else {
55
+ return null ;
56
+ }
57
+ } , [ no_labels , is_public , read_only ] ) ;
60
58
61
- const disabled = useMemo (
62
- ( ) => ! has_unsaved_changes || ! ! read_only || ! ! is_public ,
63
- [ has_unsaved_changes , read_only , is_public ] ,
64
- ) ;
59
+ const disabled = useMemo (
60
+ ( ) => ! has_unsaved_changes || ! ! read_only || ! ! is_public ,
61
+ [ has_unsaved_changes , read_only , is_public ] ,
62
+ ) ;
65
63
66
- const icon = useMemo (
67
- ( ) => ( is_saving ? "arrow-circle-o-left" : "save" ) ,
68
- [ is_saving ] ,
69
- ) ;
64
+ const icon = useMemo (
65
+ ( ) => ( is_saving ? "arrow-circle-o-left" : "save" ) ,
66
+ [ is_saving ] ,
67
+ ) ;
70
68
71
- function renderLabel ( ) {
72
- if ( ! no_labels && label ) {
73
- return < VisibleMDLG > { ` ${ label } ` } </ VisibleMDLG > ;
74
- }
69
+ function renderLabel ( ) {
70
+ if ( ! no_labels && label ) {
71
+ return < VisibleMDLG > { ` ${ label } ` } </ VisibleMDLG > ;
75
72
}
73
+ }
76
74
77
- // The funny style in the icon below is because the width changes
78
- // slightly depending on which icon we are showing.
79
- // whiteSpace:"nowrap" due to https://github.com/sagemathinc/cocalc/issues/4434
80
- return (
81
- < Button
82
- size = { size }
83
- disabled = { disabled }
84
- onClick = { onClick }
85
- style = { {
86
- ...( type == "default"
87
- ? undefined
88
- : { background : "#5cb85c" , color : "#333" } ) ,
89
- opacity : disabled ? 0.65 : undefined ,
90
- whiteSpace : "nowrap" ,
91
- ...style ,
92
- } }
93
- >
94
- < Icon name = { icon } style = { { display : "inline-block" } } />
95
- { renderLabel ( ) }
96
- < UncommittedChanges
97
- has_uncommitted_changes = { has_uncommitted_changes }
98
- show_uncommitted_changes = { show_uncommitted_changes }
99
- set_show_uncommitted_changes = { set_show_uncommitted_changes }
100
- />
101
- </ Button >
102
- ) ;
103
- } ,
104
- ) ;
75
+ // The funny style in the icon below is because the width changes
76
+ // slightly depending on which icon we are showing.
77
+ // whiteSpace:"nowrap" due to https://github.com/sagemathinc/cocalc/issues/4434
78
+ return (
79
+ < Button
80
+ size = { size }
81
+ disabled = { disabled }
82
+ onClick = { onClick }
83
+ style = { {
84
+ ...( type == "default"
85
+ ? undefined
86
+ : { background : "#5cb85c" , color : "#333" } ) ,
87
+ opacity : disabled ? 0.65 : undefined ,
88
+ whiteSpace : "nowrap" ,
89
+ ...style ,
90
+ } }
91
+ >
92
+ < Icon name = { icon } style = { { display : "inline-block" } } />
93
+ { renderLabel ( ) }
94
+ < UncommittedChanges
95
+ has_uncommitted_changes = { has_uncommitted_changes }
96
+ show_uncommitted_changes = { show_uncommitted_changes }
97
+ set_show_uncommitted_changes = { set_show_uncommitted_changes }
98
+ />
99
+ </ Button >
100
+ ) ;
101
+ }
0 commit comments