Repository navigation
Add action-used-by-link feature - #3033
Conversation
|
I wonder whether this feature should do a bit more by extracting the number of results for the search? Is that good practice? |
|
Also, if it were good practice, I'd have no idea where to start: I looked at the feature that adds real names to usernames, and didn't understand the way the queries were made, so I'd need more pointers. |
Co-Authored-By: Federico Brigante <[email protected]>
Co-Authored-By: Federico Brigante <[email protected]>
Co-Authored-By: yakov116 <[email protected]>
| import searchIcon from 'octicon/search.svg'; | ||
|
|
||
| function init(): void { | ||
| const actionRepo = (select('.py-3.border-bottom.border-gray-light .octicon.octicon-issue-opened.text-gray-dark.mr-2')!.parentElement as HTMLAnchorElement) |
There was a problem hiding this comment.
JMHO
| const actionRepo = (select('.py-3.border-bottom.border-gray-light .octicon.octicon-issue-opened.text-gray-dark.mr-2')!.parentElement as HTMLAnchorElement) | |
| const actionRepo = (select('.octicon-issue-opened.text-gray-dark')!.parentElement as HTMLAnchorElement) | |
| .pathname.slice(1) | |
| .replace('/issues', ''); |
Its rare that github styles their own icons (from my experience)
There was a problem hiding this comment.
.slice(1) drops the initial slash so /issues will never match. You only need one of them anyway, either slice or replace, they do the same thing.
But really, why use the issue-opened icon and then removing /issues? There's already a plain link, you used it before.
Also try avoiding to use utility classes (.mt-1, .text-gray-dark) when selecting items; they are more prone to change or likely to appear in new places.
I found a better way that avoids having to use the awkward as HTMLAnchorElement that I suggested earlier. This should work:
| const actionRepo = (select('.py-3.border-bottom.border-gray-light .octicon.octicon-issue-opened.text-gray-dark.mr-2')!.parentElement as HTMLAnchorElement) | |
| const actionRepo = select('aside .octicon-repo')! | |
| .closest('a')! | |
| .pathname | |
| .slice(1); |
Co-Authored-By: yakov116 <[email protected]>
|
I made the requested changes, thanks a ton to both of you! I added a line for the README in a new section which I'm not sure makes sense, but at least now the line exists and can be moved around before merging. I myself still have one question: should this feature extract the number of results for the search and if so how? |
| import searchIcon from 'octicon/search.svg'; | ||
|
|
||
| function init(): void { | ||
| const actionRepo = (select('.py-3.border-bottom.border-gray-light .octicon.octicon-issue-opened.text-gray-dark.mr-2')!.parentElement as HTMLAnchorElement) |
There was a problem hiding this comment.
.slice(1) drops the initial slash so /issues will never match. You only need one of them anyway, either slice or replace, they do the same thing.
But really, why use the issue-opened icon and then removing /issues? There's already a plain link, you used it before.
Also try avoiding to use utility classes (.mt-1, .text-gray-dark) when selecting items; they are more prone to change or likely to appear in new places.
I found a better way that avoids having to use the awkward as HTMLAnchorElement that I suggested earlier. This should work:
| const actionRepo = (select('.py-3.border-bottom.border-gray-light .octicon.octicon-issue-opened.text-gray-dark.mr-2')!.parentElement as HTMLAnchorElement) | |
| const actionRepo = select('aside .octicon-repo')! | |
| .closest('a')! | |
| .pathname | |
| .slice(1); |
|
I made the changes, thanks a lot, and yes it still works. 😸 |
action-used-by-link feature
|
Looks and works well, thank you Maëlle! 🐡 |
Fix #3009
URLs to check it from