Skip to content

Show user name in content list header #235

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 5 commits into from
Jul 10, 2025
Merged

Show user name in content list header #235

merged 5 commits into from
Jul 10, 2025

Conversation

dotNomad
Copy link
Collaborator

This PR shows the user's name in the content list header in the Package Vulnerability Scanner making it clear whose content you are viewing.

It will use first name + last name if both are available, falling back to one or the other, and finally the user name if neither are set.

Fixes #210

Preview CleanShot 2025-07-10 at 11 48 54

These changes have been published to our internal Dogfood server here.

Copy link
Contributor

@fizzboop fizzboop left a comment

Choose a reason for hiding this comment

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

yay for user types! 🎉

Copy link
Contributor

@marcosnav marcosnav left a comment

Choose a reason for hiding this comment

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

Smaller PRs are 1000% great and easier to review, thank you for splitting up this work!

Comment on lines +13 to +15
const props = defineProps<{
user: User;
}>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Since ContentList already makes use of stores, is there a reason to create a prop and not import userStore directly here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I do this to help with typing.

App.vue has a loading spinner while the vulnerability store, content store, and user store are loading in data. The ContentList only renders when the user store has a user, so if I pass it as a prop I can tell this component that it is guaranteed to have the data. If I use userStore.user directly I will have to either have undefined checks or use the TypeScript non-null assertion operator (!)

Comment on lines +108 to +104
let name;

if (props.user.first_name && props.user.last_name) {
name = `${props.user.first_name} ${props.user.last_name}`;
} else if (props.user.first_name) {
name = props.user.first_name;
} else if (props.user.last_name) {
name = props.user.last_name;
}

if (name === undefined) {
name = props.user.username;
}

return `${name}'s Connect Content`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto from previous PRs, what about encapsulating this within the store to something like userStore.headerDisplayLabel ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah if I do this I'm realizing that I'll have to handle undefined and I lose the guaranteed nature of using prop.user. I'll leave this as is, but if I need the user's name in a display format in other places in the future I'll move it to the store.

Base automatically changed from dotnomad/211 to main July 10, 2025 23:06
@dotNomad dotNomad merged commit a3aa011 into main Jul 10, 2025
18 checks passed
@dotNomad dotNomad deleted the dotnomad/210 branch July 10, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include the name of the user on the content list page
3 participants