From 831f750cd34bd2bb8dc8908aeb318b486b01d350 Mon Sep 17 00:00:00 2001 From: Ivan Kuchin Date: Tue, 8 Apr 2025 14:23:34 +0200 Subject: [PATCH] remove hover card fallback for the case when phase is absent or not active --- .../phases/hover_card_component.html.erb | 44 ++++++++----------- .../phases/hover_card_component_spec.rb | 16 ------- 2 files changed, 18 insertions(+), 42 deletions(-) diff --git a/app/components/projects/phases/hover_card_component.html.erb b/app/components/projects/phases/hover_card_component.html.erb index 085db25eec6..b5cc2c84a3d 100644 --- a/app/components/projects/phases/hover_card_component.html.erb +++ b/app/components/projects/phases/hover_card_component.html.erb @@ -28,39 +28,31 @@ See COPYRIGHT and LICENSE files for more details. ++#%> <%= - if @phase&.active? - flex_layout(classes: "op-phase-gate-hover-card", data: { test_selector: "phase-gate-hover-card-#{phase.id}" }) do |flex| - flex.with_row do - flex_layout(classes: "op-phase-gate-hover-card--info", justify_content: :space_between) do |f| - f.with_column(classes: "op-phase-gate-hover-card--name flex-self-start") do - flex_layout do |fl| - fl.with_column(classes: icon_color_class, mr: 1) do - render Primer::Beta::Octicon.new(icon: gate_icon) - end - fl.with_column do - render(Primer::Beta::Text.new(data: { test_selector: "phase-gate-hover-card-name" })) { phase_gate_name } - end + flex_layout(classes: "op-phase-gate-hover-card", data: { test_selector: "phase-gate-hover-card-#{phase.id}" }) do |flex| + flex.with_row do + flex_layout(classes: "op-phase-gate-hover-card--info", justify_content: :space_between) do |f| + f.with_column(classes: "op-phase-gate-hover-card--name flex-self-start") do + flex_layout do |fl| + fl.with_column(classes: icon_color_class, mr: 1) do + render Primer::Beta::Octicon.new(icon: gate_icon) + end + fl.with_column do + render(Primer::Beta::Text.new(data: { test_selector: "phase-gate-hover-card-name" })) { phase_gate_name } end end + end - f.with_column(classes: "op-phase-gate-hover-card--date flex-self-end") do - flex_layout do |fl| - fl.with_column(mr: 1) do - render Primer::Beta::Octicon.new(icon: :calendar, color: :muted) - end - fl.with_column do - render(Primer::Beta::Text.new(data: { test_selector: "phase-gate-hover-card-date" })) { phase_gate_date } - end + f.with_column(classes: "op-phase-gate-hover-card--date flex-self-end") do + flex_layout do |fl| + fl.with_column(mr: 1) do + render Primer::Beta::Octicon.new(icon: :calendar, color: :muted) + end + fl.with_column do + render(Primer::Beta::Text.new(data: { test_selector: "phase-gate-hover-card-date" })) { phase_gate_date } end end end end end - else - render Primer::Beta::Blankslate.new(border: false, narrow: true) do |component| - component.with_visual_icon(icon: "x-circle") - # Show a generic error message to avoid leaking information - component.with_heading(tag: :h3).with_content(I18n.t("http.response.unexpected")) - end end %> diff --git a/spec/components/projects/phases/hover_card_component_spec.rb b/spec/components/projects/phases/hover_card_component_spec.rb index 6f46fb674bd..117d67da0f7 100644 --- a/spec/components/projects/phases/hover_card_component_spec.rb +++ b/spec/components/projects/phases/hover_card_component_spec.rb @@ -76,20 +76,4 @@ RSpec.describe Projects::Phases::HoverCardComponent, type: :component do end end end - - context "when inactive" do - let(:phase) { build_stubbed(:project_phase, active: false) } - - it "renders a generic error message" do - expect(page).to have_text(I18n.t("http.response.unexpected")) - end - end - - context "when phase cannot be found in database" do - let(:phase) { nil } - - it "renders a generic error message" do - expect(page).to have_text(I18n.t("http.response.unexpected")) - end - end end