Skip to content

Commit

Permalink
feat: trial warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Nov 6, 2023
1 parent 7bb73dd commit 9da45a9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/components/LogViewer/LogAccordion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import { StyledLogAccordion } from '../StyledLogViewer';

const LogAccordion = forwardRef(
({ children, onToggle, header, className = '', defaultValue = false, metadata = '' }, ref) => {
({ children, onToggle, header, className = '', defaultValue = false, metadata = ['', false] }, ref) => {
const logsTopRef = useRef(null);
const logsEndRef = useRef(null);
const [visibility, setVisibility] = useState(defaultValue);
Expand All @@ -30,14 +30,14 @@ const LogAccordion = forwardRef(
return (
<StyledLogAccordion className={className}>
<div
className={`accordion-heading`}
className={metadata[1] == true ? `accordion-heading accordion-heading-warning` : `accordion-heading`}
onClick={e => {
setVisibility(!visibility);
if (onToggle) onToggle(!visibility);
}}
>
<div key="1" className={'log-header' + (visibility ? ' visible' : '')}>
{header} {metadata.length > 0 ? '(' + metadata + ')' : ''}
<div key="1" className={'log-header' + (metadata[1] == true ? ' log-warning-state' : '') + (visibility ? ' visible' : '')}>
{header} {metadata[0].length > 0 ? '(' + metadata[0] + ')' : ''} {metadata[1] == true ? '(WARNING)' : ''}
</div>
</div>
<div ref={logsTopRef} />
Expand Down
16 changes: 16 additions & 0 deletions src/components/LogViewer/StyledLogViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,20 @@ export const StyledLogAccordion = styled.div`
}
}
}
&.data-row {
.accordion-heading {
.log-warning-state {
::before {
color: #000000;
background-color: #806003;
}
}
}
}
&.data-row {
.accordion-heading-warning {
color: #000000;
background-color: #c79d1e;
}
}
`;
10 changes: 7 additions & 3 deletions src/components/LogViewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const logPreprocessorProcessParse = (tokens, sectionMetadata) => {
case 'section-opener':
let metadataForSection = sectionMetadata.get(tokens[i].details.trim());
if (metadataForSection == undefined) {
metadataForSection = '';
metadataForSection = ['', false]
}

let node = {
Expand Down Expand Up @@ -167,11 +167,15 @@ const logPreprocessorExtractSectionEndDetails = logs => {
let stepName = tokens[i].trim();
i++;
let stepDetails = tokens[i].trim();

if (stepName != '' && stepDetails != '') {
let durationArray = stepDetails.match(durationRegexp);
let hasWarnings = false
if (stepDetails.match(/.* WithWarnings$/)) {
hasWarnings = true
}
let payload = [`Duration: ${durationArray[1]}`, hasWarnings]
if (durationArray.length == 2) {
ret.set(stepName, `Duration: ${durationArray[1]}`);
ret.set(stepName, payload);
}
}
}
Expand Down

0 comments on commit 9da45a9

Please sign in to comment.