Skip to content

Add isUserSettings #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 3, 2021
Merged

Conversation

stefanbuck
Copy link
Contributor

@stefanbuck stefanbuck commented Apr 30, 2021

Add isUserSettings detector.

Test url:
https://github.com/settings

btw. the live demo is super helpful 👏

Copy link
Member

@yakov116 yakov116 left a comment

Choose a reason for hiding this comment

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

LGYM

index.ts Outdated
@@ -377,6 +377,11 @@ collect.set('isRepoMainSettings', [
'https://github.com/sindresorhus/refined-github/settings',
]);

export const isUserSettings = (url: URL | HTMLAnchorElement | Location = location): boolean => getCleanPathname(url) === 'settings';
collect.set('isUserSettings', [
'https://github.com/settings',
Copy link
Member

@fregante fregante May 2, 2021

Choose a reason for hiding this comment

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

This page doesn't exist, it's a redirect to https://github.com/settings/profile and this page doesn't match isUserSettings.

I think the check should be url.pathname.startsWith('/settings/')

Copy link
Member

@yakov116 yakov116 May 2, 2021

Choose a reason for hiding this comment

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

I think this is why we never made that. We always made specific pages as we needed it (I did not notice the redirect as I was on mobile)

Copy link
Member

Choose a reason for hiding this comment

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

What do you need this for @stefanbuck?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good shout. Addressed in 1bf7bdf

Copy link
Member

Choose a reason for hiding this comment

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

@stefanbuck what is your use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stefanbuck what is your use case?

I'm working on a new browser extension and I was thinking about adding the extension settings right into GitHub rather than using an extension settings dialog.

Copy link
Member

Choose a reason for hiding this comment

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

Looking forward to seeing that! Are you planning to use webext-options-sync?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

webext-options-sync looks neat, so I will consider using it.

index.ts Outdated
@@ -377,6 +377,12 @@ collect.set('isRepoMainSettings', [
'https://github.com/sindresorhus/refined-github/settings',
]);

export const isUserSettings = (url: URL | HTMLAnchorElement | Location = location): boolean => url.pathname.startsWith('/settings/');
collect.set('isUserSettings', [
'https://github.com/settings/',
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't exist and should be removed.

Also the tests are failing because all the URLs in this file are tested against each other, so if any other URL matches this function, it should be included in this array. The test error will tell you exactly which URLs are missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry my fault, I was in rush and only made the change without running the tests locally first. I made the change in 229cc84

Copy link
Member

Choose a reason for hiding this comment

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

No worries, some repos have stricter tests than others 😅

@yakov116
Copy link
Member

yakov116 commented May 2, 2021

If this is accepted I would like to see 2 new additions.

isUserSetting and isuserProfileSettings

isRepliesSettings would need to be updated too.

@fregante
Copy link
Member

fregante commented May 2, 2021

isuserProfileSettings

What for?

isRepliesSettings would need to be updated too.

Do you mean it should be renamed?

@yakov116

This comment has been minimized.

@fregante

This comment has been minimized.

@yakov116

This comment has been minimized.

@fregante

This comment has been minimized.

@yakov116

This comment has been minimized.

@fregante fregante added the enhancement New feature or request label May 3, 2021
@fregante
Copy link
Member

fregante commented May 3, 2021

Thanks for the PR @stefanbuck :)

@fregante fregante merged commit a18db82 into refined-github:master May 3, 2021
Comment on lines +383 to +384
'https://github.com/settings/replies',
'https://github.com/settings/replies/88491/edit',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'https://github.com/settings/replies',
'https://github.com/settings/replies/88491/edit',
...collect.get('isRepliesSettings') as string[],

Copy link
Member

Choose a reason for hiding this comment

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

I'll include that in my other PR

@stefanbuck stefanbuck deleted the isUserSettings branch May 3, 2021 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants