@@ -14,42 +14,48 @@ import {
14
14
import { SettingsRow } from '../settings-row' ;
15
15
import { STORE_NAME } from '../../data/store' ;
16
16
import { PromptRepeater } from './prompt-repeater' ;
17
+ import { getFeature } from '../../utils/utils' ;
18
+ import { useFeatureContext } from '../feature-settings/context' ;
17
19
18
20
/**
19
21
* Component for Excerpt Generation feature settings.
20
22
*
21
23
* This component is used within the FeatureSettings component to allow users to configure the Excerpt Generation feature.
22
24
*
23
- * @param {Object } props Component props.
24
- * @param {boolean } [props.showPrompt=true] Whether to show the prompt settings row.
25
- * @param {boolean } [props.showPostTypes=true] Whether to show the post types settings row.
26
- * @param {boolean } [props.showLength=true] Whether to show the excerpt length settings row.
25
+ * @param {Object } props Component props.
26
+ * @param {boolean } [props.showPrompt=true] Whether to show the prompt settings row.
27
+ * @param {boolean } [props.showPostTypes=true] Whether to show the post types settings row.
28
+ * @param {boolean } [props.showLength=true] Whether to show the excerpt length settings row.
29
+ *
27
30
* @return {React.ReactElement } ExcerptGenerationSettings component.
28
31
*/
29
- export const ExcerptGenerationSettings = ( {
30
- showPrompt = true ,
31
- showPostTypes = true ,
32
- showLength = true
32
+ export const ExcerptGenerationSettings = ( {
33
+ showPrompt = true ,
34
+ showPostTypes = true ,
35
+ showLength = true ,
33
36
} = { } ) => {
37
+ const { featureName } = useFeatureContext ( ) ;
38
+ const feature = getFeature ( featureName ) ;
39
+
34
40
// determine which provider is currently loaded
35
41
const provider = useSelect (
36
42
( select ) =>
37
43
select ( STORE_NAME ) . getFeatureSettings ( 'provider' ) ||
38
44
Object . keys ( feature ?. providers || { } ) [ 0 ]
39
45
) ;
40
-
46
+
41
47
/**
42
48
* These fields don't apply to Azure Language. Azure has its own keyed fields. This parameter is
43
49
* filtered at Classifai\Providers\Azure\Language (classifai_azure_language_summary_length)
44
- *
50
+ *
45
51
* There is likely a better way to handle this where the individual provider configs can govern
46
52
* the fields that are shown. For now this is a quick fix.
47
53
*/
48
54
if ( provider === 'azure_language' ) {
49
55
showPrompt = false ;
50
56
showLength = false ;
51
57
}
52
-
58
+
53
59
const featureSettings = useSelect ( ( select ) =>
54
60
select ( STORE_NAME ) . getFeatureSettings ( )
55
61
) ;
0 commit comments