From 9bd3a3df8dd2db8afd0b51574a22d0b062a2fde4 Mon Sep 17 00:00:00 2001 From: jacobshandling <61553566+jacobshandling@users.noreply.github.com> Date: Tue, 13 May 2025 11:16:27 -0700 Subject: [PATCH] UI: Hide script contents for saved script run activity details (#29064) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## For #27255 - Hide script contents when a saved script was run - Clean up code Screenshot 2025-05-12 at 3 39 32 PM - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling --- ...7255-hide-script-content-for-saved-scripts | 2 + .../RunScriptDetailsModal.tsx | 38 +++++++++---------- frontend/services/entities/scripts.ts | 2 +- 3 files changed, 20 insertions(+), 22 deletions(-) create mode 100644 changes/27255-hide-script-content-for-saved-scripts 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;