Skip to content

Commit 509e231

Browse files
authored
Merge pull request #14 from baikho/develop
chore(release): v1.3.2 release
2 parents 8939714 + c3459fc commit 509e231

File tree

5 files changed

+187
-183
lines changed

5 files changed

+187
-183
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Drupal Tooler
22

33
[![Chrome Extension](https://img.shields.io/badge/Chrome-Extension-brightgreen?logo=googlechrome&logoColor=white)](https://chromewebstore.google.com/detail/drupal-tooler/lmkfjgfjbplgkgkgfmkiepadaajpenkn)
4-
[![Drupal.org](https://img.shields.io/badge/Drupal.org-Enhanced-blue?logo=drupal)](https://www.drupal.org)
4+
[![Drupal.org](https://img.shields.io/badge/Drupal.org-Enhanced-blue?logo=drupal)](https://www.drupal.org/project/tooler)
55
[![License: MIT](https://img.shields.io/github/license/baikho/drupal-tooler)](LICENSE)
66
[![Last Commit](https://img.shields.io/github/last-commit/baikho/drupal-tooler)](https://github.com/baikho/drupal-tooler/commits/1.x)
77
[![Stars](https://img.shields.io/github/stars/baikho/drupal-tooler?style=social)](https://github.com/baikho/drupal-tooler/stargazers)

modules/gitlabPatchFetcher.js

Lines changed: 89 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,105 @@
1-
21
export function addGitLabMRPatchComposer() {
3-
const forkContainer = document.querySelector('#drupalorg-issue-forks');
4-
if (!forkContainer) return;
2+
const forkContainer = document.querySelector('#drupalorg-issue-forks');
3+
if (!forkContainer) return;
54

6-
const projectMatch = location.pathname.match(/\/project\/([^/]+)\/issues\//);
7-
if (!projectMatch) return;
5+
const projectMatch = location.pathname.match(/\/project\/([^/]+)\/issues\//);
6+
if (!projectMatch) return;
87

9-
const project = projectMatch[1];
10-
const issueIdMatch = location.pathname.match(/\/issues\/(\d+)/);
11-
const issueId = issueIdMatch ? issueIdMatch[1] : 'Patch';
8+
const project = projectMatch[1];
9+
const issueIdMatch = location.pathname.match(/\/issues\/(\d+)/);
10+
const issueId = issueIdMatch ? issueIdMatch[1] : 'Patch';
1211

13-
const issueTitleEl = document.querySelector('.node__title, h1#page-title');
14-
const issueTitle = issueTitleEl ? issueTitleEl.textContent.trim() : 'Patch';
15-
const safeTitle = JSON.stringify(`#${issueId}: ${issueTitle}`).slice(1, -1);
12+
const issueTitleEl = document.querySelector('.node__title, h1#page-title');
13+
const issueTitle = issueTitleEl ? issueTitleEl.textContent.trim() : 'Patch';
14+
const safeTitle = JSON.stringify(`#${issueId}: ${issueTitle}`).slice(1, -1);
1615

17-
const mrLinks = forkContainer.querySelectorAll('a.merge-request');
18-
if (!mrLinks.length) return;
16+
const mrLinks = forkContainer.querySelectorAll('a.merge-request');
17+
if (!mrLinks.length) return;
1918

20-
const table = document.createElement('table');
21-
table.className = 'gitlab-mr-patches';
22-
table.style.marginTop = '1em';
23-
table.style.width = '100%';
24-
table.style.borderCollapse = 'collapse';
19+
const table = document.createElement('table');
20+
table.className = 'gitlab-mr-patches';
21+
table.style.marginTop = '1em';
22+
table.style.width = '100%';
23+
table.style.borderCollapse = 'collapse';
2524

26-
const thead = document.createElement('thead');
27-
thead.innerHTML = `
25+
const thead = document.createElement('thead');
26+
thead.innerHTML = `
2827
<tr>
2928
<th style="text-align: left; border: 1px solid #ccc; border-right: 0; padding: 4px;">Merge Request</th>
3029
<th style="text-align: left; border: 1px solid #ccc; border-left: 0; border-right: 0; padding: 4px;">Patch URL</th>
3130
<th style="text-align: left; border: 1px solid #ccc; border-left: 0; padding: 4px;">Composer</th>
3231
</tr>
3332
`;
34-
table.appendChild(thead);
35-
36-
const tbody = document.createElement('tbody');
37-
38-
mrLinks.forEach(link => {
39-
const mrIdMatch = link.href.match(/\/merge_requests\/(\d+)/);
40-
if (!mrIdMatch) return;
41-
42-
const mrId = mrIdMatch[1];
43-
const patchUrl = `https://git.drupalcode.org/project/${project}/-/merge_requests/${mrId}.patch`;
44-
45-
const row = document.createElement('tr');
46-
47-
const mrCell = document.createElement('td');
48-
mrCell.textContent = `!${mrId}`;
49-
mrCell.style.padding = '4px';
50-
mrCell.style.borderRight = '0';
51-
52-
const urlCell = document.createElement('td');
53-
const urlLink = document.createElement('a');
54-
urlLink.href = patchUrl;
55-
urlLink.textContent = `${mrId}.patch`;
56-
urlCell.appendChild(urlLink);
57-
urlCell.style.padding = '4px';
58-
urlCell.style.borderLeft = '0';
59-
urlCell.style.borderRight = '0';
60-
61-
const composerCell = document.createElement('td');
62-
const copyButton = document.createElement('button');
63-
copyButton.textContent = 'Copy';
64-
copyButton.style.padding = '4px 8px';
65-
copyButton.style.backgroundColor = '#7cbc48';
66-
copyButton.style.color = '#fff';
67-
copyButton.style.border = 'none';
68-
copyButton.style.cursor = 'pointer';
69-
70-
copyButton.addEventListener('click', () => {
71-
const composerJson = `"drupal/${project}": {
33+
table.appendChild(thead);
34+
35+
const tbody = document.createElement('tbody');
36+
37+
mrLinks.forEach(link => {
38+
const mrIdMatch = link.href.match(/\/merge_requests\/(\d+)/);
39+
if (!mrIdMatch) return;
40+
41+
const mrId = mrIdMatch[1];
42+
const patchUrl = `https://git.drupalcode.org/project/${project}/-/merge_requests/${mrId}.patch`;
43+
44+
const row = document.createElement('tr');
45+
46+
const mrCell = document.createElement('td');
47+
mrCell.textContent = `!${mrId}`;
48+
mrCell.style.padding = '4px';
49+
mrCell.style.borderRight = '0';
50+
51+
const urlCell = document.createElement('td');
52+
const urlLink = document.createElement('a');
53+
urlLink.href = patchUrl;
54+
urlLink.textContent = `${mrId}.patch`;
55+
urlCell.appendChild(urlLink);
56+
urlCell.style.padding = '4px';
57+
urlCell.style.borderLeft = '0';
58+
urlCell.style.borderRight = '0';
59+
60+
const composerCell = document.createElement('td');
61+
const copyButton = document.createElement('button');
62+
copyButton.textContent = 'Copy';
63+
copyButton.style.padding = '4px 8px';
64+
copyButton.style.backgroundColor = '#7cbc48';
65+
copyButton.style.color = '#fff';
66+
copyButton.style.border = 'none';
67+
copyButton.style.cursor = 'pointer';
68+
69+
copyButton.addEventListener('click', () => {
70+
const composerJson = `"drupal/${project}": {
7271
"${safeTitle}": "${patchUrl}"
7372
}`;
74-
navigator.clipboard.writeText(composerJson).then(() => {
75-
copyButton.textContent = '✔ Copied';
76-
setTimeout(() => {
77-
copyButton.textContent = 'Copy';
78-
}, 1500);
79-
});
80-
});
81-
82-
composerCell.appendChild(copyButton);
83-
composerCell.style.padding = '4px';
84-
composerCell.style.borderLeft = '0';
85-
86-
row.appendChild(mrCell);
87-
row.appendChild(urlCell);
88-
row.appendChild(composerCell);
89-
tbody.appendChild(row);
90-
});
91-
92-
table.appendChild(tbody);
93-
forkContainer.appendChild(table);
94-
95-
const warning = document.createElement('div');
96-
warning.style.marginTop = '0.5em';
97-
warning.style.padding = '0.5em';
98-
warning.style.backgroundColor = '#fff8e1';
99-
warning.style.border = '1px solid #ffcc80';
100-
warning.style.color = '#8a6d3b';
101-
warning.style.fontSize = '14px';
102-
warning.style.lineHeight = '1.4';
103-
warning.innerHTML = '⚠️ GitLab MR patch URLs may change when the branch is updated. For stability, download the patch and store it locally.';
104-
105-
forkContainer.appendChild(warning);
73+
navigator.clipboard.writeText(composerJson).then(() => {
74+
copyButton.textContent = '✔ Copied';
75+
setTimeout(() => {
76+
copyButton.textContent = 'Copy';
77+
}, 1500);
78+
});
79+
});
80+
81+
composerCell.appendChild(copyButton);
82+
composerCell.style.padding = '4px';
83+
composerCell.style.borderLeft = '0';
84+
85+
row.appendChild(mrCell);
86+
row.appendChild(urlCell);
87+
row.appendChild(composerCell);
88+
tbody.appendChild(row);
89+
});
90+
91+
table.appendChild(tbody);
92+
forkContainer.appendChild(table);
93+
94+
const warning = document.createElement('div');
95+
warning.style.marginTop = '0.5em';
96+
warning.style.padding = '0.5em';
97+
warning.style.backgroundColor = '#fff8e1';
98+
warning.style.border = '1px solid #ffcc80';
99+
warning.style.color = '#8a6d3b';
100+
warning.style.fontSize = '14px';
101+
warning.style.lineHeight = '1.4';
102+
warning.innerHTML = '⚠️ GitLab MR patch URLs may change when the branch is updated. For stability, download the patch and store it locally.';
103+
104+
forkContainer.appendChild(warning);
106105
}

modules/highlightOPComments.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
export function highlightOPComments() {
32
const commentBlocks = document.querySelectorAll('.comment, .indented, .comment-wrapper');
43

modules/patchPreview.js

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,83 @@
1-
21
export function addInlinePatchPreviews() {
3-
const patchLinks = document.querySelectorAll('td.nodechanges-file-link a[href$=".patch"]');
2+
const patchLinks = document.querySelectorAll(
3+
'td.nodechanges-file-link a[href$=".patch"], td[name^="extended-file-field-table-filename"] a[href$=".patch"]'
4+
);
45

5-
patchLinks.forEach(link => {
6-
if (link.closest('td').querySelector('.drupal-tooler-preview-btn')) return;
6+
patchLinks.forEach(link => {
7+
if (link.closest('td').querySelector('.drupal-tooler-preview-btn')) return;
78

8-
const previewBtn = document.createElement('button');
9-
previewBtn.textContent = 'Preview';
10-
previewBtn.className = 'drupal-tooler-preview-btn';
11-
previewBtn.style.marginLeft = '8px';
12-
previewBtn.style.padding = '2px 6px';
13-
previewBtn.style.fontSize = '12px';
14-
previewBtn.style.cursor = 'pointer';
15-
previewBtn.style.backgroundColor = '#0074bd';
16-
previewBtn.style.color = '#fff';
17-
previewBtn.style.border = 'none';
9+
const previewBtn = document.createElement('button');
10+
previewBtn.textContent = 'Preview';
11+
previewBtn.className = 'drupal-tooler-preview-btn';
12+
previewBtn.style.marginLeft = '8px';
13+
previewBtn.style.padding = '2px 6px';
14+
previewBtn.style.fontSize = '12px';
15+
previewBtn.style.cursor = 'pointer';
16+
previewBtn.style.backgroundColor = '#0074bd';
17+
previewBtn.style.color = '#fff';
18+
previewBtn.style.border = 'none';
1819

19-
let previewRow = null;
20+
let previewRow = null;
2021

21-
previewBtn.addEventListener('click', () => {
22-
if (previewRow) {
23-
previewRow.style.display = previewRow.style.display === 'none' ? 'table-row' : 'none';
24-
return;
25-
}
22+
previewBtn.addEventListener('click', () => {
23+
if (previewRow) {
24+
previewRow.style.display = previewRow.style.display === 'none' ? 'table-row' : 'none';
25+
return;
26+
}
2627

27-
const patchRow = link.closest('tr');
28-
previewRow = document.createElement('tr');
28+
const patchRow = link.closest('tr');
29+
previewRow = document.createElement('tr');
2930

30-
const previewCell = document.createElement('td');
31-
previewCell.colSpan = patchRow.children.length;
32-
previewCell.style.padding = '8px';
33-
previewCell.style.backgroundColor = '#f9f9f9';
34-
previewCell.style.borderTop = '1px solid #ccc';
31+
const previewCell = document.createElement('td');
32+
previewCell.colSpan = patchRow.children.length;
33+
previewCell.style.padding = '8px';
34+
previewCell.style.backgroundColor = '#f9f9f9';
35+
previewCell.style.borderTop = '1px solid #ccc';
3536

36-
const previewContainer = document.createElement('div');
37-
previewContainer.style.fontFamily = 'monospace';
38-
previewContainer.style.fontSize = '12px';
39-
previewContainer.style.whiteSpace = 'pre-wrap';
40-
previewContainer.style.wordBreak = 'break-word';
41-
previewContainer.style.overflowX = 'auto';
42-
previewContainer.style.width = '100%';
43-
previewContainer.style.maxWidth = '100vw';
44-
previewContainer.style.lineHeight = '1.4';
37+
const previewContainer = document.createElement('div');
38+
previewContainer.style.fontFamily = 'monospace';
39+
previewContainer.style.fontSize = '12px';
40+
previewContainer.style.whiteSpace = 'pre-wrap';
41+
previewContainer.style.wordBreak = 'break-word';
42+
previewContainer.style.overflowX = 'auto';
43+
previewContainer.style.width = '100%';
44+
previewContainer.style.maxWidth = '100vw';
45+
previewContainer.style.lineHeight = '1.4';
4546

46-
previewContainer.textContent = 'Loading patch...';
47+
previewContainer.textContent = 'Loading patch...';
4748

48-
fetch(link.href)
49-
.then(res => res.text())
50-
.then(text => {
51-
previewContainer.textContent = '';
52-
const lines = text.split('\n');
53-
lines.forEach(line => {
54-
const span = document.createElement('span');
55-
span.textContent = line;
56-
span.style.display = 'block';
57-
span.style.width = '100%';
58-
span.style.boxSizing = 'border-box';
59-
if (line.startsWith('+') && !line.startsWith('+++')) {
60-
span.style.backgroundColor = '#e6ffed';
61-
span.style.color = '#22863a';
62-
} else if (line.startsWith('-') && !line.startsWith('---')) {
63-
span.style.backgroundColor = '#ffeef0';
64-
span.style.color = '#cb2431';
65-
} else {
66-
span.style.color = '#333';
67-
}
68-
previewContainer.appendChild(span);
69-
});
70-
})
71-
.catch(() => {
72-
previewContainer.textContent = 'Failed to load patch.';
49+
fetch(link.href)
50+
.then(res => res.text())
51+
.then(text => {
52+
previewContainer.textContent = '';
53+
const lines = text.split('\n');
54+
lines.forEach(line => {
55+
const span = document.createElement('span');
56+
span.textContent = line;
57+
span.style.display = 'block';
58+
span.style.width = '100%';
59+
span.style.boxSizing = 'border-box';
60+
if (line.startsWith('+') && !line.startsWith('+++')) {
61+
span.style.backgroundColor = '#e6ffed';
62+
span.style.color = '#22863a';
63+
} else if (line.startsWith('-') && !line.startsWith('---')) {
64+
span.style.backgroundColor = '#ffeef0';
65+
span.style.color = '#cb2431';
66+
} else {
67+
span.style.color = '#333';
68+
}
69+
previewContainer.appendChild(span);
70+
});
71+
})
72+
.catch(() => {
73+
previewContainer.textContent = 'Failed to load patch.';
74+
});
75+
76+
previewCell.appendChild(previewContainer);
77+
previewRow.appendChild(previewCell);
78+
patchRow.parentNode.insertBefore(previewRow, patchRow.nextSibling);
7379
});
7480

75-
previewCell.appendChild(previewContainer);
76-
previewRow.appendChild(previewCell);
77-
patchRow.parentNode.insertBefore(previewRow, patchRow.nextSibling);
81+
link.parentElement.appendChild(previewBtn);
7882
});
79-
80-
link.parentElement.appendChild(previewBtn);
81-
});
8283
}

0 commit comments

Comments
 (0)