@@ -6,6 +6,7 @@ import {toggleElem} from '../utils/dom.js';
66import {formatDatetime } from ' ../utils/time.js' ;
77import {renderAnsi } from ' ../render/ansi.js' ;
88import {GET , POST , DELETE } from ' ../modules/fetch.js' ;
9+ import {htmlEscape } from ' escape-goat' ;
910
1011const sfc = {
1112 name: ' RepoActionView' ,
@@ -151,9 +152,9 @@ const sfc = {
151152 POST (` ${ this .run .link } /approve` );
152153 },
153154
154- createLogLine (line , startTime , stepIndex ) {
155+ createLogLine (line , startTime , stepIndex , {classNames, wrappings} = {} ) {
155156 const div = document .createElement (' div' );
156- div .classList .add (' job-log-line' );
157+ div .classList .add (' job-log-line' , ... classNames );
157158 div .setAttribute (' id' , ` jobstep-${ stepIndex} -${ line .index } ` );
158159 div ._jobLogTime = line .timestamp ;
159160
@@ -179,19 +180,50 @@ const sfc = {
179180
180181 const logMessage = document .createElement (' span' );
181182 logMessage .className = ' log-msg' ;
182- logMessage .innerHTML = renderAnsi (line .message );
183- div .append (logTimeStamp);
184- div .append (logMessage);
185- div .append (logTimeSeconds);
186183
184+ let html = renderAnsi (line .message );
185+ for (const [before , after ] of wrappings) {
186+ html = ` ${ before}${ html}${ after} ` ;
187+ }
188+ logMessage .innerHTML = html;
189+
190+ div .append (logTimeStamp, logMessage, logTimeSeconds);
187191 return div;
188192 },
189193
194+ getLineHTML ({message, index, timestamp}, startTime , stepIndex ) {
195+ const wrappings = [];
196+ const classNames = [];
197+
198+ if (message .startsWith (' ::endgroup::' )) {
199+ classNames .push (' endgroup' );
200+ } else if (message .startsWith (' ::add-matcher' )) {
201+ classNames .push (' add-matcher' );
202+ } else if (message .startsWith (' ::remove-matcher' )) {
203+ classNames .push (' remove-matcher' );
204+ } else {
205+ if (message .startsWith (' ::group::' )) {
206+ message = message .substring (9 );
207+ wrappings .push ([' <details><summary>' , ' </summary></details>' ]);
208+ }
209+ if (message .startsWith (' ::error::' )) {
210+ message = message .substring (9 );
211+ wrappings .push ([' <span class="tw-text-red">' , ' </span>' ]);
212+ }
213+ if (message .startsWith (' [command]' )) {
214+ message = message .substring (9 );
215+ wrappings .push ([' <span class="tw-text-blue">' , ' </span>' ]);
216+ }
217+ }
218+
219+ return this .createLogLine ({message, index, timestamp}, startTime, stepIndex, {classNames, wrappings});
220+ },
221+
190222 appendLogs (stepIndex , logLines , startTime ) {
223+ const el = this .getLogsContainer (stepIndex);
224+
191225 for (const line of logLines) {
192- // TODO: group support: ##[group]GroupTitle , ##[endgroup]
193- const el = this .getLogsContainer (stepIndex);
194- el .append (this .createLogLine (line, startTime, stepIndex));
226+ el .append (this .getLineHTML (line, startTime, stepIndex));
195227 }
196228 },
197229
@@ -789,6 +821,12 @@ export function initRepositoryActionView() {
789821 scroll- margin- top: 95px ;
790822}
791823
824+ .job - log- line .add - matcher,
825+ .job - log- line .remove - matcher,
826+ .job - log- line .endgroup {
827+ display: none ! important;
828+ }
829+
792830/* class names 'log-time-seconds' and 'log-time-stamp' are used in the method toggleTimeDisplay */
793831.job - log- line .line - num, .log - time- seconds {
794832 width: 48px ;
0 commit comments