diff --git a/.eslintrc.json b/.eslintrc.json index 31c5902..b189d6e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -14,6 +14,7 @@ ], "rules": { "max-len": ["error", { "code": 120, "tabWidth": 2 }], + "complexity": ["off"], "no-magic-numbers": ["error", { "ignore": [0, 1] }], "indent": ["error", 2, { "ignoredNodes": ["TemplateLiteral", "SwitchCase"] diff --git a/github.js b/github.js index 24435db..7e4f5cf 100644 --- a/github.js +++ b/github.js @@ -243,22 +243,28 @@ const renderCloneButtons = (tools, githubMetadata) => { } else { // new UI as of 24.06.20 getRepoController = document.querySelector('get-repo'); + if (getRepoController) { + // https://github.com/orgs/community/discussions/61982 + const isNewRepositoryOverview = getRepoController. + parentElement?.parentElement?.classList?.contains('pagehead-actions') ?? false; + const summary = getRepoController.querySelector('summary'); // the Code tab contains the green Code button (primary), // the Pull requests tab contains the ordinary Code button (outlined) const isOnCodeTab = summary && summary.classList.contains('Button--primary'); - const toolboxCloneButtonGroup = document.createElement('div'); + const toolboxCloneButtonGroup = document.createElement(isNewRepositoryOverview ? 'li' : 'div'); + const classes = isOnCodeTab + ? (!isNewRepositoryOverview && 'd-block ml-2') + : 'flex-md-order-2'; toolboxCloneButtonGroup.setAttribute( 'class', - `BtnGroup ${isOnCodeTab - ? 'd-block ml-2' - : 'flex-md-order-2'} ${CLONE_BUTTON_GROUP_JS_CSS_CLASS}` + `BtnGroup ${classes} ${CLONE_BUTTON_GROUP_JS_CSS_CLASS}` ); tools.forEach(tool => { - const btn = createCloneButton(tool, githubMetadata, !isOnCodeTab); + const btn = createCloneButton(tool, githubMetadata, !isOnCodeTab || isNewRepositoryOverview); toolboxCloneButtonGroup.appendChild(btn); });