8 |
9 |
--------------------------------------------------------------------------------
/lib/active_admin/orm/active_record/comments/namespace_helper.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Comments
3 |
4 | module NamespaceHelper
5 |
6 | # Returns true if the namespace allows comments
7 | def comments?
8 | comments == true
9 | end
10 |
11 | end
12 |
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/features/step_definitions/action_item_steps.rb:
--------------------------------------------------------------------------------
1 | Then /^I should see an action item link to "([^"]*)"$/ do |link|
2 | expect(page).to have_css('.action_item a', text: link)
3 | end
4 |
5 | Then /^I should not see an action item link to "([^"]*)"$/ do |link|
6 | expect(page).to_not have_css('.action_item a', text: link)
7 | end
8 |
--------------------------------------------------------------------------------
/features/step_definitions/tab_steps.rb:
--------------------------------------------------------------------------------
1 | Then /^the "([^"]*)" tab should be selected$/ do |name|
2 | step %{I should see "#{name}" within "ul#tabs li.current"}
3 | end
4 |
5 | Then(/^I should see two tabs "(.*?)" and "(.*?)"$/) do |tab_1, tab_2|
6 | expect(page).to have_link(tab_1)
7 | expect(page).to have_link(tab_2)
8 | end
9 |
--------------------------------------------------------------------------------
/lib/active_admin/view_helpers/sidebar_helper.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module ViewHelpers
3 | module SidebarHelper
4 |
5 | def skip_sidebar!
6 | @skip_sidebar = true
7 | end
8 |
9 | def skip_sidebar?
10 | @skip_sidebar == true
11 | end
12 |
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/features/step_definitions/member_link_steps.rb:
--------------------------------------------------------------------------------
1 | Then /^I should see an action item button "([^"]*)"$/ do |content|
2 | expect(page).to have_css '.action_items a', text: content
3 | end
4 |
5 | Then /^I should not see an action item button "([^"]*)"$/ do |content|
6 | expect(page).to_not have_css '.action_items', text: content
7 | end
8 |
--------------------------------------------------------------------------------
/gemfiles/rails_50.gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | eval_gemfile(File.expand_path(File.join("..", "Gemfile.common"), __dir__))
4 |
5 | gem "rails", "5.0.7"
6 | gem "devise", "~> 4.0"
7 | gem "draper", "~> 3.0"
8 | gem "activerecord-jdbcsqlite3-adapter", "~> 50.0", platforms: :jruby
9 |
10 | gemspec path: "../"
11 |
--------------------------------------------------------------------------------
/gemfiles/rails_51.gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | eval_gemfile(File.expand_path(File.join("..", "Gemfile.common"), __dir__))
4 |
5 | gem "rails", "5.1.6"
6 | gem "devise", "~> 4.3"
7 | gem "draper", "~> 3.0"
8 | gem "activerecord-jdbcsqlite3-adapter", "~> 51.0", platforms: :jruby
9 |
10 | gemspec path: "../"
11 |
--------------------------------------------------------------------------------
/lib/active_admin/views/components/sidebar.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Views
3 |
4 | class Sidebar < Component
5 | builder_method :sidebar
6 |
7 | def build(sections, attributes = {})
8 | super(attributes)
9 | sections.map(&method(:sidebar_section))
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/spec/unit/active_admin_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe ActiveAdmin do
4 | %w(register register_page unload! load! routes).each do |method|
5 | it "delegates ##{method} to application" do
6 | expect(ActiveAdmin.application).to receive(method)
7 |
8 | ActiveAdmin.send(method)
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/active_admin/components/_status_tags.scss:
--------------------------------------------------------------------------------
1 | .status_tag {
2 | background: darken($secondary-color, 15%);
3 | color: #fff;
4 | text-transform: uppercase;
5 | letter-spacing: 0.15em;
6 | padding: 3px 5px 2px 5px;
7 | font-size: 0.8em;
8 |
9 | &.yes { background: #6090DB }
10 | &.no { background: grey }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/lib/active_admin/inputs/filters/numeric_input.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Inputs
3 | module Filters
4 | class NumericInput < ::Formtastic::Inputs::NumberInput
5 | include Base
6 | include Base::SearchMethodSelect
7 |
8 | filter :equals, :greater_than, :less_than
9 | end
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/active_admin/view_helpers/active_admin_application_helper.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module ViewHelpers
3 | module ActiveAdminApplicationHelper
4 |
5 | # Returns the current Active Admin application instance
6 | def active_admin_application
7 | ActiveAdmin.application
8 | end
9 |
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/app/assets/javascripts/active_admin/ext/jquery.es6:
--------------------------------------------------------------------------------
1 | // `serializeArray` generates => [{ name: 'foo', value: 'bar' }]
2 | // This function remaps it to => { foo: 'bar' }
3 | $.fn.serializeObject = function() {
4 | return this.serializeArray()
5 | .reduce((obj, item) => {
6 | obj[item.name] = item.value
7 | return obj
8 | }, {});
9 | };
10 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/active_admin/components/_grid.scss:
--------------------------------------------------------------------------------
1 | // -------------------------------------- Index as Grid
2 | table.index_grid td { border: none; background: none; padding: 0 20px 20px 0; margin: 0;}
3 |
4 | // -------------------------------------- Columns
5 | .columns {
6 | clear: both;
7 | padding: 0;
8 | .column { float: left; }
9 | }
10 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | codecov:
4 | notify:
5 | require_ci_to_pass: true
6 |
7 | comment: off
8 |
9 | coverage:
10 | precision: 2
11 |
12 | range:
13 | - 70.0
14 | - 100.0
15 |
16 | round: down
17 |
18 | status:
19 | changes: false
20 |
21 | patch: true
22 |
23 | project:
24 | default:
25 | threshold: 1%
26 |
--------------------------------------------------------------------------------
/lib/active_admin/inputs/filters/date_picker_input.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Inputs
3 | module Filters
4 | class DatePickerInput < ::Formtastic::Inputs::DatePickerInput
5 | include Base
6 |
7 | def input_html_options
8 | super.merge(class: "datepicker")
9 | end
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/app/views/active_admin/devise/mailer/unlock_instructions.html.erb:
--------------------------------------------------------------------------------
1 |
Hello <%= @resource.email %>!
2 |
3 |
Your account has been locked due to an excessive amount of unsuccessful sign in attempts.
4 |
5 |
Click the link below to unlock your account:
6 |
7 |
<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @resource.unlock_token) %>
8 |
--------------------------------------------------------------------------------
/lib/active_admin/resource_controller/sidebars.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | class ResourceController < BaseController
3 |
4 | module Sidebars
5 |
6 | protected
7 |
8 | def skip_sidebar!
9 | @skip_sidebar = true
10 | end
11 |
12 | def skip_sidebar?
13 | @skip_sidebar == true
14 | end
15 | end
16 |
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/features/users/logging_out.feature:
--------------------------------------------------------------------------------
1 | Feature: User Logging out
2 |
3 | Logging out of the system as an admin user
4 |
5 | Scenario: Logging out successfully
6 | Given a configuration of:
7 | """
8 | ActiveAdmin.register Post
9 | """
10 | And I am logged in
11 | When I go to the dashboard
12 | And I follow "Logout"
13 | Then I should see "Login"
14 |
--------------------------------------------------------------------------------
/lib/generators/active_admin/page/page_generator.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Generators
3 | class PageGenerator < Rails::Generators::NamedBase
4 | source_root File.expand_path('../templates', __FILE__)
5 |
6 | def generate_config_file
7 | template "page.rb", "app/admin/#{file_path.tr('/', '_')}.rb"
8 | end
9 |
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/active_admin/view_helpers/scope_name_helper.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module ViewHelpers
3 | module ScopeNameHelper
4 |
5 | def scope_name(scope)
6 | case scope.name
7 | when Proc then
8 | self.instance_exec(&scope.name).to_s
9 | else
10 | scope.name.to_s
11 | end
12 | end
13 |
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/active_admin/mixins/_all.scss:
--------------------------------------------------------------------------------
1 | @import "active_admin/mixins/variables";
2 | @import "active_admin/mixins/gradients";
3 | @import "active_admin/mixins/shadows";
4 | @import "active_admin/mixins/rounded";
5 | @import "active_admin/mixins/buttons";
6 | @import "active_admin/mixins/sections";
7 | @import "active_admin/mixins/utilities";
8 | @import "active_admin/mixins/typography";
9 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/active_admin/structure/_footer.scss:
--------------------------------------------------------------------------------
1 | #footer {
2 | padding: 30px 30px;
3 | font-size: 0.8em;
4 | clear: both;
5 |
6 | p {
7 | padding-top: 10px
8 | }
9 | }
10 |
11 | // -------------------------------------- Index Footer (Under Table)
12 | #index_footer { padding-top: 5px; text-align: right; font-size: 0.85em; }
13 |
14 | .index_content { clear: both; }
15 |
--------------------------------------------------------------------------------
/lib/active_admin/helpers/routes/url_helpers.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Helpers
3 | module Routes
4 | module UrlHelpers
5 | include Rails.application.routes.url_helpers
6 | end
7 |
8 | extend UrlHelpers
9 |
10 | def self.default_url_options
11 | Rails.application.routes.default_url_options || {}
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/support/templates/policies/active_admin/page_policy.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | class PagePolicy < ApplicationPolicy
3 | class Scope < Scope
4 | def resolve
5 | scope
6 | end
7 | end
8 |
9 | def show?
10 | case record.name
11 | when "Dashboard"
12 | true
13 | else
14 | false
15 | end
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/active_admin/components/_unsupported_browser.scss:
--------------------------------------------------------------------------------
1 | .unsupported_browser {
2 | padding: 10px 30px;
3 | color: #211e14;
4 | background-color: #fae692;
5 | @include gradient(#feefae, #fae692);
6 | border-bottom: 1px solid #b3a569;
7 |
8 | h1 {
9 | font-size: 13px;
10 | font-weight: bold;
11 | }
12 |
13 | p {
14 | margin-bottom: 0.5em;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require 'simplecov' if ENV["COVERAGE"] == "true"
2 |
3 | RSpec.configure do |config|
4 | config.disable_monkey_patching!
5 | config.filter_run focus: true
6 | config.filter_run_excluding skip: true
7 | config.run_all_when_everything_filtered = true
8 | config.color = true
9 | config.order = :random
10 | config.example_status_persistence_file_path = ".rspec_failures"
11 | end
12 |
--------------------------------------------------------------------------------
/vendor/assets/javascripts/jquery-ui/version.js:
--------------------------------------------------------------------------------
1 | ( function( factory ) {
2 | if ( typeof define === "function" && define.amd ) {
3 |
4 | // AMD. Register as an anonymous module.
5 | define( [ "jquery" ], factory );
6 | } else {
7 |
8 | // Browser globals
9 | factory( jQuery );
10 | }
11 | } ( function( $ ) {
12 |
13 | $.ui = $.ui || {};
14 |
15 | return $.ui.version = "1.12.1";
16 |
17 | } ) );
18 |
--------------------------------------------------------------------------------
/app/views/kaminari/active_admin/_gap.html.erb:
--------------------------------------------------------------------------------
1 | <%# Non-link tag that stands for skipped pages...
2 | - available local variables
3 | current_page: a page object for the currently displayed page
4 | total_pages: total number of pages
5 | per_page: number of items to fetch per page
6 | remote: data-remote
7 | -%>
8 | <%= t('views.pagination.truncate').html_safe %>
9 |
--------------------------------------------------------------------------------
/lib/active_admin/orm/active_record/comments/resource_helper.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Comments
3 |
4 | module ResourceHelper
5 | extend ActiveSupport::Concern
6 |
7 | included do
8 | attr_accessor :comments
9 | end
10 |
11 | def comments?
12 | (namespace.comments? && comments != false) || comments == true
13 | end
14 | end
15 |
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/active_admin/views/action_items.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Views
3 |
4 | class ActionItems < ActiveAdmin::Component
5 |
6 | def build(action_items)
7 | action_items.each do |action_item|
8 | span class: action_item.html_class do
9 | instance_exec(&action_item.block)
10 | end
11 | end
12 | end
13 |
14 | end
15 |
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/app/assets/javascripts/active_admin/ext/jquery-ui.es6:
--------------------------------------------------------------------------------
1 | // Short-circuits `_focusTabbable` to focus on the modal itself instead of
2 | // elements inside the modal. Without this, if a datepicker is the first input,
3 | // it'll immediately pop up when the modal opens.
4 | // See this ticket for more info: http://bugs.jqueryui.com/ticket/4731
5 | $.ui.dialog.prototype._focusTabbable = function() {
6 | this.uiDialog.focus();
7 | };
8 |
--------------------------------------------------------------------------------
/spec/javascripts/fixtures/checkboxes.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/features/step_definitions/breadcrumb_steps.rb:
--------------------------------------------------------------------------------
1 | Around '@breadcrumb' do |scenario, block|
2 | previous_breadcrumb = ActiveAdmin.application.breadcrumb
3 |
4 | begin
5 | block.call
6 | ensure
7 | ActiveAdmin.application.breadcrumb = previous_breadcrumb
8 | end
9 | end
10 |
11 | Then /^I should see a link to "([^"]*)" in the breadcrumb$/ do |text|
12 | expect(page).to have_css '.breadcrumb > a', text: text
13 | end
14 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/active_admin/mixins/_utilities.scss:
--------------------------------------------------------------------------------
1 | @mixin clearfix {
2 | &:after {
3 | visibility: hidden;
4 | display: block;
5 | content: "";
6 | clear: both;
7 | height: 0;
8 | }
9 | }
10 |
11 | @mixin border-colors($top, $sides, $bottom) {
12 | border-color: $sides;
13 | border-top-color: $top;
14 | border-right-color: $sides;
15 | border-bottom-color: $bottom;
16 | border-left-color: $sides;
17 | }
18 |
--------------------------------------------------------------------------------
/features/step_definitions/attributes_table_title_steps.rb:
--------------------------------------------------------------------------------
1 | Then /^I should see the panel title "([^"]*)"$/ do |title|
2 | expect(page).to have_css '.panel > h3', text: title
3 | end
4 |
5 | Then /^I should not see the panel title "([^"]*)"$/ do |title|
6 | expect(page).to_not have_css '.panel > h3', text: title
7 | end
8 |
9 | Then /^I should see the attributes table$/ do
10 | expect(page).to have_css '.panel .attributes_table'
11 | end
12 |
--------------------------------------------------------------------------------
/lib/active_admin/views/components/blank_slate.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Views
3 | # Build a Blank Slate
4 | class BlankSlate < ActiveAdmin::Component
5 | builder_method :blank_slate
6 |
7 | def default_class_name
8 | 'blank_slate_container'
9 | end
10 |
11 | def build(content)
12 | super(span(content.html_safe, class: "blank_slate"))
13 | end
14 |
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/features/step_definitions/flash_steps.rb:
--------------------------------------------------------------------------------
1 | Then /^I should see a flash with "([^"]*)"$/ do |text|
2 | expect(page).to have_content text
3 | end
4 |
5 | Then /^I should see a successful create flash$/ do
6 | expect(page).to have_css 'div.flash_notice', text: /was successfully created/
7 | end
8 |
9 | Then /^I should not see a successful create flash$/ do
10 | expect(page).to_not have_css 'div.flash_notice', text: /was successfully created/
11 | end
12 |
--------------------------------------------------------------------------------
/spec/unit/resource/menu_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | module ActiveAdmin
4 | RSpec.describe Resource, "Menu" do
5 |
6 | before { load_defaults! }
7 |
8 | let(:application){ ActiveAdmin::Application.new }
9 | let(:namespace){ Namespace.new(application, :admin) }
10 |
11 | def config(options = {})
12 | @config ||= Resource.new(namespace, Category, options)
13 | end
14 |
15 | # TODO...
16 |
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/cucumber.yml:
--------------------------------------------------------------------------------
1 | <%
2 | std_opts = "--format progress --order random"
3 | default_opts = std_opts + " --format ParallelTests::Gherkin::RuntimeLogger --out tmp/parallel_runtime_cucumber.log"
4 | %>
5 |
6 | default: <%= default_opts %> --require features/support/regular_env.rb features --tags 'not @requires-reloading' --tags 'not @wip'
7 | class-reloading: CLASS_RELOADING=true <%= std_opts %> --require features/support/reload_env.rb features --tags @requires-reloading
8 |
--------------------------------------------------------------------------------
/features/step_definitions/menu_steps.rb:
--------------------------------------------------------------------------------
1 | Then /^I should see a menu item for "([^"]*)"$/ do |name|
2 | expect(page).to have_css '#tabs > li > a', text: name
3 | end
4 |
5 | Then /^I should not see a menu item for "([^"]*)"$/ do |name|
6 | expect(page).to_not have_css '#tabs > li > a', text: name
7 | end
8 |
9 | Then /^I should see a nested menu item for "([^"]*)"$/ do |name|
10 | expect(page).to have_css '#tabs > li > ul > li > a', text: name
11 | end
12 |
--------------------------------------------------------------------------------
/spec/unit/views/pages/base_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe ActiveAdmin::Views::Pages::Base do
4 | class NewPage < ActiveAdmin::Views::Pages::Base
5 | end
6 |
7 | it "defines a default title" do
8 | expect(NewPage.new.title).to eq 'NewPage'
9 | end
10 |
11 | it "defines default main content" do
12 | expect(NewPage.new.main_content).to eq 'Please implement NewPage#main_content to display content.'
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/bin/install_chromedriver.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -euo pipefail
4 |
5 | curl --silent \
6 | --show-error \
7 | --location \
8 | --fail \
9 | --retry 3 \
10 | --output /tmp/chromedriver_linux64.zip \
11 | https://chromedriver.storage.googleapis.com/2.38/chromedriver_linux64.zip
12 |
13 | unzip /tmp/chromedriver_linux64.zip chromedriver -d ~/.local/bin
14 |
15 | rm /tmp/chromedriver_linux64.zip
16 |
17 | chromedriver --version
18 |
--------------------------------------------------------------------------------
/features/step_definitions/i18n_steps.rb:
--------------------------------------------------------------------------------
1 | Given /^String "([^"]*)" corresponds to "([^"]*)"$/ do |translation, key|
2 | *seq, last_key = key.split('.')
3 | result = seq.reverse.inject({last_key.to_sym => translation}) do |temp_result, nested_key|
4 | {nested_key.to_sym => temp_result}
5 | end
6 | I18n.backend.store_translations :en, active_admin: result
7 | end
8 |
9 | When /^I set my locale to "([^"]*)"$/ do |lang|
10 | I18n.locale = lang
11 | end
12 |
--------------------------------------------------------------------------------
/lib/active_admin/views/components/unsupported_browser.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Views
3 | class UnsupportedBrowser < Component
4 | def build
5 | h1 I18n.t("active_admin.unsupported_browser.headline").html_safe
6 | para I18n.t("active_admin.unsupported_browser.recommendation").html_safe
7 | para I18n.t("active_admin.unsupported_browser.turn_off_compatibility_view").html_safe
8 | end
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/active_admin/mixins/_shadows.scss:
--------------------------------------------------------------------------------
1 | @mixin shadow($x: 0, $y: 1px, $blur: 2px, $color: rgba(0,0,0,0.37)) {
2 | box-shadow: $x $y $blur $color;
3 | }
4 |
5 | @mixin no-shadow {
6 | box-shadow: none;
7 | }
8 |
9 | @mixin inset-shadow($x: 0, $y: 1px, $blur: 2px, $color: #aaa) {
10 | box-shadow: inset $x $y $blur $color;
11 | }
12 |
13 | @mixin text-shadow($color: #fff, $x: 0, $y: 1px, $blur: 0) {
14 | text-shadow: $color $x $y $blur;
15 | }
16 |
--------------------------------------------------------------------------------
/lib/generators/active_admin/assets/assets_generator.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Generators
3 | class AssetsGenerator < Rails::Generators::Base
4 |
5 | source_root File.expand_path("../templates", __FILE__)
6 |
7 | def install_assets
8 | template 'active_admin.js', 'app/assets/javascripts/active_admin.js'
9 | template "active_admin.scss", "app/assets/stylesheets/active_admin.scss"
10 | end
11 |
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/vendor/assets/javascripts/jquery-ui/ie.js:
--------------------------------------------------------------------------------
1 | //= require jquery-ui/version
2 |
3 | ( function( factory ) {
4 | if ( typeof define === "function" && define.amd ) {
5 |
6 | // AMD. Register as an anonymous module.
7 | define( [ "jquery", "./version" ], factory );
8 | } else {
9 |
10 | // Browser globals
11 | factory( jQuery );
12 | }
13 | } ( function( $ ) {
14 |
15 | // This file is deprecated
16 | return $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
17 | } ) );
18 |
--------------------------------------------------------------------------------
/app/views/active_admin/devise/mailer/reset_password_instructions.html.erb:
--------------------------------------------------------------------------------
1 |
Hello <%= @resource.email %>!
2 |
3 |
Someone has requested a link to change your password, and you can do this through the link below.
4 |
5 |
<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @resource.reset_password_token) %>
6 |
7 |
If you didn't request this, please ignore this email.
8 |
Your password won't change until you access the link above and create a new one.
9 |
--------------------------------------------------------------------------------
/app/views/kaminari/active_admin/_last_page.html.erb:
--------------------------------------------------------------------------------
1 | <%# Link to the "Last" page
2 | - available local variables
3 | url: url to the last page
4 | current_page: a page object for the currently displayed page
5 | total_pages: total number of pages
6 | per_page: number of items to fetch per page
7 | remote: data-remote
8 | -%>
9 |
10 | <%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, remote: remote %>
11 |
12 |
--------------------------------------------------------------------------------
/app/views/kaminari/active_admin/_first_page.html.erb:
--------------------------------------------------------------------------------
1 | <%# Link to the "First" page
2 | - available local variables
3 | url: url to the first page
4 | current_page: a page object for the currently displayed page
5 | total_pages: total number of pages
6 | per_page: number of items to fetch per page
7 | remote: data-remote
8 | -%>
9 |
10 | <%= link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, remote: remote %>
11 |
12 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss:
--------------------------------------------------------------------------------
1 | .breadcrumb {
2 | display: block;
3 | font-size: 0.9em;
4 | font-weight: normal;
5 | line-height: 1.0em;
6 | margin-bottom: 12px;
7 | text-transform: uppercase;
8 |
9 | a, a:link, a:visited, a:active {
10 | color: $breadcrumbs-color;
11 | text-decoration: none;
12 | }
13 |
14 | a:hover { text-decoration: underline; }
15 |
16 | .breadcrumb_sep {
17 | margin: 0 2px;
18 | color: $breadcrumbs-separator-color;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/views/kaminari/active_admin/_next_page.html.erb:
--------------------------------------------------------------------------------
1 | <%# Link to the "Next" page
2 | - available local variables
3 | url: url to the next page
4 | current_page: a page object for the currently displayed page
5 | total_pages: total number of pages
6 | per_page: number of items to fetch per page
7 | remote: data-remote
8 | -%>
9 |
10 | <%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, rel: 'next', remote: remote %>
11 |
12 |
--------------------------------------------------------------------------------
/spec/requests/stylesheets_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe "Stylesheets", type: :request do
4 |
5 | require "sprockets"
6 |
7 | let(:css) do
8 | assets = Rails.application.assets
9 | assets.find_asset("active_admin.css")
10 | end
11 | it "should successfully render the scss stylesheets using sprockets" do
12 | expect(css).to_not eq nil
13 | end
14 | it "should not have any syntax errors" do
15 | expect(css.to_s).to_not include("Syntax error:")
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/features/step_definitions/pagination_steps.rb:
--------------------------------------------------------------------------------
1 | Then /^I should not see pagination$/ do
2 | expect(page).to_not have_css '.pagination'
3 | end
4 |
5 | Then /^I should see pagination with (\d+) pages$/ do |count|
6 | expect(page).to have_css '.pagination span.page', count: count
7 | end
8 |
9 | Then /^I should see the pagination "Next" link/ do
10 | expect(page).to have_css "a", text: "Next"
11 | end
12 |
13 | Then /^I should not see the pagination "Next" link/ do
14 | expect(page).to_not have_css "a", text: "Next"
15 | end
16 |
--------------------------------------------------------------------------------
/spec/javascripts/support/jasmine_runner.rb:
--------------------------------------------------------------------------------
1 | $:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
2 |
3 | require 'jasmine'
4 | require 'spec'
5 |
6 | jasmine_config = Jasmine::Config.new
7 | spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
8 |
9 | should_stop = false
10 |
11 | Spec::Runner.configure do |config|
12 | config.after(:suite) do
13 | spec_builder.stop if should_stop
14 | end
15 | end
16 |
17 | spec_builder.start
18 | should_stop = true
19 | spec_builder.declare_suites
20 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'bundler/gem_tasks'
2 |
3 | # Import all our rake tasks
4 | FileList['tasks/**/*.rake'].each { |task| import task }
5 |
6 | task default: :test
7 |
8 | begin
9 | require 'jasmine'
10 | load 'jasmine/tasks/jasmine.rake'
11 | rescue LoadError
12 | task :jasmine do
13 | abort 'Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine'
14 | end
15 | end
16 |
17 | task :console do
18 | require 'irb'
19 | require 'irb/completion'
20 |
21 | ARGV.clear
22 | IRB.start
23 | end
24 |
--------------------------------------------------------------------------------
/app/assets/javascripts/active_admin/initializers/datepicker.es6:
--------------------------------------------------------------------------------
1 | (($) => {
2 |
3 | $(document)
4 | .on('focus', 'input.datepicker:not(.hasDatepicker)', function() {
5 | const input = $(this);
6 |
7 | // Only create datepickers in compatible browsers
8 | if (input[0].type === 'date') { return; }
9 |
10 | const defaults = { dateFormat: 'yy-mm-dd' };
11 | const options = input.data('datepicker-options');
12 |
13 | input.datepicker($.extend(defaults, options));
14 | });
15 |
16 | })(jQuery);
17 |
--------------------------------------------------------------------------------
/app/views/kaminari/active_admin/_prev_page.html.erb:
--------------------------------------------------------------------------------
1 | <%# Link to the "Previous" page
2 | - available local variables
3 | url: url to the previous page
4 | current_page: a page object for the currently displayed page
5 | total_pages: total number of pages
6 | per_page: number of items to fetch per page
7 | remote: data-remote
8 | -%>
9 |
10 | <%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, rel: 'prev', remote: remote %>
11 |
12 |
--------------------------------------------------------------------------------
/docs/3-index-pages/index-as-block.md:
--------------------------------------------------------------------------------
1 | ---
2 | redirect_from: /docs/3-index-pages/index-as-block.html
3 | ---
4 |
5 | # Index as a Block
6 |
7 | If you want to fully customize the display of your resources on the index
8 | screen, Index as a Block allows you to render a block of content for each
9 | resource.
10 |
11 | ```ruby
12 | index as: :block do |product|
13 | div for: product do
14 | resource_selection_cell product
15 | h2 auto_link product.title
16 | div simple_format product.description
17 | end
18 | end
19 | ```
20 |
--------------------------------------------------------------------------------
/lib/active_admin/settings_node.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 |
3 | class SettingsNode
4 | class << self
5 | # Never instantiated. Variables are stored in the singleton_class.
6 | private_class_method :new
7 |
8 | # @return anonymous class with same accessors as the superclass.
9 | def build(superclass = self)
10 | Class.new(superclass)
11 | end
12 |
13 | def register(name, value)
14 | class_attribute name
15 | send "#{name}=", value
16 | end
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/unit/component_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | class MockComponentClass < ActiveAdmin::Component; end
4 |
5 | RSpec.describe ActiveAdmin::Component do
6 |
7 | let(:component_class){ MockComponentClass }
8 | let(:component){ component_class.new }
9 |
10 | it "should be a subclass of an html div" do
11 | expect(ActiveAdmin::Component.ancestors).to include(Arbre::HTML::Div)
12 | end
13 |
14 | it "should render to a div, even as a subclass" do
15 | expect(component.tag_name).to eq 'div'
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/lib/active_admin/inputs.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Inputs
3 | extend ActiveSupport::Autoload
4 |
5 | autoload :DatepickerInput
6 |
7 | module Filters
8 | extend ActiveSupport::Autoload
9 |
10 | autoload :Base
11 | autoload :StringInput
12 | autoload :TextInput
13 | autoload :DatePickerInput
14 | autoload :DateRangeInput
15 | autoload :NumericInput
16 | autoload :SelectInput
17 | autoload :CheckBoxesInput
18 | autoload :BooleanInput
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/features/dashboard.feature:
--------------------------------------------------------------------------------
1 | Feature: Dashboard
2 |
3 | Scenario: With default configuration
4 | Given a configuration of:
5 | """
6 | ActiveAdmin.register_page "Dashboard" do
7 | content do
8 | para "Hello world from the dashboard page"
9 | end
10 | end
11 | """
12 | Given I am logged in
13 | When I go to the dashboard
14 | Then I should see the Active Admin layout
15 | And I should not see the default welcome message
16 | And I should see "Hello world from the dashboard page"
17 |
--------------------------------------------------------------------------------
/lib/active_admin/view_helpers/flash_helper.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module ViewHelpers
3 | module FlashHelper
4 |
5 | # Returns all the flash keys to display in any Active Admin view.
6 | # This method removes the :timedout key that Devise uses by default.
7 | # Note Rails >= 4.1 normalizes keys to strings automatically.
8 | def flash_messages
9 | @flash_messages ||= flash.to_hash.with_indifferent_access.except(*active_admin_application.flash_keys_to_except)
10 | end
11 |
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/docs/_includes/head.html:
--------------------------------------------------------------------------------
1 |
2 | Active Admin | The administration framework for Ruby on Rails
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lib/active_admin/views/header.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Views
3 | class Header < Component
4 |
5 | def build(namespace, menu)
6 | super(id: "header")
7 |
8 | @namespace = namespace
9 | @menu = menu
10 | @utility_menu = @namespace.fetch_menu(:utility_navigation)
11 |
12 | site_title @namespace
13 | global_navigation @menu, class: 'header-item tabs'
14 | utility_navigation @utility_menu, id: "utility_nav", class: 'header-item tabs'
15 | end
16 |
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/features/index/index_as_block.feature:
--------------------------------------------------------------------------------
1 | Feature: Index as Block
2 |
3 | Viewing the resource as a block which is renderered by the user
4 |
5 | Scenario: Viewing the index as a block
6 | Given a post with the title "Hello World from Block" exists
7 | And an index configuration of:
8 | """
9 | ActiveAdmin.register Post do
10 | index as: :block do |post|
11 | span(link_to(post.title, admin_post_path(post)))
12 | end
13 | end
14 | """
15 | Then I should see "Hello World from Block" within ".index_as_block"
16 |
--------------------------------------------------------------------------------
/app/views/kaminari/active_admin/_page.html.erb:
--------------------------------------------------------------------------------
1 | <%# Link showing page number
2 | - available local variables
3 | page: a page object for "this" page
4 | url: url to this page
5 | current_page: a page object for the currently displayed page
6 | total_pages: total number of pages
7 | per_page: number of items to fetch per page
8 | remote: data-remote
9 | -%>
10 |
11 | <%= link_to_unless page.current?, page, url, {remote: remote, rel: page.rel} %>
12 |
13 |
--------------------------------------------------------------------------------
/features/step_definitions/sidebar_steps.rb:
--------------------------------------------------------------------------------
1 | Then /^I should see a sidebar titled "([^"]*)"$/ do |title|
2 | expect(page).to have_css '.sidebar_section h3', text: title
3 | end
4 |
5 | Then /^I should not see a sidebar titled "([^"]*)"$/ do |title|
6 | expect(page).not_to have_css '.sidebar_section h3', text: title
7 | end
8 |
9 | Then(/^I should see a sidebar titled "(.*?)" above sidebar titled "(.*?)"$/) do |top_title, bottom_title|
10 | expect(page).to have_css %Q(.sidebar_section:contains('#{top_title}') + .sidebar_section:contains('#{bottom_title}'))
11 | end
12 |
--------------------------------------------------------------------------------
/lib/active_admin/filters.rb:
--------------------------------------------------------------------------------
1 | require 'active_admin/filters/dsl'
2 | require 'active_admin/filters/resource_extension'
3 | require 'active_admin/filters/formtastic_addons'
4 | require 'active_admin/filters/forms'
5 | require 'active_admin/helpers/optional_display'
6 | require 'active_admin/filters/active_sidebar'
7 |
8 | # Add our Extensions
9 | ActiveAdmin::ResourceDSL.send :include, ActiveAdmin::Filters::DSL
10 | ActiveAdmin::Resource.send :include, ActiveAdmin::Filters::ResourceExtension
11 | ActiveAdmin::ViewHelpers.send :include, ActiveAdmin::Filters::ViewHelper
12 |
--------------------------------------------------------------------------------
/features/root_to.feature:
--------------------------------------------------------------------------------
1 | @root
2 | Feature: Namespace root
3 |
4 | As a developer
5 | In order to customize the welcome page
6 | I want to set it in the configuration
7 |
8 | Scenario: Default root is the Dashboard
9 | Given I am logged in with capybara
10 | Then I should be on the dashboard
11 |
12 | Scenario: Set root to "stores#index"
13 | Given a configuration of:
14 | """
15 | ActiveAdmin.application.root_to = 'stores#index'
16 | """
17 | Given I am logged in with capybara
18 | Then I should see the page title "Bookstores"
19 |
--------------------------------------------------------------------------------
/features/favicon.feature:
--------------------------------------------------------------------------------
1 | Feature: Favicon
2 |
3 | Configuring a Favicon file
4 |
5 | Background:
6 | Given a configuration of:
7 | """
8 | ActiveAdmin.register Post
9 | ActiveAdmin.application.favicon = "a/favicon.ico"
10 | """
11 |
12 | Scenario: Logged out views show Favicon
13 | Given I am logged out
14 | When I am on the login page
15 | Then I should see the favicon "favicon"
16 |
17 | Scenario: Logged in views show Favicon
18 | Given I am logged in
19 | When I am on the dashboard
20 | Then I should see the favicon "favicon"
--------------------------------------------------------------------------------
/features/first_boot.feature:
--------------------------------------------------------------------------------
1 | Feature: First Boot
2 |
3 | As a developer
4 | In order to ensure I have a great first experience
5 | I want Active Admin to just work on install
6 |
7 | Scenario: Visiting /admin and logging in with no configurations
8 | Given a configuration of:
9 | """
10 | """
11 | And an admin user "admin@example.com" exists
12 | When I go to the dashboard
13 | When I fill in "Email" with "admin@example.com"
14 | And I fill in "Password" with "password"
15 | And I press "Login"
16 | Then I should be on the the dashboard
17 |
--------------------------------------------------------------------------------
/config/i18n-tasks.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | # The "main" locale
4 | base_locale: en
5 |
6 | # Read and write translations
7 | data:
8 | yaml:
9 | write:
10 | # Do not wrap lines at 80 characters
11 | line_width: -1
12 |
13 | # Find translate calls
14 | search:
15 | # Paths or `File.find` patterns to search in
16 | paths:
17 | - app
18 | - lib
19 |
20 | # Files or `File.fnmatch` patterns to exclude from search
21 | exclude:
22 | - app/assets/images
23 | - lib/bug_report_templates/tmp
24 |
25 | # Guess usages such as t("categories.#{category}.title")
26 | strict: false
27 |
--------------------------------------------------------------------------------
/docs/_layouts/default.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | {% include head.html %}
4 |
5 |
6 | {% include top-menu.html %}
7 |
8 |
9 | {% include toc.html %}
10 |
11 |
12 |
13 | {{ content }}
14 |
15 |
16 |
17 | {% include footer.html %}
18 |
19 | {% include google-analytics.html %}
20 |
21 |
22 |
--------------------------------------------------------------------------------
/lib/active_admin/helpers/collection.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Helpers
3 | module Collection
4 | # 1. removes `select` and `order` to prevent invalid SQL
5 | # 2. correctly handles the Hash returned when `group by` is used
6 | def collection_size(c = collection)
7 | return c.count if c.is_a?(Array)
8 |
9 | c = c.except :select, :order
10 |
11 | c.group_values.present? ? c.count.count : c.count
12 | end
13 |
14 | def collection_is_empty?(c = collection)
15 | collection_size(c) == 0
16 | end
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/lib/active_admin/resource/controllers.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | class Resource
3 | module Controllers
4 | delegate :resources_configuration, to: :controller
5 |
6 | # Returns a properly formatted controller name for this
7 | # config within its namespace
8 | def controller_name
9 | [namespace.module_name, resource_name.plural.camelize + "Controller"].compact.join('::')
10 | end
11 |
12 | # Returns the controller for this config
13 | def controller
14 | @controller ||= controller_name.constantize
15 | end
16 |
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/lib/active_admin/view_helpers.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module ViewHelpers
3 |
4 | # Require all ruby files in the view helpers dir
5 | Dir[File.expand_path('../view_helpers', __FILE__) + "/*.rb"].each{|f| require f }
6 |
7 | include ActiveAdminApplicationHelper
8 | include AutoLinkHelper
9 | include BreadcrumbHelper
10 | include DisplayHelper
11 | include MethodOrProcHelper
12 | include SidebarHelper
13 | include FormHelper
14 | include TitleHelper
15 | include ViewFactoryHelper
16 | include FlashHelper
17 | include ScopeNameHelper
18 |
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb.erb:
--------------------------------------------------------------------------------
1 | class CreateActiveAdminComments < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version.to_s %>]
2 | def self.up
3 | create_table :active_admin_comments do |t|
4 | t.string :namespace
5 | t.text :body
6 | t.references :resource, polymorphic: true
7 | t.references :author, polymorphic: true
8 | t.timestamps
9 | end
10 | add_index :active_admin_comments, [:namespace]
11 | end
12 |
13 | def self.down
14 | drop_table :active_admin_comments
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/unit/filters/active_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe ActiveAdmin::Filters::Active do
4 |
5 | let(:resource) do
6 | namespace = ActiveAdmin::Namespace.new(ActiveAdmin::Application.new, :admin)
7 | namespace.register(Post)
8 | end
9 |
10 | subject { described_class.new(resource, search) }
11 |
12 | let(:params) do
13 | ::ActionController::Parameters.new(q: {author_id_eq: 1})
14 | end
15 |
16 | let(:search) do
17 | Post.ransack(params[:q])
18 | end
19 |
20 | it 'should have filters' do
21 | expect(subject.filters.size).to eq(1)
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/docs/_includes/google-analytics.html:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/features/step_definitions/dashboard_steps.rb:
--------------------------------------------------------------------------------
1 | Then /^I should see the default welcome message$/ do
2 | step %{I should see "Welcome to Active Admin" within "#dashboard_default_message"}
3 | end
4 |
5 | Then /^I should not see the default welcome message$/ do
6 | step %{I should not see "Welcome to Active Admin"}
7 | end
8 |
9 | Then /^I should see a dashboard widget "([^"]*)"$/ do |name|
10 | expect(page).to have_css '.dashboard .panel h3', text: name
11 | end
12 |
13 | Then /^I should not see a dashboard widget "([^"]*)"$/ do |name|
14 | expect(page).to_not have_css '.dashboard .panel h3', text: name
15 | end
16 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/active_admin/structure/_main_structure.scss:
--------------------------------------------------------------------------------
1 | #wrapper {
2 | width: 100%;
3 | }
4 |
5 | .index #wrapper {
6 | display: table;
7 | }
8 |
9 | #active_admin_content {
10 | margin: 0;
11 | padding: $horizontal-page-margin;
12 |
13 | #main_content_wrapper {
14 | float: left;
15 | width: 100%;
16 |
17 | #main_content{
18 | margin-right: 300px;
19 | }
20 | }
21 |
22 | &.without_sidebar #main_content_wrapper #main_content{ margin-right: 0; }
23 |
24 | #sidebar {
25 | float: left;
26 | width: $sidebar-width;
27 | margin-left: -$sidebar-width;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Mac
2 | .DS_Store
3 |
4 | ## Windows
5 | .Thumbs.db
6 |
7 | ## TextMate
8 | *.tm_project
9 | *.tmproj
10 | tmtags
11 |
12 | ## Emacs
13 | *~
14 | \#*
15 | .\#*
16 |
17 | ## Vim
18 | *.swp
19 | # IDEA / RUBYMINE
20 | .idea
21 |
22 | ## RVM
23 | .rvmrc
24 | .ruby-version
25 | .ruby-gemset
26 |
27 | ## Project (general)
28 | tags
29 | tmp
30 | coverage
31 | rdoc
32 | doc
33 | .yardoc
34 | pkg
35 |
36 | ## Project (specific)
37 | .bundle
38 | spec/rails
39 | *.sqlite3-journal
40 | .test-rails-apps
41 | public
42 | .rspec_failures
43 | .rails-version
44 | .rbenv-version
45 | .localeapp/*
46 | lib/bug_report_templates/tmp
47 |
--------------------------------------------------------------------------------
/spec/javascripts/fixtures/table_checkboxes.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/spec/unit/authorization/index_overriding_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe 'Index overriding', type: :controller do
4 | before do
5 | load_resources { ActiveAdmin.register Post }
6 | @controller = Admin::PostsController.new
7 |
8 | @controller.instance_eval do
9 | def index
10 | super do
11 | render body: 'Rendered from passed block'
12 | return
13 | end
14 | end
15 | end
16 | end
17 |
18 | it 'should call block passed to overridden index' do
19 | get :index
20 | expect(response.body).to eq 'Rendered from passed block'
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/lib/active_admin/resource/pagination.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 |
3 | class Resource
4 | module Pagination
5 |
6 | # The default number of records to display per page
7 | attr_accessor :per_page
8 |
9 | # The default number of records to display per page
10 | attr_accessor :max_per_page
11 |
12 | # Enable / disable pagination (defaults to true)
13 | attr_accessor :paginate
14 |
15 | def initialize(*args)
16 | super
17 | @paginate = true
18 | @per_page = namespace.default_per_page
19 | @max_per_page = namespace.max_per_page
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/spec/unit/views/components/sidebar_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe ActiveAdmin::Views::Sidebar do
4 |
5 | let(:section) do
6 | ActiveAdmin::SidebarSection.new("Section") do
7 | para 'Section content.'
8 | end
9 | end
10 |
11 | let(:html) do
12 | render_arbre_component sections: [section] do
13 | sidebar assigns[:sections], id: 'sidebar'
14 | end
15 | end
16 |
17 | it "should have an id of 'sidebar'" do
18 | expect(html.id).to eq 'sidebar'
19 | end
20 |
21 | it "renders the section" do
22 | expect(html.find_by_tag('p').first.content).to eq 'Section content.'
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/vendor/assets/javascripts/jquery-ui/escape-selector.js:
--------------------------------------------------------------------------------
1 | //= require jquery-ui/version
2 |
3 | ( function( factory ) {
4 | if ( typeof define === "function" && define.amd ) {
5 |
6 | // AMD. Register as an anonymous module.
7 | define( [ "jquery", "./version" ], factory );
8 | } else {
9 |
10 | // Browser globals
11 | factory( jQuery );
12 | }
13 | } ( function( $ ) {
14 |
15 | // Internal use only
16 | return $.ui.escapeSelector = ( function() {
17 | var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
18 | return function( selector ) {
19 | return selector.replace( selectorEscape, "\\$1" );
20 | };
21 | } )();
22 |
23 | } ) );
24 |
--------------------------------------------------------------------------------
/spec/support/templates/post_decorator.rb:
--------------------------------------------------------------------------------
1 | require 'draper'
2 |
3 | class PostDecorator < Draper::Decorator
4 | decorates :post
5 | delegate_all
6 |
7 | # @param attributes [Hash]
8 | def assign_attributes(attributes)
9 | object.assign_attributes attributes.except(:virtual_title)
10 | self.virtual_title = attributes.fetch(:virtual_title) if attributes.key?(:virtual_title)
11 | end
12 |
13 | def virtual_title
14 | object.title
15 | end
16 |
17 | def virtual_title=(virtual_title)
18 | object.title = virtual_title
19 | end
20 |
21 | def decorator_method
22 | 'A method only available on the decorator'
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/app/views/active_admin/devise/unlocks/new.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= active_admin_application.site_title(self) %> <%= title t('active_admin.devise.unlock.title') %>
21 |
--------------------------------------------------------------------------------
/lib/active_admin/reloader.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 | module Reloader
3 | # ActionDispatch::Reloader.to_prepare is deprecated in Rails 5.0 and will be removed from Rails 5.1
4 | #
5 | # Use ActiveSupport::Reloader if available for Rails 5, fall back to ActionDispatch::Reloader for earlier Rails
6 | def self.to_prepare(*args, &block)
7 | if defined? ActiveSupport::Reloader
8 | ActiveSupport::Reloader.to_prepare(*args, &block)
9 | else
10 | ActionDispatch::Reloader.to_prepare(*args, &block)
11 | end
12 | end
13 |
14 | # ActionDispatch::Reloader.to_cleanup is deprecated in Rails 5.0 and will be removed from Rails 5.1
15 | #
16 | # Use ActiveSupport::Reloader if available for Rails 5, fall back to ActionDispatch::Reloader for earlier Rails
17 | def self.to_complete(*args, &block)
18 | if defined? ActiveSupport::Reloader
19 | ActiveSupport::Reloader.to_complete(*args, &block)
20 | else
21 | ActionDispatch::Reloader.to_cleanup(*args, &block)
22 | end
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/active_admin/components/_comments.scss:
--------------------------------------------------------------------------------
1 | // -------------------------------------- Admin Notes
2 | .comments {
3 |
4 | .active_admin_comment {
5 | clear: both;
6 | margin-top: 10px;
7 | margin-bottom: 40px;
8 | max-width: 700px;
9 |
10 | .active_admin_comment_meta {
11 | width: 130px;
12 | float: left;
13 | overflow: hidden;
14 | font-size: 0.9em;
15 | color: lighten($primary-color, 10%);
16 | .active_admin_comment_author {
17 | font-size: 1.2em;
18 | font-weight: bold;
19 | margin: 0;
20 | color: $primary-color;
21 | }
22 | }
23 | .active_admin_comment_body {
24 | margin-left: 150px;
25 | }
26 | }
27 | form.active_admin_comment {
28 | margin: 0;
29 | padding: 0;
30 | margin-left: 150px;
31 |
32 | fieldset.inputs {
33 | margin: 0;
34 | padding: 0;
35 | background: none;
36 | @include no-shadow;
37 | }
38 | li { padding: 0; }
39 | fieldset.buttons { padding: 0; margin-top: 5px;}
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/features/global_navigation.feature:
--------------------------------------------------------------------------------
1 | Feature: Global Navigation
2 |
3 | Background:
4 | Given a configuration of:
5 | """
6 | ActiveAdmin.register Post
7 | """
8 | Given I am logged in
9 | And 10 posts exist
10 |
11 | Scenario: Viewing the current section in the global navigation
12 | Given I am on the index page for posts
13 | Then the "Posts" tab should be selected
14 |
15 | Scenario: Viewing the current section in the global navigation when on new page
16 | Given I am on the index page for posts
17 | And I follow "New Post"
18 | Then the "Posts" tab should be selected
19 |
20 | Scenario: Viewing the current section in the global navigation when on show page
21 | Given I am on the index page for posts
22 | And I follow "View"
23 | Then the "Posts" tab should be selected
24 |
25 | Scenario: Viewing the current section in the global navigation when on edit page
26 | Given I am on the index page for posts
27 | And I follow "View"
28 | And I follow "Edit Post"
29 | Then the "Posts" tab should be selected
30 |
--------------------------------------------------------------------------------
/spec/unit/resource_controller/sidebars_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe ActiveAdmin::ResourceController::Sidebars, type: :controller do
4 | let(:klass){ Admin::PostsController }
5 |
6 | shared_context 'with post config' do
7 | before do
8 | load_resources { post_config }
9 |
10 | @controller = klass.new
11 |
12 | get :index
13 | end
14 | end
15 |
16 | context 'without skip_sidebar! before filter' do
17 | include_context 'with post config' do
18 | let(:post_config) { ActiveAdmin.register Post }
19 | end
20 |
21 | it 'does not set @skip_sidebar' do
22 | expect(controller.instance_variable_get(:@skip_sidebar)).to eq nil
23 | end
24 | end
25 |
26 | context 'with skip_sidebar! before_action' do
27 | include_context 'with post config' do
28 | let(:post_config) do
29 | ActiveAdmin.register(Post) { before_action :skip_sidebar! }
30 | end
31 | end
32 |
33 | it 'works' do
34 | expect(controller.instance_variable_get(:@skip_sidebar)).to eq true
35 | end
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/features/development_reloading.feature:
--------------------------------------------------------------------------------
1 | Feature: Development Reloading
2 |
3 | In order to quickly develop applications
4 | As a developer
5 | I want the application to reload itself in development
6 |
7 | @requires-reloading
8 | Scenario: Registering a resource that was not previously registered
9 | When I am logged in with capybara
10 | Then I should not see a menu item for "Posts"
11 |
12 | When "app/admin/posts.rb" contains:
13 | """
14 | ActiveAdmin.register Post do
15 | permit_params :custom_category_id, :author_id, :title,
16 | :body, :position, :published_date, :starred
17 | end
18 | """
19 | When I am logged in with capybara
20 | Then I should see a menu item for "Posts"
21 |
22 | When I create a new post with the title "A"
23 | Then I should see a successful create flash
24 |
25 | When I add "validates_presence_of :title" to the "post" model
26 | And I create a new post with the title ""
27 | Then I should not see a successful create flash
28 | And I should see a validation error "can't be blank"
29 |
--------------------------------------------------------------------------------
/features/registering_resources.feature:
--------------------------------------------------------------------------------
1 | Feature: Registering Resources
2 |
3 | Registering resources within Active Admin
4 |
5 | Background:
6 | Given I am logged in
7 | And a post with the title "Hello World" exists
8 |
9 | Scenario: Registering a resource with the defaults
10 | Given a configuration of:
11 | """
12 | ActiveAdmin.register Post
13 | """
14 | When I go to the dashboard
15 | Then I should see "Posts"
16 | When I follow "Posts"
17 | Then I should see "Hello World"
18 | When I follow "View"
19 | Then I should see "Hello World"
20 | And I should be in the resource section for Post
21 |
22 | Scenario: Registering a resource with another name
23 | Given a configuration of:
24 | """
25 | ActiveAdmin.register Post, as: "My Post"
26 | """
27 | When I go to the dashboard
28 | Then I should see "My Posts"
29 | When I follow "My Posts"
30 | Then I should see "Hello World"
31 | When I follow "View"
32 | Then I should see "Hello World"
33 | And I should be in the resource section for My Post
34 |
--------------------------------------------------------------------------------
/lib/generators/active_admin/install/templates/dashboard.rb:
--------------------------------------------------------------------------------
1 | ActiveAdmin.register_page "Dashboard" do
2 |
3 | menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
4 |
5 | content title: proc{ I18n.t("active_admin.dashboard") } do
6 | div class: "blank_slate_container", id: "dashboard_default_message" do
7 | span class: "blank_slate" do
8 | span I18n.t("active_admin.dashboard_welcome.welcome")
9 | small I18n.t("active_admin.dashboard_welcome.call_to_action")
10 | end
11 | end
12 |
13 | # Here is an example of a simple dashboard with columns and panels.
14 | #
15 | # columns do
16 | # column do
17 | # panel "Recent Posts" do
18 | # ul do
19 | # Post.recent(5).map do |post|
20 | # li link_to(post.title, admin_post_path(post))
21 | # end
22 | # end
23 | # end
24 | # end
25 |
26 | # column do
27 | # panel "Info" do
28 | # para "Welcome to ActiveAdmin."
29 | # end
30 | # end
31 | # end
32 | end # content
33 | end
34 |
--------------------------------------------------------------------------------
/lib/active_admin/dynamic_setting.rb:
--------------------------------------------------------------------------------
1 | module ActiveAdmin
2 |
3 | class DynamicSetting
4 | def self.build(setting, type)
5 | (type ? klass(type) : self).new(setting)
6 | end
7 |
8 | def self.klass(type)
9 | klass = "#{type.to_s.camelcase}Setting"
10 | raise ArgumentError, "Unknown type: #{type}" unless ActiveAdmin.const_defined?(klass)
11 | ActiveAdmin.const_get(klass)
12 | end
13 |
14 | def initialize(setting)
15 | @setting = setting
16 | end
17 |
18 | def value(*_args)
19 | @setting
20 | end
21 | end
22 |
23 | # Many configuration options (Ex: site_title, title_image) could either be
24 | # static (String), methods (Symbol) or procs (Proc). This wrapper takes care of
25 | # returning the content when String or using instance_eval when Symbol or Proc.
26 | #
27 | class StringSymbolOrProcSetting < DynamicSetting
28 | def value(context = self)
29 | case @setting
30 | when Symbol, Proc
31 | context.instance_eval(&@setting)
32 | else
33 | @setting
34 | end
35 | end
36 | end
37 |
38 | end
39 |
--------------------------------------------------------------------------------
/app/views/active_admin/devise/registrations/new.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= active_admin_application.site_title(self) %> <%= title t('active_admin.devise.sign_up.title') %>