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

V2 configuration #644

Merged
merged 53 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7797dda
connect the controller and views
kitallis Sep 13, 2024
61e1706
minor reldex tweaks
kitallis Sep 13, 2024
76f1156
Merge remote-tracking branch 'origin/main' into v2/configuration
nid90 Sep 18, 2024
1656091
Persist platform config in a structured manner across config tables
nid90 Sep 18, 2024
b7a5a6e
Fix rake tasks to use the config models for release platform
nid90 Sep 19, 2024
ca452db
basic form render for platform config of release platforms
nid90 Sep 19, 2024
845bf1d
Fix get commit call when processing commits
nid90 Sep 19, 2024
cf0d0ce
do not overwrite existing config when loading v2 config
nid90 Sep 20, 2024
136474c
get the form working with all nested attributes for platform config
nid90 Sep 20, 2024
6f675a8
add basic config validations
nid90 Sep 23, 2024
d11d4a7
Merge remote-tracking branch 'origin/main' into v2/configuration
nid90 Sep 24, 2024
de711d8
wip - form enhancements
nid90 Sep 24, 2024
b761ba3
validate internal releases, cleaner forms, conditional tabs, new url
kitallis Sep 27, 2024
c71fa90
add workflow caches to ci/cd integrations, fix form issues
kitallis Sep 27, 2024
f63c87a
safe nav reldex computes
kitallis Sep 27, 2024
f128afd
train config tabs based on v2 or not v2
kitallis Sep 27, 2024
57aaf30
better info all around
kitallis Sep 27, 2024
dc3d21c
more destroy-aware shit validations
kitallis Sep 27, 2024
e6610eb
Merge branch 'main' into v2/configuration
nid90 Sep 27, 2024
f045897
split submissions into separate tabs because really annoying to handle
kitallis Oct 1, 2024
cd11880
redirect instead of re-render, solves all problems
kitallis Oct 1, 2024
6513760
some pr glance things
kitallis Oct 2, 2024
d0be652
unrelated: fix user edit
kitallis Oct 2, 2024
c18663a
Merge branch 'main' into v2/configuration
nid90 Oct 3, 2024
98da47c
additional validations
kitallis Oct 2, 2024
d699647
minor
kitallis Oct 2, 2024
3a67e35
simplify validation and controller logic and fix a few more issues:
kitallis Oct 3, 2024
428ee20
missed rename from previous refactor
kitallis Oct 3, 2024
50ee43b
unrelated: change passport emphasize styling
kitallis Oct 3, 2024
6915503
lint
kitallis Oct 4, 2024
ed7181e
Merge branch 'main' into v2/configuration
nid90 Oct 4, 2024
c535fa9
provider-filtered submission lists in dropdown
kitallis Oct 4, 2024
70cfe60
specs for some validations
kitallis Oct 4, 2024
fbf16ca
error msg in red
kitallis Oct 4, 2024
e643878
set default submission conf based on prod/beta
kitallis Oct 4, 2024
f88f780
update and improvements to onboarding (part 1)
kitallis Oct 4, 2024
8a96c4d
update sentry js
kitallis Oct 5, 2024
960ce45
lint
kitallis Oct 5, 2024
52f4e57
add debug log for data migration
nid90 Oct 5, 2024
46a89db
Fix anonymize script to not add duplicate workflow ids
nid90 Oct 5, 2024
3d85477
Add missing delegate for Rails cache
nid90 Oct 5, 2024
6cce518
fix missing app
nid90 Oct 5, 2024
9b7efec
fix bb retry logic
nid90 Oct 5, 2024
bbb3794
fix workflows fetch for butbucket integration
nid90 Oct 5, 2024
e229192
review comments
kitallis Oct 5, 2024
3dfb84b
fux bitbucket non-json response errors
nid90 Oct 5, 2024
3a0fb52
specs
kitallis Oct 5, 2024
0ec3410
more bb fix
nid90 Oct 5, 2024
2832e83
fix use of the new config model in workflow ru
nid90 Oct 5, 2024
8ac1ce7
passable onboarding flow
kitallis Oct 5, 2024
132b6c3
workflows should only optionally take a param
kitallis Oct 5, 2024
c617c1c
remove Train#in_creation?
kitallis Oct 6, 2024
2ffdd2c
minor onboarding changes
kitallis Oct 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .irbrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV["HOME"]}/.irb-save-history"
IRB.conf[:USE_AUTOCOMPLETE] = false

def T(slug) = Train.find_by_slug(slug)
def Rel(slug) = Release.find_by_slug(slug)
def Wrun(id) = WorkflowRun.find(id)
def B(id) = Build.find(id)
Expand Down
1 change: 0 additions & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ tunnel: ngrok start tramline_dev
web: bin/rails server -p 3000 -b 'ssl://localhost:3000?key=config/certs/localhost-key.pem&cert=config/certs/localhost.pem'
css: bin/rails tailwindcss:watch
worker: bundle exec sidekiq | tee ./log/sidekiq.log
console: bin/rails console
dbconsole: bin/rails dbconsole
12 changes: 12 additions & 0 deletions app/assets/images/v2/sliders.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 6 additions & 5 deletions app/assets/stylesheets/application.tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
@apply px-4 py-3.5;
}

.box-padding-md {
@apply px-2 py-2;
}

.box-padding-sm {
@apply px-1.5 py-0.5;
}
Expand Down Expand Up @@ -270,16 +274,13 @@ turbo-frame.with-turbo-frame-loader[busy] > *:not(.turbo-frame-loader) {
}

.emphasize {
@apply inline-block pr-1.5 pl-1.5 py-0;
@apply rounded-md;
@apply inline-block pr-1.5 pl-1.5 py-0.5;
@apply bg-main-200 text-slate-700;
}

.emphasize-link {
@apply underline;
@apply inline-block pr-1.5 pl-1.5 py-0;
@apply rounded-md;
@apply bg-main-200 text-slate-700;
@apply emphasize;
}

/* Application theme starts here */
Expand Down
9 changes: 9 additions & 0 deletions app/components/info_icon_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%= render V2::IconComponent.new("v2/info.svg", size: :md, classes: "text-secondary") do |icon| %>
<% icon.with_tooltip(nil, placement: "top", type: :detailed) do |tooltip| %>
<% tooltip.with_detailed_text do %>
<div class="flex flex-col gap-y-4 items-start">
<%= content %>
</div>
<% end %>
<% end %>
<% end %>
8 changes: 8 additions & 0 deletions app/components/info_icon_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

class InfoIconComponent < V2::BaseComponent
def initialize(placement: "top")
@placement = placement
@icon = V2::IconComponent.new("v2/info.svg", size: :md, classes: "text-secondary")
end
end
2 changes: 1 addition & 1 deletion app/components/v2/base_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class V2::BaseComponent < ViewComponent::Base
:ci_cd_provider_logo,
:vcs_provider_logo,
:live_release_tab_configuration,
:current_overall_status,
:live_release_overall_status,
:teams_supported?,
to: :helpers
delegate :team_colors, to: :current_organization
Expand Down
5 changes: 3 additions & 2 deletions app/components/v2/button_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class V2::ButtonComponent < V2::BaseComponent
renders_one :icon, V2::IconComponent
renders_one :tooltip, ->(text, **args) { V2::TooltipComponent.new(text, **args.merge(cursor: false)) }

def initialize(label: nil, scheme: :switcher, type: :button, size: :xxs, options: nil, html_options: nil, arrow: :none, authz: true, turbo: true, disabled: false)
def initialize(label: nil, scheme: :switcher, type: :button, size: :xxs, options: nil, html_options: nil, arrow: :none, authz: true, turbo: true, disabled: false, auto_label_case: true)
arrow = (scheme == :switcher) ? :double : arrow
raise ArgumentError, "Invalid scheme" unless SCHEMES.include?(scheme)
raise ArgumentError, "Invalid button type" unless TYPES.include?(type)
Expand All @@ -57,12 +57,13 @@ def initialize(label: nil, scheme: :switcher, type: :button, size: :xxs, options
@authz = authz
@disabled = disabled
@turbo = turbo
@auto_label_case = auto_label_case
end

def before_render
super
@html_options = apply_html_options(@html_options)
@label = @label&.humanize if button? || action?
@label = @label&.humanize if @auto_label_case && (button? || action?)
end

def render_component
Expand Down
24 changes: 10 additions & 14 deletions app/components/v2/form/switch_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<section class="grid gap-4"
data-controller="toggle-switch"
data-toggle-switch-on-label-value="<%= on_label %>"
data-toggle-switch-off-label-value="<%= off_label %>">
<div class="grid gap-4"
data-controller="toggle-switch"
data-toggle-switch-on-label-value="<%= on_label %>"
data-toggle-switch-off-label-value="<%= off_label %>">
<% if heading.present? %>
<div class="text-slate-600 font-medium"><%= heading %></div>
<% end %>
Expand All @@ -12,23 +12,19 @@
</div>
<% end %>

<div class="flex items-center">
<div class="flex items-center gap-1.5">
<div class="form-switch">
<%= form.check_box field_name,
switch_options,
"true", "false" %>
<label class="bg-slate-400" for="<%= switch_id %>">
<span class="bg-white shadow" aria-hidden="true"></span>
<span class="sr-only">Switch label</span>
</label>
<%= form_checkbox %>
<%= form_label %>
</div>

<div class="text-sm text-slate-600 ml-2" data-toggle-switch-target="output"></div>
<div class="<%= EnhancedFormHelper::AuthzForm::BASE_LABEL_CLASSES %>" data-toggle-switch-target="output"></div>
<%= info_icon if info_icon? %>
</div>

<% if child.present? %>
<div data-toggle-switch-target="child" <%= hide_child %>>
<%= child %>
</div>
<% end %>
</section>
</div>
16 changes: 13 additions & 3 deletions app/components/v2/form/switch_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class V2::Form::SwitchComponent < ViewComponent::Base
renders_one :child
renders_one :heading
renders_one :description
renders_one :info_icon, InfoIconComponent

def initialize(form:, field_name:, on_label: "Enabled", off_label: "Disabled", hide_child: true, switch_id: nil, switch_data: {}, html_options: {})
@form = form
Expand All @@ -28,9 +29,7 @@ def hide_child
end

def switch_options
{id: switch_id,
class: "sr-only",
data: switch_data}.merge(@html_options)
{class: "sr-only", data: switch_data}.merge(@html_options)
end

def data_actions
Expand All @@ -43,4 +42,15 @@ def switch_data
{action: data_actions,
toggle_switch_target: "checkbox"}.merge(@switch_data.except(:action))
end

def form_label
form.label field_name, class: "bg-slate-400" do
content_tag(:span, nil, class: "bg-white shadow", aria: {hidden: true})
.concat(content_tag(:span, nil, class: "sr-only"))
end
end

def form_checkbox
form.check_box field_name, switch_options, "true", "false"
end
end
2 changes: 1 addition & 1 deletion app/components/v2/live_release/container_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def initialize(release, title:, error_resource: nil)
:stop_release_warning, to: :release

def overall_status
RELEASE_PHASE.fetch(current_overall_status.to_sym)
RELEASE_PHASE.fetch(live_release_overall_status.to_sym)
end

def sorted_sections
Expand Down
8 changes: 4 additions & 4 deletions app/components/v2/live_release/internal_builds_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def configured?(run)
configuration(run).present?
end

def configuration(run)
run.conf.internal_release
def internal_workflow_config(run)
run.conf.pick_internal_workflow
end

def internal_workflow_config(run)
run.conf.workflows.pick_internal_workflow
def configuration(run)
run.conf.internal_release
end

def latest_internal_release(run)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def configuration(release_platform_run)
end

def workflow_config(release_platform_run)
release_platform_run.conf.workflows.release_candidate_workflow
release_platform_run.conf.release_candidate_workflow
end

def latest_beta_release(release_platform_run)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<!-- loop over the deployments/submissions -->
<div class="grid justify-self-start grid-flow-col items-center">
<div class="border-t mr-1 border-main-300 border-dashed w-5"></div>
<%= render V2::BadgeComponent.new(text: submission.submission_config.name, kind: :badge) do |badge| %>
<% badge.with_icon("integrations/logo_#{submission.submission_type.new(release_platform_run:).provider}.png") %>
<%= render V2::BadgeComponent.new(text: submission.submission_external.name, kind: :badge) do |badge| %>
<% badge.with_icon("integrations/logo_#{submission.submission_class.new(release_platform_run:).provider}.png") %>
<% end %>
</div>
<% submission = submission.next %>
Expand Down
8 changes: 4 additions & 4 deletions app/components/v2/reldex/form_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</div>
<% components.each do |component| %>
<div class="" data-controller="domain--release-index-component">
<div class="px-1 py-3 grid grid-cols-6 items-center gap-x-10 text-sm">
<div class="px-1 py-3 grid grid-cols-6 items-start gap-x-10 text-sm">
<% section.F.fields_for :release_index_components, component do |component_fields| %>
<div class="col-span-2">
<div class="flex items-center gap-1.5">
Expand All @@ -72,9 +72,9 @@
<% end %>
<% end %>
<% end %>
<div hidden data-domain--release-index-component-target="inactive">
<%= render V2::BadgeComponent.new(text: "Excluded", kind: :badge) %>
</div>
</div>
<div hidden data-domain--release-index-component-target="inactive">
<%= render V2::BadgeComponent.new(text: "Excluded", kind: :badge) %>
</div>
</div>
<div class="col-span-1">
Expand Down
4 changes: 2 additions & 2 deletions app/components/v2/reldex/status_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def grade
end

def tolerable_min
@reldex_score.release_index.tolerable_range.min
@reldex_score.release_index&.tolerable_range&.min
end

def tolerable_max
@reldex_score.release_index.tolerable_range.max
@reldex_score.release_index&.tolerable_range&.max
end

def components
Expand Down
29 changes: 7 additions & 22 deletions app/components/v2/release_list_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -248,30 +248,15 @@
<% end %>
<% end %>

<% if train.in_creation? %>
<% if no_releases? %>
<% container.with_empty_state do %>
<%= render V2::EmptyStateComponent.new(
title: "Incomplete train configuration",
text: "Once you've finished configuring your train fully, you can start creating new releases.",
banner_image: "art/no_releases.png") do %>
<div>
<%= render V2::ButtonComponent.new(scheme: :default,
type: :link,
label: "Configure train",
options: steps_app_train_path(train.app, train),
size: :xxs,
authz: false) do |b| %>
<% b.with_icon("v2/cog.svg", size: :md) %>
<% end %>
</div>
<%= render V2::EmptyStateComponent.new(title: no_release_empty_state[:title], text: no_release_empty_state[:text], banner_image: "art/no_releases.png") do %>
<% if no_release_empty_state[:content].present? %>
<div>
<%= no_release_empty_state[:content] %>
</div>
<% end %>
<% end %>
<% end %>
<% elsif empty? %>
<% container.with_empty_state do %>
<%= render V2::EmptyStateComponent.new(
title: empty_state[:title],
text: empty_state[:text],
banner_image: "art/no_releases.png") %>
<% end %>
<% end %>
<% end %>
10 changes: 7 additions & 3 deletions app/components/v2/release_list_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def initialize(train:)
attr_reader :train, :ongoing_release, :hotfix_release, :upcoming_release
delegate :app, :hotfix_from, to: :train

def empty?
# we don't check for train.releases.none?
# because the constituent releases that are loaded on the page are already memoized, so we avoid a query
def no_releases?
previous_releases.empty? && ongoing_release.nil? && upcoming_release.nil? && hotfix_release.nil? && last_completed_release.nil?
end

Expand Down Expand Up @@ -85,7 +87,7 @@ def ios_enabled?
app.cross_platform? || app.ios?
end

def empty_state
def no_release_empty_state
if train.automatic?
if train.activatable?
{
Expand All @@ -99,9 +101,11 @@ def empty_state
}
end
else
platform = train.release_platforms.first.platform
{
title: "Create your very first release",
text: "Once you've finished configuring your train fully, you can start creating new releases."
text: "You can now start creating new releases. We have added some default submissions settings for you. This involves picking the right workflows and configuring the right channels for build distribution. Please review these starting a release.",
content: render(V2::ButtonComponent.new(scheme: :light, type: :link, label: "Review submission settings", options: edit_app_train_platform_submission_config_path(app, train, platform), size: :xxs, authz: false))
}
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/components/v2/simple_tab_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
type: :action,
label: tab[:name],
authz: false,
html_options: { data: { action: "click->tabs#change", tabs_target: "tab" }, aria_selected: tab[:selected], aria_controls: "overall-tab" })
auto_label_case: false,
html_options: { data: { action: "click->tabs#change", tabs_target: "tab" } })
%>
</li>
<% end %>
Expand Down
22 changes: 12 additions & 10 deletions app/components/v2/tabbed_container_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@
data-activation-inactive-value="<%= TAB_STYLE %>">
<% sorted_configs.each do |(_position, name, path, icon)| %>
<li class="me-2">
<a href="<%= path %>"
data-activation-target="target"
data-action="click->activation#toggle"
data-turbo-action="replace"
data-turbo-frame="<%= frame %>"
class="<%= style(path) %>"
aria-selected="false">
<%= render V2::IconComponent.new(icon, size: :md, classes: "me-2") %>
<%= name %>
</a>
<div data-turbo-prefetch="false">
<a href="<%= path %>"
data-activation-target="target"
data-action="click->activation#toggle"
data-turbo-action="replace"
data-turbo-frame="<%= frame %>"
class="<%= style(path) %>"
aria-selected="false">
<%= render V2::IconComponent.new(icon, size: :md, classes: "me-2") %>
<%= name %>
</a>
</div>
</li>
<% end %>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/accounts/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def edit

def update
if @user.update(parsed_user_params)
redirect_back fallback_location: root_path, notice: "Account was successfully updated."
redirect_to edit_accounts_user_path, notice: "Account was successfully updated."
else
render :edit, status: :unprocessable_entity
end
Expand Down
Loading