apps.websight-package-manager.web-resources.components.ActivityLog.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of websight-package-manager-view Show documentation
Show all versions of websight-package-manager-view Show documentation
Package Manager View module is responsible for view part of Package Manager.
The newest version!
import React from "/apps/websight-atlaskit-esm/web-resources/react.js";
import { colors } from "/apps/websight-admin/web-resources/theme.js";
export const Separator = () => {
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("hr", {
style: {
borderWidth: '1px 0px 0px 0px',
color: colors.white
}
}), /*#__PURE__*/React.createElement("br", null));
};
const Header = props => {
const {
title,
path,
date
} = props;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("b", null, title, ":"), " ", path), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("span", null, date.toString()), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null));
};
const Footer = props => {
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(ExecutionTime, props));
};
const ExecutionTime = props => {
const {
title,
timeInMillis
} = props;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, title, " in ", timeInMillis, "ms."), /*#__PURE__*/React.createElement("br", null));
};
const Filter = props => {
const spaces = ' '; // no tabs in html
const pathStartColumnIndex = 10;
const {
mode,
root,
rules
} = props.filter;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, mode.toLowerCase(), ":", spaces.substr(0, pathStartColumnIndex - mode.length) + root), /*#__PURE__*/React.createElement("br", null), (rules || []).map(rule => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Rule, rule), /*#__PURE__*/React.createElement("br", null))));
};
const Rule = props => {
const {
include,
pattern
} = props;
const content = ' ' + (include ? 'include' : 'exclude') + ': ' + pattern;
return /*#__PURE__*/React.createElement("span", {
style: {
color: include ? colors.veryDarkGreen : colors.red
}
}, content);
};
export const Filters = props => {
const header = /*#__PURE__*/React.createElement(Header, {
title: "Show Filters",
path: props.path,
date: props.date
});
const footer = /*#__PURE__*/React.createElement(Footer, {
title: "Filters shown",
timeInMillis: 0
});
if ((props.filters || []).length === 0) {
return /*#__PURE__*/React.createElement(React.Fragment, null, header, /*#__PURE__*/React.createElement("span", null, "Package ", props.name, " has no filters"), /*#__PURE__*/React.createElement("br", null), footer);
}
const filters = [];
let previousFilterHadRules = true;
(props.filters || []).forEach(filter => {
const hasRules = (filter.rules || []).length > 0;
if (hasRules || previousFilterHadRules) {
filters.push( /*#__PURE__*/React.createElement("br", null));
}
filters.push( /*#__PURE__*/React.createElement(Filter, {
filter: filter
}));
previousFilterHadRules = hasRules;
});
return /*#__PURE__*/React.createElement(React.Fragment, null, header, /*#__PURE__*/React.createElement("span", null, "Package ", props.name, " filters:"), /*#__PURE__*/React.createElement("br", null), filters, footer);
};
const ShowFullLogHeader = props => {
const endpoint = '/apps/websight-package-manager-service/bin/package.log';
const fullUri = `${endpoint}?path=${props.path}`;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", {
href: fullUri,
target: "_blank",
rel: "noreferrer"
}, "Show Full Log"), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null));
};
const formattedLineStarts = ['Build Package:', 'Building package', 'Install Package: ', 'Installing content', 'Package Coverage Preview', 'Test Install Package:', 'Uninstall Package:', 'A ', 'D ', 'U ', '-'];
const formattedLines = ['Collecting import information...', 'Creating snapshot for', 'Dry Run: Skipping node types installation (might lead to errors).', 'Dump package coverage', 'Importing content...', 'Installing content (dry run)', 'Installing privileges...', 'Installing node types...', 'Package import simulation finished.', 'Package imported.', 'reverting approx', 'saving approx', 'Simulating content import...', 'Unable to revert package content', 'Uninstalling content', 'Uninstalling package'];
const checkIfLineStartShouldBeFormatted = line => {
return formattedLineStarts.find(lineStart => line.startsWith(lineStart));
};
const checkIfWholeLineShouldBeFormatted = line => {
return formattedLines.find(lineStart => line.startsWith(lineStart));
};
const checkIfIsFailedMessage = line => {
return line.match('^Package .+ failed.$');
};
export const PackageLogs = props => {
const result = (props.logs || []).map((line, index) => {
if (checkIfWholeLineShouldBeFormatted(line)) {
return /*#__PURE__*/React.createElement("span", {
key: index
}, /*#__PURE__*/React.createElement("b", null, line));
}
const lineStartToBeFormatted = checkIfLineStartShouldBeFormatted(line);
if (lineStartToBeFormatted) {
return /*#__PURE__*/React.createElement("span", {
key: index
}, /*#__PURE__*/React.createElement("b", null, lineStartToBeFormatted), line.substr(lineStartToBeFormatted.length));
}
if (checkIfIsFailedMessage(line)) {
return /*#__PURE__*/React.createElement("span", {
key: index,
style: {
color: colors.red
}
}, line);
}
return /*#__PURE__*/React.createElement("div", {
key: index
}, line);
});
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ShowFullLogHeader, {
path: props.path
}), result);
};