Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: add fallback icons for notifications#17013

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
defelmnq merged 11 commits intomainfromnotif-inbox/internal-522
Mar 28, 2025
Merged

Conversation

defelmnq
Copy link
Contributor

@defelmnqdefelmnq commentedMar 20, 2025
edited by mtojek
Loading

@defelmnqdefelmnq changed the titlework on fallback iconsfix: add fallback icons for notificationsMar 26, 2025
Comment on lines 39 to 69
var fallbackIcons = map[uuid.UUID]string{
// workspace related notifications
notifications.TemplateWorkspaceCreated: FallbackIconWorkspace,
notifications.TemplateWorkspaceCreated: FallbackIconWorkspace,
notifications.TemplateWorkspaceManuallyUpdated: FallbackIconWorkspace,
notifications.TemplateWorkspaceDeleted: FallbackIconWorkspace,
notifications.TemplateWorkspaceAutobuildFailed: FallbackIconWorkspace,
notifications.TemplateWorkspaceDormant: FallbackIconWorkspace,
notifications.TemplateWorkspaceAutoUpdated: FallbackIconWorkspace,
notifications.TemplateWorkspaceMarkedForDeletion: FallbackIconWorkspace,
notifications.TemplateWorkspaceManualBuildFailed: FallbackIconWorkspace,
notifications.TemplateWorkspaceOutOfMemory: FallbackIconWorkspace,
notifications.TemplateWorkspaceOutOfDisk: FallbackIconWorkspace,

// account related notifications
notifications.TemplateUserAccountCreated: FallbackIconAccount,
notifications.TemplateUserAccountDeleted: FallbackIconAccount,
notifications.TemplateUserAccountSuspended: FallbackIconAccount,
notifications.TemplateUserAccountActivated: FallbackIconAccount,
notifications.TemplateYourAccountSuspended: FallbackIconAccount,
notifications.TemplateYourAccountActivated: FallbackIconAccount,
notifications.TemplateUserRequestedOneTimePasscode: FallbackIconAccount,

// template related notifications
notifications.TemplateTemplateDeleted: FallbackIconTemplate,
notifications.TemplateTemplateDeprecated: FallbackIconTemplate,
notifications.TemplateWorkspaceBuildsFailedReport: FallbackIconTemplate,

// other related notifications
notifications.TemplateTestNotification: FallbackIconOther,
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test to ensure that each notification template type has a fallback icon associated with it?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Added some tests 👀

Comment on lines 196 to 197
payload.InboxNotification.Icon = fallbackIcons[payload.InboxNotification.TemplateID]
}
Copy link
Member

Choose a reason for hiding this comment

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

Same here, we should check that there is a fallback icon defined.

Thoought: would it make sense to encapsulate this logic in a functionInboxNotification.Icon()?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I created an util function to have only one place on the which we change it.

I was willing to do it as a method for thecodersdk.InboxNotification receiver, but can't as it generates import cycle with the templates. :(

Comment on lines 67 to 68
// other related notifications
notifications.TemplateTestNotification: FallbackIconOther,
Copy link
Member

Choose a reason for hiding this comment

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

WDYT about returningFallbackIconOther iffallbackIcons[notif.TemplateID] does not exist? so eventually the order would be:

  1. Custom notif icon.
  2. fallbackIcons[notif.TemplateID]
  3. FallbackIconOther

In this case we won't need to add entries to fallbackIcons if FallbackIconOther is fine, includingTemplateTestNotification.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks for the idea, like it and will make it more reliable. I added a fallback logic, please tell me if that's what you had in mind.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, thank you!

@defelmnqdefelmnq marked this pull request as ready for reviewMarch 27, 2025 15:54
Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

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

@defelmnq is it still a draft PR?

Comment on lines 33 to 36
FallbackIconWorkspace = "DEFAULT_WORKSPACE_ICON"
FallbackIconAccount = "DEFAULT_ACCOUNT_ICON"
FallbackIconTemplate = "DEFAULT_TEMPLATE_ICON"
FallbackIconOther = "DEFAULT_OTHER_ICON"
Copy link
Member

Choose a reason for hiding this comment

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

If these are values processed by "site", you should place them in codersdk as Enum, so they will be generated to TS.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This is a really good idea, thanks for that - I moved it.

cc@BrunoQuaresma you would be able to use it now.

FallbackIconOther = "DEFAULT_OTHER_ICON"
)

var fallbackIcons = map[uuid.UUID]string{
Copy link
Member

Choose a reason for hiding this comment

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

alternative data structure:

fallbackIcons = map[NotificationIcon][]uuid.UUID

not a must, just a preference

@defelmnqdefelmnq requested a review frommtojekMarch 28, 2025 09:37
Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

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

Thank you!!

Comment on lines 67 to 68
// other related notifications
notifications.TemplateTestNotification: FallbackIconOther,
Copy link
Member

Choose a reason for hiding this comment

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

Yes, thank you!

@defelmnqdefelmnq merged commit148dae1 intomainMar 28, 2025
31 of 33 checks passed
@defelmnqdefelmnq deleted the notif-inbox/internal-522 branchMarch 28, 2025 11:21
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMar 28, 2025
@matifali
Copy link
Member

/cherry-pick release/2.21

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mtojekmtojekmtojek approved these changes

@johnstcnjohnstcnAwaiting requested review from johnstcn

Assignees

@defelmnqdefelmnq

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@defelmnq@matifali@johnstcn@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp