@@ -42,7 +42,8 @@ import { useHistory, useLocation } from 'react-router';
4242
4343import { CodeEditor , EDITOR_THEME_MAP , StatusCell , StatusGroup , useSnackbar } from 'app/components' ;
4444import { usePluginConfig } from 'app/containers/admin/plugins/plugin-gql' ;
45- import { GQLClusterStatus , GQLEditableRetentionScript } from 'app/types/schema' ;
45+ import { SCRIPT_MODIFICATION_DISABLED } from 'app/containers/constants' ;
46+ import { GQLClusterStatus , GQLDetailedRetentionScript , GQLEditableRetentionScript } from 'app/types/schema' ;
4647import { AutoSizerContext , withAutoSizerContext } from 'app/utils/autosizer' ;
4748import { allowRetentionScriptName } from 'configurable/data-export' ;
4849
@@ -121,9 +122,21 @@ interface RetentionScriptEditorProps {
121122 initialValue : string ;
122123 onChange : ( value : string ) => void ;
123124 isReadOnly : boolean ;
125+ readOnlyReason : string ;
124126}
127+
128+ const getReadOnlyReason = ( script : GQLDetailedRetentionScript | null ) : string | undefined => {
129+ if ( script ?. isPreset ) {
130+ return 'PxL for preset scripts cannot be edited' ;
131+ }
132+ if ( SCRIPT_MODIFICATION_DISABLED ) {
133+ return 'Editing retention scripts is disabled.' ;
134+ }
135+ return undefined ;
136+ } ;
137+
125138const RetentionScriptEditorInner = React . memo < RetentionScriptEditorProps > ( ( {
126- initialValue, onChange, isReadOnly = false ,
139+ initialValue, onChange, isReadOnly = false , readOnlyReason ,
127140} ) => {
128141 const { width, height } = React . useContext ( AutoSizerContext ) ;
129142 const theme = useTheme ( ) ;
@@ -152,7 +165,7 @@ const RetentionScriptEditorInner = React.memo<RetentionScriptEditorProps>(({
152165 language = 'python'
153166 theme = { EDITOR_THEME_MAP [ theme . palette . mode ] }
154167 isReadOnly = { isReadOnly }
155- readOnlyReason = 'PxL for preset scripts cannot be edited'
168+ readOnlyReason = { readOnlyReason }
156169 />
157170 </ div >
158171 ) ;
@@ -497,7 +510,8 @@ export const EditDataExportScript = React.memo<{ scriptId: string, isCreate: boo
497510 < RetentionScriptEditor
498511 initialValue = { pendingValues . contents }
499512 onChange = { ( v ) => setPendingField ( 'contents' , v ) }
500- isReadOnly = { script ?. isPreset }
513+ isReadOnly = { script ?. isPreset || SCRIPT_MODIFICATION_DISABLED }
514+ readOnlyReason = { getReadOnlyReason ( script ) }
501515 />
502516 </ div >
503517 </ Paper >
0 commit comments