diff --git a/changes/27255-hide-script-content-for-saved-scripts b/changes/27255-hide-script-content-for-saved-scripts new file mode 100644 index 0000000000..57232d39b2 --- /dev/null +++ b/changes/27255-hide-script-content-for-saved-scripts @@ -0,0 +1,2 @@ +- To prevent misleading UI when a saved script's contents have changed, only show a run script + activity's script contents if the script run was ad-hoc diff --git a/frontend/pages/DashboardPage/cards/ActivityFeed/components/RunScriptDetailsModal/RunScriptDetailsModal.tsx b/frontend/pages/DashboardPage/cards/ActivityFeed/components/RunScriptDetailsModal/RunScriptDetailsModal.tsx index e806260bd7..f467d3bc08 100644 --- a/frontend/pages/DashboardPage/cards/ActivityFeed/components/RunScriptDetailsModal/RunScriptDetailsModal.tsx +++ b/frontend/pages/DashboardPage/cards/ActivityFeed/components/RunScriptDetailsModal/RunScriptDetailsModal.tsx @@ -119,10 +119,15 @@ const StatusMessage = ({ interface IScriptOutputProps { output: string; hostname: string; + wasAdHoc: boolean; } -const ScriptOutput = ({ output, hostname }: IScriptOutputProps) => { - return ( +const ScriptOutput = ({ + output, + hostname, + wasAdHoc = false, +}: IScriptOutputProps) => ( +
- ); -}; - -interface IScriptResultProps { - hostname: string; - output: string; -} - -const ScriptResult = ({ hostname, output }: IScriptResultProps) => { - return ( -
- -
- ); -}; - +
+); interface IRunScriptDetailsModalProps { scriptExecutionId: string; onCancel: () => void; @@ -209,6 +200,7 @@ const RunScriptDetailsModal = ({ data.exit_code === null && data.host_timeout === false; const showOutputText = !hostTimedOut && !scriptsDisabledForHost && !scriptStillRunning; + const ranAdHocScript = data.script_id === null; content = ( <> @@ -217,9 +209,13 @@ const RunScriptDetailsModal = ({ exitCode={data.exit_code} message={data.output} /> - + {ranAdHocScript && } {showOutputText && ( - + )} ); diff --git a/frontend/services/entities/scripts.ts b/frontend/services/entities/scripts.ts index 118da2e314..7724107bfc 100644 --- a/frontend/services/entities/scripts.ts +++ b/frontend/services/entities/scripts.ts @@ -33,7 +33,7 @@ export interface IScriptResultResponse { host_id: number; execution_id: string; script_contents: string; - script_id: number; + script_id: number | null; // null for ad-hoc script run via API exit_code: number | null; output: string; message: string;