-
Notifications
You must be signed in to change notification settings - Fork 875
chore: return organization's display name and icon in templates #13858
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
Emyrk
merged 9 commits into
main
from
stevenmasley/organization_display_name_with_template
Jul 10, 2024
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ef49cd7
chore: templates return organization display name and icon
Emyrk ed2b48f
templates api response includes organization display name and icon
Emyrk f7d3e17
unit test
Emyrk f3c2361
fixup typescript mocks
Emyrk 378a042
update audit table
Emyrk eb93911
make gen
Emyrk 8cae3e3
forgot swagger doc
Emyrk b3bd5a2
bump migration
Emyrk 31bd3fd
make gen
Emyrk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
chore: templates return organization display name and icon
- Loading branch information
commit ef49cd72085fb9147d08183e9b9f6c610650d290
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
coderd/database/migrations/000223_template_display_name.down.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
DROP VIEW template_with_names; | ||
|
||
CREATE VIEW | ||
template_with_names | ||
AS | ||
SELECT | ||
templates.*, | ||
coalesce(visible_users.avatar_url, '') AS created_by_avatar_url, | ||
coalesce(visible_users.username, '') AS created_by_username, | ||
coalesce(organizations.name, '') AS organization_name | ||
FROM | ||
templates | ||
LEFT JOIN | ||
visible_users | ||
ON | ||
templates.created_by = visible_users.id | ||
LEFT JOIN | ||
organizations | ||
ON templates.organization_id = organizations.id | ||
; | ||
|
||
COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.'; |
25 changes: 25 additions & 0 deletions
25
coderd/database/migrations/000223_template_display_name.up.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- Update the template_with_names view by recreating it. | ||
DROP VIEW template_with_names; | ||
CREATE VIEW | ||
template_with_names | ||
AS | ||
SELECT | ||
templates.*, | ||
coalesce(visible_users.avatar_url, '') AS created_by_avatar_url, | ||
coalesce(visible_users.username, '') AS created_by_username, | ||
coalesce(organizations.name, '') AS organization_name, | ||
coalesce(organizations.display_name, '') AS organization_display_name, | ||
coalesce(organizations.description, '') AS organization_description, | ||
coalesce(organizations.icon, '') AS organization_icon | ||
FROM | ||
templates | ||
LEFT JOIN | ||
visible_users | ||
ON | ||
templates.created_by = visible_users.id | ||
LEFT JOIN | ||
organizations | ||
ON templates.organization_id = organizations.id | ||
; | ||
|
||
COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that the created_by user is not visible by the caller of this? I'm thinking the case where someone is removed from an org after creating a template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, but we decided awhile back that if you can read the template, you should also see who created it. So granting
read
permission on the template gives some implicit permission to reading the user's name + organization information.