From 20032385006a33601946ec4da976bf26314d50e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= Date: Thu, 31 Oct 2024 21:27:35 +0100 Subject: [PATCH] Abandon Avo Literal types. --- app/views/application_view.rb | 1 + app/views/components/application_component.rb | 1 + app/views/components/events/table_component.rb | 4 +--- app/views/components/events/table_details_component.rb | 4 ++-- app/views/components/oidc/api_key_role/table_component.rb | 3 +-- .../components/oidc/id_token/key_value_pairs_component.rb | 3 +-- app/views/components/oidc/id_token/table_component.rb | 3 +-- .../oidc/trusted_publisher/github_action/form_component.rb | 4 +--- .../oidc/trusted_publisher/github_action/table_component.rb | 4 +--- app/views/oidc/id_tokens/show_view.rb | 3 +-- app/views/oidc/pending_trusted_publishers/index_view.rb | 3 +-- app/views/oidc/pending_trusted_publishers/new_view.rb | 4 +--- app/views/oidc/rubygem_trusted_publishers/index_view.rb | 5 ++--- app/views/oidc/rubygem_trusted_publishers/new_view.rb | 4 +--- app/views/profiles/security_events_view.rb | 3 +-- app/views/rubygems/security_events_view.rb | 5 ++--- 16 files changed, 19 insertions(+), 35 deletions(-) diff --git a/app/views/application_view.rb b/app/views/application_view.rb index 42743b7431a..193fbba9fd8 100644 --- a/app/views/application_view.rb +++ b/app/views/application_view.rb @@ -6,6 +6,7 @@ class ApplicationView < ApplicationComponent # By default, it inherits from `ApplicationComponent`, but you # can change that to `Phlex::HTML` if you want to keep views and # components independent. + extend PropInitializer::Properties def title=(title) @_view_context.instance_variable_set :@title, title diff --git a/app/views/components/application_component.rb b/app/views/components/application_component.rb index 75773f70368..8e8d1aa0d40 100644 --- a/app/views/components/application_component.rb +++ b/app/views/components/application_component.rb @@ -2,6 +2,7 @@ class ApplicationComponent < Phlex::HTML include Phlex::Rails::Helpers::Routes + extend PropInitializer::Properties class TranslationHelper include ActionView::Helpers::TranslationHelper diff --git a/app/views/components/events/table_component.rb b/app/views/components/events/table_component.rb index 56bf86d57b0..94cfd2b917d 100644 --- a/app/views/components/events/table_component.rb +++ b/app/views/components/events/table_component.rb @@ -12,9 +12,7 @@ class Events::TableComponent < ApplicationComponent register_value_helper :page_entries_info register_value_helper :paginate - extend Literal::Properties - - prop :security_events, _Union(ActiveRecord::Relation, Array), reader: :private + prop :security_events def view_template header(class: "gems__header push--s") do diff --git a/app/views/components/events/table_details_component.rb b/app/views/components/events/table_details_component.rb index d3d8db5f1ab..12d87747a3c 100644 --- a/app/views/components/events/table_details_component.rb +++ b/app/views/components/events/table_details_component.rb @@ -1,7 +1,7 @@ class Events::TableDetailsComponent < ApplicationComponent - extend Literal::Properties + extend PropInitializer::Properties - prop :event, _Any, reader: :private + prop :event delegate :additional, :rubygem, to: :event def view_template diff --git a/app/views/components/oidc/api_key_role/table_component.rb b/app/views/components/oidc/api_key_role/table_component.rb index 53dd5e64a52..c555e42c8c4 100644 --- a/app/views/components/oidc/api_key_role/table_component.rb +++ b/app/views/components/oidc/api_key_role/table_component.rb @@ -2,9 +2,8 @@ class OIDC::ApiKeyRole::TableComponent < ApplicationComponent include Phlex::Rails::Helpers::LinkTo - extend Literal::Properties - prop :api_key_roles, _Any, reader: :private + prop :api_key_roles def view_template table(class: "t-body") do diff --git a/app/views/components/oidc/id_token/key_value_pairs_component.rb b/app/views/components/oidc/id_token/key_value_pairs_component.rb index 51c6ef0c1a3..9e2e8463230 100644 --- a/app/views/components/oidc/id_token/key_value_pairs_component.rb +++ b/app/views/components/oidc/id_token/key_value_pairs_component.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true class OIDC::IdToken::KeyValuePairsComponent < ApplicationComponent - extend Literal::Properties - prop :pairs, _Any, reader: :private + prop :pairs def view_template dl(class: "t-body provider_attributes full-width overflow-wrap") do diff --git a/app/views/components/oidc/id_token/table_component.rb b/app/views/components/oidc/id_token/table_component.rb index a59ee0c8549..5806412491d 100644 --- a/app/views/components/oidc/id_token/table_component.rb +++ b/app/views/components/oidc/id_token/table_component.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true class OIDC::IdToken::TableComponent < ApplicationComponent - extend Literal::Properties - prop :id_tokens, _Any, reader: :private + prop :id_tokens include Phlex::Rails::Helpers::TimeTag include Phlex::Rails::Helpers::LinkToUnlessCurrent diff --git a/app/views/components/oidc/trusted_publisher/github_action/form_component.rb b/app/views/components/oidc/trusted_publisher/github_action/form_component.rb index 34fa0f5fb05..0dc9425bfaa 100644 --- a/app/views/components/oidc/trusted_publisher/github_action/form_component.rb +++ b/app/views/components/oidc/trusted_publisher/github_action/form_component.rb @@ -1,9 +1,7 @@ # frozen_string_literal: true class OIDC::TrustedPublisher::GitHubAction::FormComponent < ApplicationComponent - extend Literal::Properties - - prop :github_action_form, _Any, reader: :private + prop :github_action_form def view_template github_action_form.fields_for :trusted_publisher do |trusted_publisher_form| diff --git a/app/views/components/oidc/trusted_publisher/github_action/table_component.rb b/app/views/components/oidc/trusted_publisher/github_action/table_component.rb index be63e206bdd..090cad58468 100644 --- a/app/views/components/oidc/trusted_publisher/github_action/table_component.rb +++ b/app/views/components/oidc/trusted_publisher/github_action/table_component.rb @@ -1,7 +1,5 @@ class OIDC::TrustedPublisher::GitHubAction::TableComponent < ApplicationComponent - extend Literal::Properties - - prop :github_action, _Any, reader: :private + prop :github_action def view_template dl(class: "tw-flex tw-flex-col sm:tw-grid sm:tw-grid-cols-2 tw-items-baseline tw-gap-4 full-width overflow-wrap") do diff --git a/app/views/oidc/id_tokens/show_view.rb b/app/views/oidc/id_tokens/show_view.rb index a11162e281f..606627509f7 100644 --- a/app/views/oidc/id_tokens/show_view.rb +++ b/app/views/oidc/id_tokens/show_view.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true class OIDC::IdTokens::ShowView < ApplicationView - extend Literal::Properties include Phlex::Rails::Helpers::TimeTag include Phlex::Rails::Helpers::LinkTo - prop :id_token, OIDC::IdToken, reader: :private + prop :id_token def view_template # rubocop:disable Metrics/AbcSize self.title = t(".title") diff --git a/app/views/oidc/pending_trusted_publishers/index_view.rb b/app/views/oidc/pending_trusted_publishers/index_view.rb index ed8239fa0a4..6da982569f0 100644 --- a/app/views/oidc/pending_trusted_publishers/index_view.rb +++ b/app/views/oidc/pending_trusted_publishers/index_view.rb @@ -5,9 +5,8 @@ class OIDC::PendingTrustedPublishers::IndexView < ApplicationView include Phlex::Rails::Helpers::ContentFor include Phlex::Rails::Helpers::DistanceOfTimeInWordsToNow include Phlex::Rails::Helpers::LinkTo - extend Literal::Properties - prop :trusted_publishers, _Any, reader: :private + prop :trusted_publishers def view_template title_content diff --git a/app/views/oidc/pending_trusted_publishers/new_view.rb b/app/views/oidc/pending_trusted_publishers/new_view.rb index 2a573de4ec5..dfa998e74e8 100644 --- a/app/views/oidc/pending_trusted_publishers/new_view.rb +++ b/app/views/oidc/pending_trusted_publishers/new_view.rb @@ -6,9 +6,7 @@ class OIDC::PendingTrustedPublishers::NewView < ApplicationView include Phlex::Rails::Helpers::OptionsForSelect include Phlex::Rails::Helpers::FormWith - extend Literal::Properties - - prop :pending_trusted_publisher, OIDC::PendingTrustedPublisher, reader: :private + prop :pending_trusted_publisher def view_template self.title = t(".title") diff --git a/app/views/oidc/rubygem_trusted_publishers/index_view.rb b/app/views/oidc/rubygem_trusted_publishers/index_view.rb index bd4ac10c09e..e878d8a7a12 100644 --- a/app/views/oidc/rubygem_trusted_publishers/index_view.rb +++ b/app/views/oidc/rubygem_trusted_publishers/index_view.rb @@ -5,10 +5,9 @@ class OIDC::RubygemTrustedPublishers::IndexView < ApplicationView include Phlex::Rails::Helpers::LinkTo include Phlex::Rails::Helpers::ContentFor include OIDC::RubygemTrustedPublishers::Concerns::Title - extend Literal::Properties - prop :rubygem, Rubygem, reader: :private - prop :trusted_publishers, _Any, reader: :private + prop :rubygem + prop :trusted_publishers def view_template title_content diff --git a/app/views/oidc/rubygem_trusted_publishers/new_view.rb b/app/views/oidc/rubygem_trusted_publishers/new_view.rb index 5d207a9fdc2..fa2c1411c8c 100644 --- a/app/views/oidc/rubygem_trusted_publishers/new_view.rb +++ b/app/views/oidc/rubygem_trusted_publishers/new_view.rb @@ -8,9 +8,7 @@ class OIDC::RubygemTrustedPublishers::NewView < ApplicationView include Phlex::Rails::Helpers::SelectTag include OIDC::RubygemTrustedPublishers::Concerns::Title - extend Literal::Properties - - prop :rubygem_trusted_publisher, OIDC::RubygemTrustedPublisher, reader: :private + prop :rubygem_trusted_publisher def view_template title_content diff --git a/app/views/profiles/security_events_view.rb b/app/views/profiles/security_events_view.rb index aad7a7fe957..4fdd00a2bc4 100644 --- a/app/views/profiles/security_events_view.rb +++ b/app/views/profiles/security_events_view.rb @@ -6,9 +6,8 @@ class Profiles::SecurityEventsView < ApplicationView include Phlex::Rails::Helpers::DistanceOfTimeInWordsToNow include Phlex::Rails::Helpers::TimeTag include Phlex::Rails::Helpers::LinkTo - extend Literal::Properties - prop :security_events, _Any, reader: :private + prop :security_events def view_template title_content diff --git a/app/views/rubygems/security_events_view.rb b/app/views/rubygems/security_events_view.rb index 9d0b387a3f9..a1a242aa395 100644 --- a/app/views/rubygems/security_events_view.rb +++ b/app/views/rubygems/security_events_view.rb @@ -4,10 +4,9 @@ class Rubygems::SecurityEventsView < ApplicationView include Phlex::Rails::Helpers::ButtonTo include Phlex::Rails::Helpers::ContentFor include Phlex::Rails::Helpers::LinkTo - extend Literal::Properties - prop :rubygem, Rubygem, reader: :private - prop :security_events, _Any, reader: :private + prop :rubygem + prop :security_events def view_template title_content