Skip to content

Commit

Permalink
Add button to copy the MD link for merged PR (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime-rainville authored Dec 3, 2023
1 parent 34f2b58 commit ffd3af6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 105 deletions.
27 changes: 27 additions & 0 deletions app/src/Processors/RecentMergedPrsProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,30 @@ public function getHtmlTableScript(): string
}
}
}, 250);
// Find the column index of the "action" column
let actionColIndex = 0;
const tableHeaders = document.querySelectorAll('thead th');
for (let i = 0; i < tableHeaders.length; i++) {
if (tableHeaders[i].innerText === 'action') {
actionColIndex = i + 1;
break;
}
}
// Loop through all the rows and convert the action cell to a "Copy MD" button
var tds = document.querySelectorAll(`tbody td:nth-child(\${actionColIndex})`);
for (let i = 0; i < tds.length; i++) {
const td = tds[i];
const md = td.innerHTML;
td.innerHTML = '';
const btn = document.createElement('button');
btn.addEventListener('click', function() {
navigator.clipboard.writeText(md);
btn.innerHTML = 'Copied';
});
btn.innerHTML = 'Copy';
td.appendChild(btn);
}
})();
EOT;
}
Expand Down Expand Up @@ -153,6 +177,8 @@ private function deriveMergedPrDataRow(stdClass $pr, string $account, string $re

$prStats = $this->prStats($pr->files->nodes);

$markdownLink = "[{$pr->title}]({$pr->url}) by [{$authorName}](https://github.com/$author)";

$row = [
'account' => $account,
'repo' => $repo,
Expand All @@ -175,6 +201,7 @@ private function deriveMergedPrDataRow(stdClass $pr, string $account, string $re
'unit' => $prStats['unit'],
'behat' => $prStats['behat'],
'jest' => $prStats['jest'],
'action' => $markdownLink,
];
return $row;
}
Expand Down
101 changes: 0 additions & 101 deletions public/assets/web.config

This file was deleted.

8 changes: 4 additions & 4 deletions themes/rhino/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ td, th {
padding: 3px;
}

.odd {
background-color: #fcf6ef !important;
#mytable .odd {
background-color: #fcf6ef;
}

.even {
background-color: #fffdfb !important;
#mytable .even {
background-color: #fffdfb;
}

thead tr:first-of-type {
Expand Down

0 comments on commit ffd3af6

Please sign in to comment.