Files
ubicloud/views/github/setting.erb
Jeremy Evans cb389c5144 Use Roda part plugin to simplify render calls with locals
This uses the new part plugin to simplify and optimize render
calls with locals.

```ruby
render(:template, locals: {foo: 'bar'})

part(:template, foo: 'bar')
```

This simplifies a large number of calls in Clover, since
rendering with locals is one of the most common method
calls in the templates.

The main advantage of this is simplicity, but the part method
is also more optimized, and will be even more optimized when
we upgrade to Ruby 3.4.

Diff best reviewed with:

```
git diff -b --color-words --word-diff-regex='\\w+|[^[:space:]]'
```
2025-01-31 09:47:06 -08:00

78 lines
3.2 KiB
Plaintext

<% @page_title = "GitHub Runner Settings" %>
<% if @installations.count > 0 %>
<div class="auto-refresh hidden" data-interval="10"></div>
<%== render("github/tabbar") %>
<div class="grid gap-6">
<!-- GitHub Installations Card -->
<div>
<div class="md:flex md:items-center md:justify-between pb-1 lg:pb-2">
<div class="min-w-0 flex-1">
<h3 class="text-2xl font-bold leading-7 text-gray-900 sm:truncate sm:text-2xl sm:tracking-tight">
Connected Accounts
</h3>
</div>
<div class="mt-4 flex md:ml-4 md:mt-0">
<%== part("components/button", text: "Connect New Account", link: "#{@project_data[:path]}/github/installation/create") %>
</div>
</div>
<div class="overflow-hidden rounded-lg shadow ring-1 ring-black ring-opacity-5 bg-white divide-y divide-gray-200">
<table class="min-w-full divide-y divide-gray-300">
<tbody class="divide-y divide-gray-200 bg-white">
<% @installations.each do |ins| %>
<tr>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6" scope="row">
<%= ins[:name] %>
</td>
<td class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6">
<div class="flex items-center justify-end space-x-4">
<form action="<%= "#{@project_data[:path]}/github/installation/#{ins[:ubid]}" %>" role="form" method="POST">
<%== csrf_tag("#{@project_data[:path]}/github/installation/#{ins[:ubid]}") %>
<%== part("components/form/hidden", name: "cache_enabled", value: !ins[:cache_enabled]) %>
<%== part(
"components/button",
**(
if ins[:cache_enabled]
{ text: "Disable Ubicloud Cache", type: "danger" }
else
{ text: "Enable Ubicloud Cache", type: "primary" }
end
)
) %>
</form>
<%== part("components/button", text: "Configure", link: ins[:installation_url]) %>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<% elsif !@project.has_valid_payment_method? %>
<form action="<%= "#{@project_data[:path]}/billing" %>" method="POST">
<%== csrf_tag("#{@project_data[:path]}/billing") %>
<%== part(
"components/empty_state",
icon: "hero-banknotes",
title: "No billing information",
description:
"Project doesn't have valid billing information. First, you need to update the project's billing details to use GitHub Runners.",
button_title: "New Billing Information"
) %>
</form>
<% else %>
<%== part(
"components/empty_state",
icon: "github",
title: "No Connected Accounts",
description: "Get started by installing our GitHub app to your user or organization account.",
button_link: "#{@project_data[:path]}/github/installation/create",
button_title: "Connect New Account"
) %>
<% end %>