@@ -66,15 +66,32 @@ const Button = ({
6666 authConfig,
6767 signedInOnly,
6868 user,
69+ onlySupportType,
70+ type,
6971} ) => {
7072 const posthog = usePosthog ( )
71- const disabled = desktopOnly
72- ? ! isDesktop
73- : authConfiguredOnly
74- ? signedInOnly
75- ? isEmpty ( user )
76- : isEmpty ( authConfig )
77- : false
73+
74+ const isDisabled = ( ) => {
75+ if ( desktopOnly ) {
76+ return { disabled : ! isDesktop , disabledText : "DESKTOP ONLY" }
77+ } else if ( onlySupportType && ! onlySupportType . includes ( type ) ) {
78+ return { disabled : true , disabledText : `DOESN'T SUPPORT THIS INTERFACE` }
79+ } else if ( authConfiguredOnly ) {
80+ if ( signedInOnly ) {
81+ return { disabled : isEmpty ( user ) , disabledText : "MUST BE SIGNED IN" }
82+ } else {
83+ return {
84+ disabled : isEmpty ( authConfig ) ,
85+ disabledText : "AUTH MUST BE CONFIGURED" ,
86+ }
87+ }
88+ } else {
89+ return { disabled : false , disabledText : "" }
90+ }
91+ }
92+
93+ const { disabled, disabledText } = isDisabled ( )
94+
7895 return (
7996 < SelectDialogContext . Consumer >
8097 { ( { onChangeDialog } ) => {
@@ -93,19 +110,9 @@ const Button = ({
93110 < div >
94111 < Icon className = { classnames ( "icon" , { disabled } ) } />
95112 < div > { children } </ div >
96- { desktopOnly && (
97- < DesktopOnlyText className = { classnames ( { disabled } ) } >
98- DESKTOP ONLY
99- </ DesktopOnlyText >
100- ) }
101- { authConfiguredOnly && isEmpty ( authConfig ) && (
113+ { disabled && (
102114 < DesktopOnlyText className = { classnames ( { disabled } ) } >
103- AUTH MUST BE CONFIGURED
104- </ DesktopOnlyText >
105- ) }
106- { signedInOnly && isEmpty ( user ) && (
107- < DesktopOnlyText className = { classnames ( { disabled } ) } >
108- MUST BE SIGNED IN
115+ { disabledText }
109116 </ DesktopOnlyText >
110117 ) }
111118 </ div >
@@ -185,7 +192,12 @@ export default ({
185192 >
186193 Files from Directory
187194 </ Button >
188- < Button dialog = "import-text-snippets" Icon = { TextFieldsIcon } >
195+ < Button
196+ dialog = "import-text-snippets"
197+ Icon = { TextFieldsIcon }
198+ onlySupportType = { [ "text_entity_recognition" , "text_classification" ] }
199+ type = { dataset . interface . type }
200+ >
189201 Import Text Snippets
190202 </ Button >
191203 < Button
0 commit comments