From 1c6fed4956257e21fb9d587d439142dad9c317cf Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 14 Dec 2021 11:30:21 +0100 Subject: Fix handling of "Code" button in `clean-repo-filelist-actions` (#5074) --- source/features/clean-repo-filelist-actions.tsx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'source/features/clean-repo-filelist-actions.tsx') diff --git a/source/features/clean-repo-filelist-actions.tsx b/source/features/clean-repo-filelist-actions.tsx index 9a55f7cc..c8a3881c 100644 --- a/source/features/clean-repo-filelist-actions.tsx +++ b/source/features/clean-repo-filelist-actions.tsx @@ -3,7 +3,7 @@ import select from 'select-dom'; import onetime from 'onetime'; import {observe} from 'selector-observer'; import * as pageDetect from 'github-url-detection'; -import {PlusIcon, SearchIcon} from '@primer/octicons-react'; +import {PlusIcon, SearchIcon, CodeIcon} from '@primer/octicons-react'; import {wrap} from '../helpers/dom-utils'; import features from '.'; @@ -37,14 +37,19 @@ function init(): void { addTooltipToSummary(addFileDropdown, 'Add file'); } - // This dropdown doesn't appear on `isSingleFile` - // Remove `.octicon-download` in November - const codeIcon = select('get-repo :is(.octicon-code, .octicon-download)'); - if (codeIcon) { - // Remove "Code" text next to it - codeIcon.nextSibling!.remove(); + const codeDropdownButton = select('get-repo summary'); + if (codeDropdownButton) { // This dropdown doesn't appear on `isSingleFile` + addTooltipToSummary(codeDropdownButton, 'Clone, open or download'); - addTooltipToSummary(codeIcon, 'Clone, open or download'); + // Users with Codespaces enabled already have an icon in the button https://github.com/refined-github/refined-github/pull/5074#issuecomment-983251719 + const codeIcon = select('.octicon-code', codeDropdownButton); + if (codeIcon) { + // Remove "Code" text + codeIcon.nextSibling!.remove(); + } else { + // Replace "Code" text with icon + codeDropdownButton.firstChild!.replaceWith(); + } } }, }); -- cgit v1.2.3