Skip to content

Commit

Permalink
Updating rule server
Browse files Browse the repository at this point in the history
  • Loading branch information
Erick Renteria committed Mar 13, 2022
1 parent 05722e3 commit 184f732
Show file tree
Hide file tree
Showing 172 changed files with 66,523 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rule-server/src/static/archives.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
{
"id": "03March2022",
"name": "03 March 2022 Deployment",
"path": "/archives/2022.03.03",
"path": "/archives/2022.03.12",
"latest": true
},
{
"id": "03March2022",
"name": "03 March 2022 Deployment",
"path": "/archives/2022.03.03"
},
{
"id": "01February2022",
"name": "01 February 2022 Deployment",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
154 changes: 154 additions & 0 deletions rule-server/src/static/archives/2022.03.12/doc/common/help.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/******************************************************************************
Copyright:: 2022- IBM, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*****************************************************************************/
@import url('https://unpkg.com/carbon-components/css/carbon-components.min.css');

bx-list-item>code, p>code, td>code {
background-color: #e0e0e0;
border-radius: 4px;
bottom: 0.0625em;
color: #161616;
display: inline;
font-size: .75rem;
font-size: .875em;
font-weight: 400;
letter-spacing: .32px;
line-height: 1.33333;
padding: 0 0.5em;
position: relative;
}

.toolHelp .toolMain p ~ p {
margin-top: .5rem;
}

.toolHelp .toolHead h3 {
font-size: 20px;
line-height: 28px;
font-weight: 600;
}

.toolHelp .toolHead .issueLevel {
font-weight: 600;
}

/* body-long-02 */
.toolHelp .toolHead p {
font-size: 16px;
line-height: 24px;
font-weight: 400;
}

/* productive-heading-03 */
.toolHelp .toolMain h3 {
font-size: 20px;
line-height: 28px;
font-weight: 400;
}

/* body-long-02 */
.toolHelp .toolMain p {
font-size: 16px;
line-height: 24px;
font-weight: 400;
}

.toolHelp .toolSide .bx--list__item {
color: black;
font-size: 0.875rem;
line-height: 18px;
}

/* productive-heading-03 */
.toolHelp .toolSide h3 {
font-size: 20px;
line-height: 28px;
font-weight: 400;
}
.toolHelp .toolSide p {
font-size: 20px;
line-height: 28px;
font-weight: 400;
}

html, body, .toolHelp .bx--row:nth-child(2) {
height: 100%;
}

body {
font-family: 'IBM Plex Sans', sans-serif;
}

.toolHelp {
padding: 0px;
margin: 0px;
max-width: 100%;
background-color: #be95ff;
}

.toolHelp .bx--row {
margin: 0px;
}

.toolHelp .toolHead {
margin-bottom: 1rem;
padding-top: 1rem;
}
.toolHelp .toolMain {
background-color: #f4f4f4;
padding-top: 1rem;
padding-bottom: 1rem;
}
.toolHelp .toolMain h2 {
margin-top: 32px;
margin-bottom: 0.5rem;
}
.toolHelp .toolMain h3 {
margin-top: 1.5rem;
margin-bottom: 0.5rem;
}
.toolHelp .toolMain p {
margin-top: 0px;
}

.toolHelp .toolSide {
padding: 16px 16px 16px 32px;
background-color: #e8daff;
color: black;
}
.toolHelp .toolSide h2 {
margin-top: 32px;
margin-bottom: 0.5rem;
}
.toolHelp .toolSide h3 {
margin-top: 1.5rem;
margin-bottom: 0.5rem;
}
.toolHelp .toolSide p {
margin-top: 0px;
}
@media (min-width: 66rem) {
.toolHelp .toolMain p, bx-list-item {
max-width: 66.66%;
}
}
bx-code-snippet[type="multi"]::after {
height: 0px;
}

#ruleInfo {
margin-top: 1rem;
}

#ruleInfo p {
font-size: 14px;
}
154 changes: 154 additions & 0 deletions rule-server/src/static/archives/2022.03.12/doc/common/help.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/******************************************************************************
Copyright:: 2022- IBM, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*****************************************************************************/

class HTMLBaseElement extends HTMLElement {
constructor(...args) {
const self = super(...args);
self.parsed = false; // guard to make it easy to do certain stuff only once
self.parentNodes = [];
return self;
}

connectedCallback() {
// collect the parentNodes
let el = this;
while (el.parentNode) {
el = el.parentNode;
this.parentNodes.push(el);
}
// check if the parser has already passed the end tag of the component
// in which case this element, or one of its parents, should have a nextSibling
// if not (no whitespace at all between tags and no nextElementSiblings either)
// resort to DOMContentLoaded or load having triggered
if ([this, ...this.parentNodes].some((el) => el.nextSibling) || document.readyState !== "loading") {
this.childrenAvailableCallback();
this.parsed = true;
} else {
this.mutationObserver = new MutationObserver(() => {
if ([this, ...this.parentNodes].some((el) => el.nextSibling) || document.readyState !== "loading") {
this.childrenAvailableCallback();
this.parsed = true;
this.mutationObserver.disconnect();
}
});

this.mutationObserver.observe(this, {
childList: true,
});
}
}
}

customElements.define(
"mark-down",
class extends HTMLBaseElement {
constructor() {
super();
setTimeout(() => {
let converted = marked.parse(this.textContent);
this.innerHTML = converted
.replace(/<(\/?)ul>/g, "<$1bx-unordered-list>")
.replace(/<(\/?)li>/g, "<$1bx-list-item>")
.replace(/<a href/g, "<a target='_blank' rel='noopener noreferrer' href")
.replace(/<pre>[ \r\n]*<code>/g, "<code-snippet>")
.replace(/<\/code>[ \r\n]*<\/pre>/g, "</code-snippet>");
}, 0)
}
// childrenAvailableCallback() {
// let converted = marked.parse(this.innerHTML);
// this.innerHTML = converted
// .replace(/<(\/?)ul>/g, "<$1bx-unordered-list>")
// .replace(/<(\/?)li>/g, "<$1bx-list-item>")
// .replace(/<a href/g, "<a target='_blank' rel='noopener noreferrer' href")
// .replace(/<pre>[ \r\n]*<code>/g, "<code-snippet>")
// .replace(/<\/code>[ \r\n]*<\/pre>/g, "</code-snippet>");
// }
}
);

customElements.define(
"code-snippet",
class extends HTMLBaseElement {
childrenAvailableCallback() {
let oldCode = this.innerHTML;
this.innerHTML = "";
// const shadowRoot = this.attachShadow({mode: 'open'});
const shadowRoot = this;
let snip = document.createElement("bx-code-snippet");
snip.setAttribute("type", "multi");
snip.setAttribute("color-scheme", "light");
snip.innerHTML = oldCode.replace(/</g, "&lt;")
shadowRoot.appendChild(snip);
}
}
);

const valueMap = {
"VIOLATION": {
"POTENTIAL": "Needs review",
"FAIL": "Violation",
"PASS": "Pass",
"MANUAL": "Needs review"
},
"RECOMMENDATION": {
"POTENTIAL": "Recommendation",
"FAIL": "Recommendation",
"PASS": "Pass",
"MANUAL": "Recommendation"
}
};

window.addEventListener("DOMContentLoaded", (evt) => {
let groupMsg = typeof RULE_MESSAGES !== "undefined" && (RULE_MESSAGES["en-US"].group || RULE_MESSAGES["en-US"][0]) || "";
groupMsg = groupMsg.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
document.querySelector("#groupLabel").innerHTML = groupMsg;
let ruleInfo;
if (window.location.search && window.location.search.length > 0) {
const searchParams = new URLSearchParams(window.location.search);
ruleInfo = JSON.parse(decodeURIComponent(searchParams.get("issue")));
} else if (window.location.hash && window.location.hash.length > 0) {
ruleInfo = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
}
if (ruleInfo) {
if (ruleInfo.message) {
let ruleMessage = ruleInfo.message.replace(/\{(\d+)\}/g, (matchedStr, matchedNum, matchedIndex) => msgArgs[matchedNum]);
document.querySelector("#ruleMessage").innerHTML = ruleMessage.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
}
setTimeout(() => {
if (ruleInfo.snippet) {
let snip = ruleInfo.snippet;
snip = snip.replace(/( [a-zA-Z-]+="[^"]*")/g, "\n $1");
let snipElem = document.createElement("code-snippet");
for (let line of snip.split("\n")) {
snipElem.appendChild(document.createTextNode(line+"\n"));
}
let locSnippet = document.querySelector("#locSnippet");
locSnippet.innerHTML = `<h3>Element location</h3>`;
locSnippet.appendChild(snipElem);
}
}, 0);
if (ruleInfo.value) {
let value = ruleInfo.value;
const val = valueMap[value[0]][value[1]];
let icon = "";
if (val === "Violation") icon = `<img src="../assets/Violation16.svg" alt="" />`;
if (val === "Needs review") icon = `<img src="../assets/NeedsReview16.svg" alt="" />`;
if (val === "Recommendation") icon = `<img src="../assets/Recommendation16.svg" alt="" />`;
document.querySelector("#locLevel").innerHTML = `<div class="issueLevel">${icon}&nbsp;${val}</div>`;
}
if (RULE_ID) {
document.querySelector("#ruleInfo").innerHTML = `<p>Rule ID: ${RULE_ID}${ruleInfo.reasonId ? `<br />Reason ID: ${ruleInfo.reasonId}</p>` : ""}`;
}
}
})

Loading

0 comments on commit 184f732

Please sign in to comment.