Skip to content

Show token owner in options page - #7380

Merged
fregante merged 4 commits into
refined-github:mainfrom
its-miroma:username
Jun 2, 2024
Merged

fregante merged 4 commits into
refined-github:mainfrom
its-miroma:username

Conversation

@its-miroma

Copy link
Copy Markdown
Contributor

Related to #6000 (comment)

Screenshot

why_is_that_token_not_hidden

@fregante fregante left a comment

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.

Thank you! Can you move it next to the field instead? Where this appears:

Screenshot 2024-06-02 at 14 16 03

Mockup:

Screenshot 2024-06-02 at 14 19 17

@fregante fregante added the meta Related to Refined GitHub itself label Jun 2, 2024
@its-miroma

Copy link
Copy Markdown
Contributor Author

ٍSome longer usernames and names may not fit next to the token input box.

@fregante

fregante commented Jun 2, 2024

Copy link
Copy Markdown
Member

I see space for about 35 characters, if someone has a username that long they're seeing it wrapping/clipping/causing issues all over the interface already.
Screenshot 2024-06-02 at 14 34 59

and even then, it's already very close to the limit:

Screenshot 2024-06-02 at 14 36 44

@its-miroma

Copy link
Copy Markdown
Contributor Author

No, I mean that I had implemented show-names, which would show @its-miroma (Miroma)

@fregante

fregante commented Jun 2, 2024

Copy link
Copy Markdown
Member

Ah yes, that part should be removed. show-names doesn't show your own username either for example.

Comment thread source/options.tsx Outdated
Comment on lines +117 to +118
const scopes = await getTokenScopes(tokenField.value);
const text = `👤 @${await getNameFromToken(tokenField.value)}`;

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.

Better parallelize them:

Suggested change
const scopes = await getTokenScopes(tokenField.value);
const text = `👤 @${await getNameFromToken(tokenField.value)}`;
const [scopes, user] = await Promise.all([
getTokenScopes(tokenField.value),
getNameFromToken(tokenField.value),
]);

The emoji is part of the UI so it should be added near the DOM/HTML generation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The emoji is part of the UI so it should be added near the DOM/HTML generation

I'm sorry, I'm unsure how to do that, I can't find any place where the HTML is generated. The images seem to get added through CSS

@fregante

fregante commented Jun 2, 2024

Copy link
Copy Markdown
Member

I like it!

Untitled

Thank you Miroma!

@fregante
fregante merged commit eb1d1af into refined-github:main Jun 2, 2024
@fregante fregante changed the title Show logged-in user's name in token input Show token owner in options page Jun 2, 2024
@fregante fregante added enhancement and removed meta Related to Refined GitHub itself labels Jun 2, 2024
@fregante

fregante commented Jun 2, 2024 •

Copy link
Copy Markdown
Member

I forgot to mention this: it lacks support for GitHub Enterprise and it will break for GHE users. Can you add it? If not, I'd have to revert this PR before the next release. It looks like this:

async function getTokenScopes(personalToken: string): Promise<string[]> {
const tokenLink = $('a#personal-token-link')!;
const url = tokenLink.host === 'github.com'
? 'https://api.github.com/'
: `${tokenLink.origin}/api/v3/`;

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.

2 participants