Skip to content

Add action-used-by-link feature - #3033

Merged
fregante merged 24 commits into
refined-github:masterfrom
maelle:usedbygha
Apr 28, 2020
Merged

fregante merged 24 commits into
refined-github:masterfrom
maelle:usedbygha

Conversation

@maelle

@maelle maelle commented Apr 24, 2020 •

Copy link
Copy Markdown
Contributor

Comment thread source/features/action-used-by-link.tsx Resolved
@maelle

maelle commented Apr 24, 2020

Copy link
Copy Markdown
Contributor Author

I wonder whether this feature should do a bit more by extracting the number of results for the search? Is that good practice?

@maelle

maelle commented Apr 24, 2020

Copy link
Copy Markdown
Contributor Author

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.

Comment thread source/features/action-used-by-link.tsx Resolved
Comment thread source/features/action-used-by-link.tsx Resolved
Comment thread source/features/action-used-by-link.tsx Resolved
Comment thread source/features/action-used-by-link.tsx Resolved
Comment thread source/features/action-used-by-link.tsx Resolved
Comment thread source/features/action-used-by-link.tsx Resolved
Comment thread source/features/action-used-by-link.tsx Resolved
Comment thread source/features/action-used-by-link.tsx Outdated
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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JMHO

Suggested change
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)

@fregante fregante Apr 25, 2020 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.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:

Suggested change
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);

@maelle

maelle commented Apr 24, 2020

Copy link
Copy Markdown
Contributor Author

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?

Comment thread source/features/action-used-by-link.tsx Resolved
Comment thread source/features/action-used-by-link.tsx Resolved
Comment thread source/libs/page-detect.ts Resolved
Comment thread source/features/action-used-by-link.tsx Resolved
Comment thread source/features/action-used-by-link.tsx Outdated
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)

@fregante fregante Apr 25, 2020 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.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:

Suggested change
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);

@maelle

maelle commented Apr 26, 2020

Copy link
Copy Markdown
Contributor Author

I made the changes, thanks a lot, and yes it still works. 😸

Comment thread readme.md Resolved
@fregante fregante changed the title Add code search for workflows from a GitHub Action page on the marketplace Add action-used-by-link feature Apr 28, 2020
@fregante
fregante merged commit e84d858 into refined-github:master Apr 28, 2020
@fregante

Copy link
Copy Markdown
Member

Looks and works well, thank you Maëlle! 🐡

@fregante fregante mentioned this pull request Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

From a GitHub Action create a button to code search for the action use

3 participants