summaryrefslogtreecommitdiff
path: root/source/features/clean-repo-filelist-actions.tsx
diff options
context:
space:
mode:
authorGravatar Florent <cheap.glitch@gmail.com> 2021-12-14 11:30:21 +0100
committerGravatar GitHub <noreply@github.com> 2021-12-14 11:30:21 +0100
commit1c6fed4956257e21fb9d587d439142dad9c317cf (patch)
tree4f1a4cf8813ff245cecb44c863d04fd44e4898a2 /source/features/clean-repo-filelist-actions.tsx
parent7551cccbd72ba5fdca3a4a5635c31df488b451ad (diff)
downloadrefined-github-1c6fed4956257e21fb9d587d439142dad9c317cf.tar.gz
refined-github-1c6fed4956257e21fb9d587d439142dad9c317cf.tar.zst
refined-github-1c6fed4956257e21fb9d587d439142dad9c317cf.zip
Fix handling of "Code" button in `clean-repo-filelist-actions` (#5074)
Diffstat (limited to 'source/features/clean-repo-filelist-actions.tsx')
-rw-r--r--source/features/clean-repo-filelist-actions.tsx21
1 files changed, 13 insertions, 8 deletions
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(<CodeIcon/>);
+ }
}
},
});