@@ -6,6 +6,7 @@ import {toggleElem} from '../utils/dom.js';
6
6
import {formatDatetime } from ' ../utils/time.js' ;
7
7
import {renderAnsi } from ' ../render/ansi.js' ;
8
8
import {GET , POST , DELETE } from ' ../modules/fetch.js' ;
9
+ import {htmlEscape } from ' escape-goat' ;
9
10
10
11
const sfc = {
11
12
name: ' RepoActionView' ,
@@ -151,9 +152,9 @@ const sfc = {
151
152
POST (` ${ this .run .link } /approve` );
152
153
},
153
154
154
- createLogLine (line , startTime , stepIndex ) {
155
+ createLogLine (line , startTime , stepIndex , {classNames, wrappings} = {} ) {
155
156
const div = document .createElement (' div' );
156
- div .classList .add (' job-log-line' );
157
+ div .classList .add (' job-log-line' , ... classNames );
157
158
div .setAttribute (' id' , ` jobstep-${ stepIndex} -${ line .index } ` );
158
159
div ._jobLogTime = line .timestamp ;
159
160
@@ -179,19 +180,50 @@ const sfc = {
179
180
180
181
const logMessage = document .createElement (' span' );
181
182
logMessage .className = ' log-msg' ;
182
- logMessage .innerHTML = renderAnsi (line .message );
183
- div .append (logTimeStamp);
184
- div .append (logMessage);
185
- div .append (logTimeSeconds);
186
183
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);
187
191
return div;
188
192
},
189
193
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
+
190
222
appendLogs (stepIndex , logLines , startTime ) {
223
+ const el = this .getLogsContainer (stepIndex);
224
+
191
225
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));
195
227
}
196
228
},
197
229
@@ -789,6 +821,12 @@ export function initRepositoryActionView() {
789
821
scroll- margin- top: 95px ;
790
822
}
791
823
824
+ .job - log- line .add - matcher,
825
+ .job - log- line .remove - matcher,
826
+ .job - log- line .endgroup {
827
+ display: none ! important;
828
+ }
829
+
792
830
/* class names 'log-time-seconds' and 'log-time-stamp' are used in the method toggleTimeDisplay */
793
831
.job - log- line .line - num, .log - time- seconds {
794
832
width: 48px ;
0 commit comments