Skip to content

Commit

Permalink
fix: Make OctoLinker work with the new code experience (#1694)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbuck committed Nov 13, 2022
1 parent b4d2e61 commit 4db4ec9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/blob-reader/helper.js
Expand Up @@ -7,12 +7,17 @@ function $$(selector, rootElement = document) {
}

function getBlobCodeInner(el) {
if ($$('.react-blob-row').length) {
return $$('.react-blob-row', el);
}

return $$('.blob-code-inner', el);
}

function getBlobWrapper(rootElement) {
return $$(
`
[data-selector="repos-split-pane-content"] table,
.blob-wrapper,
.js-blob-wrapper,
[class*="highlight-source-"]
Expand Down Expand Up @@ -56,6 +61,11 @@ function getParentSha() {
}

function getPath(el) {
// New code view experience
if ($('react-app')?.attributes['initial-path']?.value) {
return $('react-app').attributes['initial-path'].value;
}

// When current page is a diff view get path from "View" button
let rootSelector =
el.parentElement.parentElement.querySelectorAll('.file-actions a');
Expand Down Expand Up @@ -122,6 +132,11 @@ function getLineNumber(el) {
}

function diffMetaInformation(el) {
// New code view experience
if (el.classList.contains('react-blob-row')) {
return {};
}

const td = el.closest('td');

// Blob view
Expand Down

0 comments on commit 4db4ec9

Please sign in to comment.