Skip to content

Commit

Permalink
Added selector comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mjasikowski committed Jan 17, 2025
1 parent 90f1e3c commit dbf1cbb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
6 changes: 4 additions & 2 deletions src/js/lib/pages/github/_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ export default function () {
Page.setup = function () {};

Page.getRepoOwner = function () {
return document.querySelectorAll('.AppHeader-context-item-label.Truncate-text')[0].textContent.trim();
return document.querySelectorAll('.AppHeader-context-item-label.Truncate-text')[0] // Org name next to GitHub logo
.textContent.trim();
};

Page.getRepo = function () {
return document.querySelectorAll('.AppHeader-context-item-label.Truncate-text')[1].textContent.trim();
return document.querySelectorAll('.AppHeader-context-item-label.Truncate-text')[1] // Repo name next to GitHub logo
.textContent.trim();
};

/**
Expand Down
12 changes: 8 additions & 4 deletions src/js/lib/pages/github/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import * as API from '../../api';

let clearErrorTimeoutID;
function catchError(e) {
$('div[data-component="PH_Actions"] .k2-element').remove();
$('div[data-component="PH_Actions"]').append('<span class="alert k2-element">OOPS!</span>');
$('div[data-component="PH_Actions"] .k2-element').remove(); // K2 elements in action buttons
$('div[data-component="PH_Actions"]') // Action buttons next to issue title
.append('<span class="alert k2-element">OOPS!</span>');
console.error(e);
clearTimeout(clearErrorTimeoutID);
clearErrorTimeoutID = setTimeout(() => {
Expand Down Expand Up @@ -126,7 +127,8 @@ const renderAssignees = (issueOwner) => {
const refreshPicker = function () {
// Add our wrappers to the DOM which all the React components will be rendered into
if (!$('.k2picker-wrapper').length) {
$('div[data-testid="issue-viewer-metadata-pane"] > :nth-child(3)').after(sidebarWrapperHTML);
$('div[data-testid="issue-viewer-metadata-pane"] > :nth-child(3)') // Labels section in right side panel
.after(sidebarWrapperHTML);
}

new K2picker().draw();
Expand Down Expand Up @@ -167,7 +169,9 @@ export default function () {
if (!$('.k2picker-wrapper').length) {
refreshPicker();
}
if (!$('div[data-testid="issue-viewer-metadata-pane"] > :nth-child(2) .k2-element').length) {

if (!$('div[data-testid="issue-viewer-metadata-pane"] > :nth-child(2) .k2-element') // Assignee section in right side panel
.length) {
renderAssignees();
}
}, 1000);
Expand Down
27 changes: 13 additions & 14 deletions src/js/lib/pages/github/pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ const refreshHold = function () {
// Classic merge experience
if (!isNewMergeUI) {
if (prTitle.toLowerCase().indexOf('[hold') > -1 || prTitle.toLowerCase().indexOf('[wip') > -1) {
$('.branch-action') // entire section
$('.branch-action') // Entire PR merge section
.removeClass('branch-action-state-clean')
.addClass('branch-action-state-dirty');
$('.merge-message button') // merge pull request button
$('.merge-message button') // Merge pull request button
.removeClass('btn-primary')
.attr('disabled', 'disabled');
// eslint-disable-next-line rulesdir/prefer-underscore-method
$('.branch-action-item').last().find('.completeness-indicator') // Last section
$('.branch-action-item').last().find('.completeness-indicator') // "Merging status" section above the merge button
.removeClass('completeness-indicator-success')
.addClass('completeness-indicator-problem')
.end()
.find('.status-heading')
.find('.status-heading') // Header for the "merging status" section
.text('This pull request has a hold on it and cannot be merged')
.end()
.find('.status-meta')
.find('.status-meta') // Body text for the "merging status" section
.html('Remove the HOLD or WIP label from the title of the PR to make it mergeable')
.end()
.find('.octicon')
Expand All @@ -34,25 +34,24 @@ const refreshHold = function () {
}

if (prTitle.toLowerCase().indexOf('[hold') > -1 || prTitle.toLowerCase().indexOf('[wip') > -1) {
$('div[data-testid="mergebox-partial"] > div > div:last-of-type')
$('div[data-testid="mergebox-partial"] > div > div:last-of-type') // Entire PR merge section
.removeClass('borderColor-success-emphasis');
$('div[data-testid="mergebox-partial"] > div > div > div button').first() // merge pull request button
$('div[data-testid="mergebox-partial"] > div > div > div button').first() // Merge pull request button
.css({backgroundColor: 'var(--bgColor-neutral-muted)', borderColor: 'var(--bgColor-neutral-muted)'})
.attr('disabled', 'disabled');
$('div[data-testid="mergebox-partial"] > div > div button[data-component="IconButton"]').first()
$('div[data-testid="mergebox-partial"] > div > div button[data-component="IconButton"]').first() // Dropdown button next to merge button
.css({backgroundColor: 'var(--bgColor-neutral-muted)', borderColor: 'var(--bgColor-neutral-muted)'})
.attr('disabled', 'disabled');
$('div[data-testid="mergebox-partial"] > div > div > div > div > div')
$('div[data-testid="mergebox-partial"] > div > div > div > div > div') // Container for merge pull request button
.css({borderColor: 'var(--bgColor-neutral-muted)'});
$('div[data-testid="mergeability-icon-wrapper"] div').css({backgroundColor: 'var(--bgColor-neutral-emphasis)'});
// eslint-disable-next-line rulesdir/prefer-underscore-method
$('div[data-testid="mergebox-partial"] > div > div > section:last-of-type svg') // Last section
$('div[data-testid="mergeability-icon-wrapper"] div').css({backgroundColor: 'var(--bgColor-neutral-emphasis)'}); // Icon on the left side of the merge panel
$('div[data-testid="mergebox-partial"] > div > div > section:last-of-type svg') // "Merging status" section above the merge button
.parent()
.removeClass('bgColor-success-emphasis')
.css({backgroundColor: 'var(--bgColor-neutral-emphasis)'});
$('div[data-testid="mergebox-partial"] > div > div > section:last-of-type h3')
$('div[data-testid="mergebox-partial"] > div > div > section:last-of-type h3') // Header for the "merging status" section
.text('This pull request has a hold on it and cannot be merged');
$('div[data-testid="mergebox-partial"] > div > div > section:last-of-type p')
$('div[data-testid="mergebox-partial"] > div > div > section:last-of-type p') // Body text for the "merging status" section
.html('Remove the HOLD or WIP label from the title of the PR to make it mergeable');
}
};
Expand Down

0 comments on commit dbf1cbb

Please sign in to comment.