Skip to content

Commit 2649668

Browse files
committed
chore: remove unused js functions
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent da59357 commit 2649668

5 files changed

Lines changed: 41 additions & 171 deletions

File tree

vulnerabilities/pipelines/v2_improvers/compute_advisory_todo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def get_disagreement_message(fixed_disagreement, affected_disagreement):
518518

519519
messages.append(f"Advisories do not agree whether {noun} {fixed} {verb} the fix.")
520520

521-
return " ".join(messages)
521+
return "\n".join(messages)
522522

523523

524524
def get_grouped_curation_advisories_for_dashboard_ui(purl, adv_map, conflict_detail, advisories):

vulnerabilities/templates/package_curation.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
<div class="container is-fluid">
1212
<div class="columns is-vcentered mb-5">
1313
<div class="column">
14-
<h1 class="title is-3">Curation Dashboard</h1>
14+
<h1 class="title is-3">Advisory Curation</h1>
1515
<h2 class="subtitle is-5 has-text-grey">{{ vulnerability_id }}</h2>
1616
</div>
1717

1818
<div class="column is-narrow">
1919
<div class="box p-4 has-background-white shadow-soft" style="min-width: 260px; border-radius: 5px;">
2020
<div class="is-flex is-justify-content-space-between is-align-items-center mb-2">
21-
<span class="is-size-7 has-text-grey-dark uppercase has-text-weight-bold mr-2 mt-1">
21+
<span class="is-size-6 has-text-grey-dark uppercase has-text-weight-bold mr-2">
2222
Progress
2323
</span>
2424
<span class="tag is-info is-light has-text-weight-bold" id="progress-text">0 / 0</span>
2525
</div>
26-
<progress class="progress is-info is-small mb-0" id="main-progress" value="0" max="100"></progress>
26+
<progress class="progress is-info is-small mb-0" id="progress" value="0" max="100"></progress>
2727
</div>
2828
</div>
2929

@@ -36,7 +36,7 @@ <h3 class="title is-5">Advisory Summaries</h3>
3636
{% for avid, text in advisory_summaries.items %}
3737
<div class="notification is-info is-light p-3 mb-3">
3838
<p><strong>{{ avid }}</strong></p>
39-
<div class="summary-text">{{ text|normalize_links|urlize }}</div>
39+
<div class="text summary-text is-2">{{ text|normalize_links|urlize }}</div>
4040
</div>
4141
{% empty %}
4242
<div class="notification is-light p-3 mb-3 has-text-grey">
@@ -50,7 +50,7 @@ <h3 class="title is-5">Advisory Summaries</h3>
5050
<div class="box">
5151
<div class="mb-4">
5252
<h4 class="title is-4 mb-1" id="current-purl"></h4>
53-
<p class="help" id="conflict-reason"></p>
53+
<p class="text is-5" id="conflict-reason"></p>
5454
</div>
5555

5656
<div class="table-container" style="max-height: 800px; overflow-y: auto; border: 1px solid #dbdbdb; border-radius: 6px;">
@@ -80,7 +80,7 @@ <h4 class="title is-4 mb-1" id="current-purl"></h4>
8080
</button>
8181
<button class="button is-info is-hidden" id="finish-btn" disabled>
8282
<span class="icon"><i class="fa fa-check"></i></span>
83-
<span>Validate</span>
83+
<span>Submit</span>
8484
</button>
8585
</div>
8686
</div>
@@ -98,4 +98,4 @@ <h4 class="title is-4 mb-1" id="current-purl"></h4>
9898
const curationItems = {{ curation_items|safe }};
9999
</script>
100100
<script src="{% static 'js/package_curation.min.js' %}"></script>
101-
{% endblock %}
101+
{% endblock %}

vulnerablecode/static/css/package_curation.css

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@
4545
width: 100px !important;
4646
}
4747

48-
49-
.curation-cell,
50-
.advisory-cell,
51-
#curation-body td,
52-
.folded-row-marker,
53-
.range-data-cell,
54-
.help-instructions {
55-
font-size: 0.8rem !important;
56-
}
57-
5848
.curation-cell {
5949
cursor: pointer;
6050
text-align: center !important;
@@ -74,12 +64,6 @@
7464
cursor: not-allowed;
7565
}
7666

77-
.advisory-cell {
78-
text-align: center !important;
79-
vertical-align: middle !important;
80-
border: 1px solid #dbdbdb !important;
81-
}
82-
8367
.folded-row-marker,
8468
.range-row-marker {
8569
cursor: pointer;
@@ -89,30 +73,10 @@
8973
background-color: #f5f5f5;
9074
}
9175

92-
.folded-row-marker {
93-
height: 30px;
94-
}
95-
96-
.folded-row-marker:hover,
97-
.range-row-marker:hover {
98-
background-color: #ededed;
99-
color: #0a0a0a;
100-
}
101-
102-
.folded-row-marker .icon {
103-
transition: transform 0.2s ease;
104-
}
105-
10676
.folded-row-marker.is-expanded .icon {
10777
transform: rotate(180deg);
10878
}
10979

110-
.range-row-marker {
111-
font-size: 0.8rem;
112-
padding: 6px 0;
113-
border: 1px solid #dbdbdb !important;
114-
}
115-
11680
.range-data-cell {
11781
background-color: #fafafa;
11882
padding: 6px !important;
@@ -133,7 +97,6 @@
13397
}
13498

13599
.summary-text {
136-
font-size: 0.85rem;
137100
line-height: 1.4;
138101
white-space: pre-wrap;
139102
word-break: break-word;
@@ -167,8 +130,3 @@
167130
white-space: normal;
168131
flex-wrap: wrap;
169132
}
170-
171-
.advisory-link .icon {
172-
font-size: 0.75rem;
173-
flex-shrink: 0;
174-
}

vulnerablecode/static/js/package_curation.js

Lines changed: 21 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const app = {
2020

2121
const total = curationItems.length;
2222
const progPercentage = ((this.currentIndex + 1) / total) * 100;
23-
document.getElementById('main-progress').value = progPercentage;
23+
document.getElementById('progress').value = progPercentage;
2424
document.getElementById('progress-text').innerText = `${this.currentIndex + 1} / ${total}`;
2525
document.getElementById('current-purl').innerText = item.purl;
2626
document.getElementById('conflict-reason').innerText = item.conflict_reason;
@@ -37,109 +37,6 @@ const app = {
3737
this.updateNavButtons();
3838
},
3939

40-
renderHeader(item) {
41-
const header = document.getElementById('table-header');
42-
header.innerHTML = `
43-
<th class="has-text-weight-bold pt-4">Version</th>
44-
<th style="width: 140px;" class="has-text-centered">
45-
<div>
46-
<div>
47-
<div class="has-text-weight-bold">Curation</div>
48-
</div>
49-
<button class="button is-small is-outlined is-info mt-auto" onclick="app.resetCurrentCuration()">Reset</button>
50-
</div>
51-
</th>`;
52-
item.advisories.forEach((adv, idx) => {
53-
const th = document.createElement('th');
54-
th.className = "has-text-centered";
55-
const targetUrl = baseAdvisoryUrl.replace('0', adv.advisory_uid);
56-
th.innerHTML = `
57-
<div>
58-
<div class="mb-3 advisory-wrapper">
59-
<a href="${targetUrl}" target="_blank" rel="noopener noreferrer" class="has-text-link has-text-weight-bold advisory-link">
60-
<span>${adv.advisory_uid}</span>
61-
<span class="icon is-small" style="font-size: 0.75rem;"><i class="fa fa-external-link"></i></span>
62-
</a>
63-
</div>
64-
<button class="button is-small is-info mt-auto" onclick="app.pickAdvisory(${idx})">Pick This</button>
65-
</div>
66-
`;
67-
header.appendChild(th);
68-
});
69-
},
70-
71-
renderBody(item, versions) {
72-
const body = document.getElementById('curation-body');
73-
body.innerHTML = '';
74-
const totalColumns = item.advisories.length + 2;
75-
const rangeToggleRow = document.createElement('tr');
76-
rangeToggleRow.innerHTML = `
77-
<td colspan="${totalColumns}" class="range-row-marker" onclick="app.toggleRanges()">
78-
<span class="icon is-small"><i class="fa ${this.showRanges ? 'fa-chevron-up' : 'fa-chevron-down'}"></i></span>
79-
${this.showRanges ? 'Hide' : 'Show'} Version Ranges
80-
</td>`;
81-
body.appendChild(rangeToggleRow);
82-
if (this.showRanges) {
83-
const rangeDataRow = document.createElement('tr');
84-
let rowHtml = `<td></td><td></td>`;
85-
item.advisories.forEach(adv => {
86-
const rangeHtml = adv.vers_ranges.map(r => {
87-
let htmlLines = [];
88-
if (r.affected_vers && r.affected_vers.trim() !== "") {
89-
htmlLines.push(`<div><span class="has-text-weight-semibold">Affected:</span> ${r.affected_vers}</div>`);
90-
}
91-
if (r.fixing_vers && r.fixing_vers.trim() !== "") {
92-
htmlLines.push(`<div><span class="has-text-weight-semibold">Fixing:</span> ${r.fixing_vers}</div>`);
93-
}
94-
return htmlLines.length > 0 ? htmlLines.join('') : '<div>No range specified</div>';
95-
}).join('<hr class="my-1" style="background-color: #dbdbdb; height: 1px;">');
96-
rowHtml += `<td class="range-data-cell">${rangeHtml}</td>`;
97-
});
98-
rangeDataRow.innerHTML = rowHtml;
99-
body.appendChild(rangeDataRow);
100-
}
101-
const foldable = this.getFoldableRanges(item, versions);
102-
for (let i = 0; i < versions.length; i++) {
103-
const range = foldable.find(r => i >= r.start && i <= r.end);
104-
if (range) {
105-
const foldKey = `${this.currentIndex}-${range.start}`;
106-
let isExpanded = this.expandedFolds.has(foldKey);
107-
if (!this.foldAgreementBlocks) {
108-
isExpanded = !this.expandedFolds.has(`${this.currentIndex}-${range.start}-collapsed`);
109-
}
110-
if (i === range.start) {
111-
const marker = document.createElement('tr');
112-
marker.innerHTML = `<td colspan="${item.advisories.length + 2}" class="folded-row-marker ${isExpanded ? 'is-expanded' : ''}" onclick="app.toggleFold(${range.start})">
113-
<span class="icon is-small"><i class="fa fa-chevron-down"></i></span>
114-
${isExpanded ? 'Hide' : 'Show'} Consensus Range (${range.end - range.start + 1} versions)
115-
</td>`;
116-
body.appendChild(marker);
117-
}
118-
if (!isExpanded) {
119-
if (i === range.end) continue;
120-
i = range.end;
121-
continue;
122-
}
123-
}
124-
body.appendChild(this.createRow(versions[i], item));
125-
}
126-
},
127-
128-
resetCurrentCuration() {
129-
const item = curationItems[this.currentIndex];
130-
const versions = item.all_versions || item.all_version;
131-
versions.forEach(v => {
132-
if (item.partial_curation.affected.includes(v)) {
133-
this.userStates[this.currentIndex][v] = 'affected';
134-
} else if (item.partial_curation.fixing.includes(v)) {
135-
this.userStates[this.currentIndex][v] = 'fixed';
136-
} else {
137-
this.userStates[this.currentIndex][v] = '?';
138-
}
139-
});
140-
this.renderBody(item, versions);
141-
},
142-
14340
renderHeader(item) {
14441
const header = document.getElementById('table-header');
14542
header.innerHTML = `
@@ -168,7 +65,7 @@ const app = {
16865
<div class="mb-3 advisory-wrapper">
16966
<a href="${primaryUrl}" target="_blank" rel="noopener noreferrer" class="has-text-link has-text-weight-bold advisory-link">
17067
<span>${advGroup.primary.advisory_uid}</span>
171-
<span class="icon is-small" style="font-size: 0.75rem;"><i class="fa fa-external-link"></i></span>
68+
<span class="icon is-small"><i class="fa fa-external-link"></i></span>
17269
</a>
17370
</div>
17471
`;
@@ -207,7 +104,7 @@ const app = {
207104
<span class="tag is-light is-size-7 mb-1">Similar</span>
208105
<a href="${secUrl}" target="_blank" rel="noopener noreferrer" class="has-text-grey-dark has-text-weight-bold advisory-link">
209106
<span>${sec.advisory_uid}</span>
210-
<span class="icon is-small" style="font-size: 0.75rem;"><i class="fa fa-external-link"></i></span>
107+
<span class="icon is-small" ><i class="fa fa-external-link"></i></span>
211108
</a>
212109
</div>
213110
<button class="button is-small is-info is-light mt-auto" onclick="app.pickAdvisory(${groupIdx}, 'secondary', ${secIdx})">Pick This</button>
@@ -299,10 +196,25 @@ const app = {
299196
}
300197
},
301198

199+
resetCurrentCuration() {
200+
const item = curationItems[this.currentIndex];
201+
const versions = item.all_versions || item.all_version;
202+
versions.forEach(v => {
203+
if (item.partial_curation.affected.includes(v)) {
204+
this.userStates[this.currentIndex][v] = 'affected';
205+
} else if (item.partial_curation.fixing.includes(v)) {
206+
this.userStates[this.currentIndex][v] = 'fixed';
207+
} else {
208+
this.userStates[this.currentIndex][v] = '?';
209+
}
210+
});
211+
this.renderBody(item, versions);
212+
},
213+
302214
createRow(v, item) {
303215
const tr = document.createElement('tr');
304216
const state = this.userStates[this.currentIndex][v];
305-
tr.innerHTML = `<td class="has-text-weight-bold ">${v}</td>`;
217+
tr.innerHTML = `<td class="has-text-weight-bold">${v}</td>`;
306218
const userTd = document.createElement('td');
307219
userTd.className = `curation-cell state-${state} `;
308220
userTd.innerText = state.toUpperCase();
@@ -315,7 +227,7 @@ const app = {
315227

316228
const primaryState = advGroup.affected.includes(v) ? 'affected' : (advGroup.fixing.includes(v) ? 'fixed' : 'unaffected');
317229
const td = document.createElement('td');
318-
td.className = `advisory-cell state-${primaryState}`;
230+
td.className = `state-${primaryState} has-text-centered`;
319231
td.innerText = primaryState.toUpperCase();
320232
tr.appendChild(td);
321233

@@ -326,7 +238,7 @@ const app = {
326238

327239
const secState = secAffected.includes(v) ? 'affected' : (secFixing.includes(v) ? 'fixed' : 'unaffected');
328240
const secTd = document.createElement('td');
329-
secTd.className = `advisory-cell state-${secState}`;
241+
secTd.className = `state-${secState} has-text-centered`;
330242
secTd.style.borderLeft = "1px dashed #dbdbdb";
331243
secTd.innerText = secState.toUpperCase();
332244
tr.appendChild(secTd);

0 commit comments

Comments
 (0)