Skip to content
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

Update flash message to contain link to github actions after save & sync #3038

Merged
merged 9 commits into from
Mar 24, 2025

Conversation

midigofrank
Copy link
Collaborator

@midigofrank midigofrank commented Mar 19, 2025

Description

This PR updates flash message to contain link to github actions after save & sync

Closes #2989

Validation steps

You need to have github sync setup for your project in order to test this locally

  1. In the workflow edit page, make a change.
  2. Press ctrl-shift-s or command-shift-s if you're using mac. Press Save and Sync in the modal that pops up.
  3. You'll get a flash message with a link to the github actions

Additional notes for the reviewer

I have made the flash message to be either a text, or a map with :function and :attrs keys.
I think we should have a type for dynamic components. I wanted to name my key :assigns instead of :attrs but I chose to stick with :attrs because it's already being used to display the :banner.
Something like:

%LightningWeb.DynamicComponent{function: fun(), assigns: map()}

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Pre-submission checklist

  • I have performed a self-review of my code.
  • I have implemented and tested all related authorization policies. (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

@midigofrank midigofrank self-assigned this Mar 19, 2025
Copy link

codecov bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.72%. Comparing base (8cf9452) to head (12e6dc6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/lightning_web/live/components/common.ex 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3038      +/-   ##
==========================================
+ Coverage   91.69%   91.72%   +0.02%     
==========================================
  Files         349      350       +1     
  Lines       12975    12988      +13     
==========================================
+ Hits        11898    11913      +15     
+ Misses       1077     1075       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@midigofrank midigofrank marked this pull request as ready for review March 19, 2025 05:47
@midigofrank midigofrank requested review from stuartc and elias-ba March 19, 2025 05:47
@midigofrank
Copy link
Collaborator Author

Okay, so I have introduced DynamicComponent struct to have a strict type. There's also a dynamic_component function which encapsulates the call to TagEngine

Copy link
Contributor

@elias-ba elias-ba left a comment

Choose a reason for hiding this comment

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

@midigofrank my man, I loved every piece in here. Nice job man 👏🏽 🔥

@@ -402,16 +415,20 @@ defmodule LightningWeb.Components.Common do
phx-hook="Flash"
>
<div class="flex justify-between items-center space-x-3 text-red-900">
<Heroicons.exclamation_circle solid class="w-5 h-5" />
<.icon name="hero-exclamation-circle-solid" class="w-5 h-5" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice ❤️

Comment on lines 1 to 14
defmodule LightningWeb.DynamicComponent do
@moduledoc """
Provides a type to be used in assigns to denote a dynamic component
"""
@type t() :: %LightningWeb.DynamicComponent{function: fun(), args: map()}
@enforce_keys [:function, :args]
defstruct [:function, :args]

@doc "Checks whether the given value can be rendered as a dynamic component"
@spec is_dynamic_component?(any()) :: boolean()
def is_dynamic_component?(val) do
is_struct(val, __MODULE__)
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Amazing 🔥

Copy link
Member

@stuartc stuartc left a comment

Choose a reason for hiding this comment

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

This looks good @midigofrank, just need to fix up the tests - assuming it's not flaky.


assert has_element?(
view,
~s{#flash [href="#{link_to_actions}"][target="_blank"]},
Copy link
Member

Choose a reason for hiding this comment

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

This test is failing, perhaps because we don't have a #flash element anymore, since the unique ids changes we use this to find flash messages: [data-flash-kind='info'].

@midigofrank midigofrank requested a review from stuartc March 24, 2025 11:01
@midigofrank
Copy link
Collaborator Author

Hey @stuartc , I have fixed the failing test. It was because we no longer have a #flash element. Let's merge in this first because it has the dynamic component component 😓

@stuartc stuartc merged commit 30fb1c5 into main Mar 24, 2025
8 checks passed
@stuartc stuartc deleted the fix-github-sync-flash-message branch March 24, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Save & Sync toast message is misleading
3 participants