Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 app/controllers/comfy/admin/web_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def subdomain_params
:enable_2fa,
:email_notification_strategy,
:track_email_opens,
shortcuts_attributes: [:name, :path],
)
end
end
8 changes: 8 additions & 0 deletions app/models/shortcut.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Shortcut < ApplicationRecord
extend FriendlyId
friendly_id :name, use: :slugged
validates :name, presence: true
validates :path, presence: true

belongs_to :subdomain
end
2 changes: 2 additions & 0 deletions app/models/subdomain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Subdomain < ApplicationRecord
has_one_attached :qr_code
has_rich_text :email_signature

has_many :shortcuts
accepts_nested_attributes_for :shortcuts

enum email_notification_strategy: { user_email: 'user_email', system_email: 'system_email' }

Expand Down
22 changes: 14 additions & 8 deletions app/views/comfy/admin/cms/partials/_navigation_inner.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@
%li.nav-item.dropdown
%a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"}
= "#{Subdomain.current.name.capitalize.truncate(12)} Shortcuts"
.dropdown-menu{"aria-labelledby" => "navbarDropdown"}
= link_to "Website", '/', class: 'dropdown-item', target: '_blank'
- if Subdomain.current.blog_enabled
= link_to "Blog", '/blog', class: 'dropdown-item', target: '_blank'
- if Subdomain.current.forum_enabled
= link_to "Forum", '/forum', class: 'dropdown-item', target: '_blank'
- if current_user.global_admin?
= link_to "Blazer BI", '/admin/blazer', class: 'dropdown-item', target: '_blank'

- if Subdomain.current.shortcuts.size > 0
.dropdown-menu{"aria-labelledby" => "navbarDropdown"}
- Subdomain.current.shortcuts.each do |shortcut|
= link_to shortcut.name, shortcut.path, class: 'dropdown-item', target: '_blank'
- else
.dropdown-menu{"aria-labelledby" => "navbarDropdown"}
= link_to "Website", '/', class: 'dropdown-item', target: '_blank'
- if Subdomain.current.blog_enabled
= link_to "Blog", '/blog', class: 'dropdown-item', target: '_blank'
- if Subdomain.current.forum_enabled
= link_to "Forum", '/forum', class: 'dropdown-item', target: '_blank'
- if current_user.global_admin?
= link_to "Blazer BI", '/admin/blazer', class: 'dropdown-item', target: '_blank'
= active_link_to "My Settings", edit_user_registration_path, class: 'nav-link'
= link_to "Logout", destroy_user_session_path, class: 'nav-link text-danger', method: :delete
18 changes: 18 additions & 0 deletions app/views/comfy/admin/web_settings/_form.haml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@
.d-block
= f.text_field :after_sign_up_path

.card.mt-5
.card-header
%strong
Custom shortcuts
.card-body
.form-group
%label
Define labels and paths (relative path, eg: foobuilder => /foo )
.d-block
- Subdomain.current.shortcuts.each do |shortcut|
= f.fields_for :shortcuts, shortcut do |shortcut_subform|
= shortcut_subform.text_field :name, placeholder: 'name'
= shortcut_subform.text_field :path, placeholder: 'path'
.d-block
= f.fields_for :shortcut, Subdomain.current.shortcuts.build do |shortcut_subform|
= shortcut_subform.text_field :name, placeholder: 'name'
= shortcut_subform.text_field :path, placeholder: 'path'

.card.mt-5
.card-header
%strong
Expand Down
12 changes: 12 additions & 0 deletions db/migrate/20251124220144_create_shortcuts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateShortcuts < ActiveRecord::Migration[6.1]
def change
create_table :shortcuts do |t|
t.string :path
t.string :name
t.string :slug
t.references :subdomain, null: false, foreign_key: true

t.timestamps
end
end
end
13 changes: 12 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions test/fixtures/shortcuts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
path: MyString
name: MyString
slug: MyString
subdomain: one

two:
path: MyString
name: MyString
slug: MyString
subdomain: two
7 changes: 7 additions & 0 deletions test/models/shortcut_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class ShortcutTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end