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

Config #29

Merged
merged 9 commits into from
Jul 26, 2023
Merged

Config #29

merged 9 commits into from
Jul 26, 2023

Conversation

kalashnikovisme
Copy link
Contributor

@kalashnikovisme kalashnikovisme commented Jul 23, 2023

What's changed basically?

  • Tramway Configuration DSL
  • Tramway entities
  • Rendering entities to Tramway Navbar

What's changed for tramway drivers?

Tramway Configuration DSL and Tramway entities

  • They able to use Tramway configuration in initializers of their applications

config/initializers/tramway.rb

Tramway.configure do |config|
  config.entities = [ :user, :podcast, :episode ] # entities will appear in Navigation bar by default. Later, entities will be used at other workflows
end

Rendering entities in a navigation bar

By default, entities will be rendered in a Navigation bar on the left.

tramway_navbar do |nav|
  nav.left do
    # something
  end
  nav.right do
    # something
  end
end

Find more info here

expect(fragment).to have_css "#{left_items_css} a[href='#{path}']", text: name
expect(fragment).to have_css "#{right_items_css} a[href='#{path}']", text: name
end
path = Rails.application.routes.url_helpers.users_path

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use let and move fragment and path from it

let(:fragment) { view.tramway_navbar }
let(:path) { Rails.application.routes.url_helpers.users_path }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! Thanks!

end

def routes
OpenStruct.new index: Rails.application.routes.url_helpers.public_send("#{name.pluralize}_path")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will not work with namespaced entities like "gpt/interaction"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! Thanks!

@kalashnikovisme kalashnikovisme merged commit 6d77163 into main Jul 26, 2023
2 checks passed
@kalashnikovisme kalashnikovisme deleted the config branch July 26, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants