Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
84c50af
Reestructure
santib May 24, 2020
574dbd6
Fix rubocop
santib May 24, 2020
c398860
Restore rubocop exclusions
santib May 30, 2020
84417b9
Fix tests
santib May 30, 2020
20992ec
Try to fix travis
santib May 30, 2020
2b38ac0
Split channels
santib May 31, 2020
40a137b
Fix dummy app
santib May 31, 2020
3e2c6b0
Fix tests
santib May 31, 2020
aef4c0c
Fix tests and deprecation warnings
santib Jun 7, 2020
e40fe3a
Reestructure JS
santib Jun 7, 2020
0f00575
Install webpacker in dummy app
santib Jun 7, 2020
a1bcc06
Update README
santib Jun 7, 2020
8a321d8
Fix tests
santib Jun 7, 2020
a6f7b7a
Fix rubocop
santib Jun 8, 2020
0e7915c
Webpacker is a prod dependency too
santib Jun 8, 2020
d0b06dc
Use npm package
santib Jun 9, 2020
17aab75
Use gemspec
santib Jun 9, 2020
c467fec
Fix Travis
santib Jul 4, 2020
be5f843
Fix gemfiles
santib Jul 19, 2020
60f80ef
Fix deprecation warning
santib Aug 16, 2020
0f93486
Fix link
santib Aug 16, 2020
b26b6ae
Fix TravisCI
santib Aug 17, 2020
cc73859
Refactor JS package
santib Aug 29, 2020
614df67
Fix rubocop
santib Aug 29, 2020
d933fe0
Improve gemspec
santib Sep 25, 2020
1f544e8
Fix require issue
santib Sep 26, 2020
8ac506b
Remove useless files
santib Oct 4, 2020
465ee45
Bump version
santib Oct 4, 2020
440145d
Restore dev dependencies
santib Oct 4, 2020
d55ed26
Bump version
santib Oct 4, 2020
67b8398
Fix code style
santib Oct 4, 2020
4ddd074
Fix rubocop
santib Oct 4, 2020
306d622
Use local dependency
santib Oct 4, 2020
4875f0c
Update ruby requirement
santib Oct 4, 2020
4c11851
Fix actioncable dependency
santib Oct 4, 2020
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ spec/dummy/node_modules/
spec/dummy/yarn-error.log
spec/dummy/storage/
spec/dummy/tmp/
spec/dummy/public/packs/
spec/dummy/public/packs-test/
spec/tmp/
node_modules/
/coverage/
Expand Down
25 changes: 16 additions & 9 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
AllCops:
TargetRubyVersion: 2.5
Exclude:
- spec/dummy/db/schema.rb
- spec/dummy/node_modules/**/*
- node_modules/**/*
- vendor/bundle/**/*
- gemfiles/vendor/bundle/**/*

Expand All @@ -13,24 +16,24 @@ Lint/AmbiguousBlockAssociation:

Lint/NestedMethodDefinition:
Exclude:
- lib/active_admin_chat/active_admin/application.rb
- lib/active_admin/chat/extensions/application.rb

Metrics/AbcSize:
# The ABC size is a calculated magnitude, so this number can be an Integer or
# a Float.
Max: 15
Exclude:
- lib/generators/active_admin_chat/install/install_generator.rb
- lib/active_admin_chat/active_admin/application.rb
- app/channels/chat_channel.rb
- lib/generators/active_admin/chat/install/install_generator.rb
- lib/active_admin/chat/extensions/application.rb
- app/channels/active_admin/chat/chat_channel.rb

Metrics/BlockLength:
CountComments: false # count full line comments?
Max: 25
Exclude:
- spec/generators/install_generator_spec.rb
- lib/active_admin_chat/active_admin/application.rb
- active_admin_chat.gemspec
- lib/active_admin/chat/extensions/application.rb
- activeadmin-chat.gemspec
ExcludedMethods: ['describe', 'context', 'feature', 'scenario']

Metrics/BlockNesting:
Expand All @@ -48,7 +51,7 @@ Metrics/MethodLength:
CountComments: false # count full line comments?
Max: 24
Exclude:
- lib/active_admin_chat/active_admin/application.rb
- lib/active_admin/chat/extensions/application.rb

Metrics/ModuleLength:
CountComments: false # count full line comments?
Expand All @@ -64,7 +67,7 @@ Metrics/LineLength:
- https
Exclude:
- spec/dummy/**/*
- spec/channels/chat_channel_spec.rb
- spec/channels/active_admin/chat/chat_channel_spec.rb
- config/routes.rb

Metrics/ParameterLists:
Expand All @@ -74,6 +77,10 @@ Metrics/ParameterLists:
Metrics/PerceivedComplexity:
Max: 12

Naming/FileName:
Exclude:
- lib/activeadmin-chat.rb

Style/FrozenStringLiteralComment:
Enabled: false

Expand All @@ -86,4 +93,4 @@ Style/MixinUsage:

Style/GuardClause:
Exclude:
- lib/generators/active_admin_chat/install/install_generator.rb
- lib/generators/active_admin/chat/install/install_generator.rb
59 changes: 32 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
language: ruby

dist: xenial

os: linux

addons:
chrome: stable

env:
global:
- CC_TEST_REPORTER_ID=796169b8dd8f24e0dfbe4ce3f7c3c3f95f5ecc5475b95871f1797664f6b2b3e3

language: ruby
cache: bundler
cache:
- bundler
- yarn

rvm:
- 2.2.2
- 2.3.8
- 2.4.5
- 2.5.3
- 2.5.8
- 2.6.6
- 2.7.1
- ruby-head

addons:
chrome: stable
gemfile:
- gemfiles/rails_5_2.gemfile
- gemfiles/rails_6_0.gemfile

dist: xenial
os: linux
jobs:
fast_finish: true
allow_failures:
- rvm: ruby-head

before_install:
- bundle install
- sudo apt-get update
- sudo apt-get install chromium-chromedriver
- "export PATH=$PATH:/usr/lib/chromium-browser/"
- nvm install 12
- bin/yarn install
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
- CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
- CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
- curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
- unzip chromedriver_linux64.zip -d ~/bin
- gem update --system --no-doc
- gem install bundler --no-doc


after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT

gemfile:
- gemfiles/5.0.gemfile
- gemfiles/5.1.gemfile
- gemfiles/5.2.gemfile

jobs:
fast_finish: true
exclude:
- gemfile: gemfiles/5.2.gemfile
rvm: 2.2.2
allow_failures:
- rvm: ruby-head
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# Declare your gem's dependencies in active_admin_chat.gemspec.
# Declare your gem's dependencies in activeadmin-chat.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
Expand Down
44 changes: 27 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# ActiveAdminChat
# ActiveAdmin::Chat

[![Build Status](https://travis-ci.org/rootstrap/active_admin_chat.svg?branch=master)](https://travis-ci.org/rootstrap/active_admin_chat)
[![Maintainability](https://api.codeclimate.com/v1/badges/7a8d43aef79218e8f772/maintainability)](https://codeclimate.com/github/rootstrap/active_admin_chat/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/7a8d43aef79218e8f772/test_coverage)](https://codeclimate.com/github/rootstrap/active_admin_chat/test_coverage)
[![Build Status](https://travis-ci.org/rootstrap/activeadmin-chat.svg?branch=master)](https://travis-ci.org/rootstrap/activeadmin-chat)
[![Maintainability](https://api.codeclimate.com/v1/badges/7a8d43aef79218e8f772/maintainability)](https://codeclimate.com/github/rootstrap/activeadmin-chat/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/7a8d43aef79218e8f772/test_coverage)](https://codeclimate.com/github/rootstrap/activeadmin-chat/test_coverage)

Get a chat for your ActiveAdmin app out of the box.

![](active_admin_chat_gif.gif)
![](images/activeadmin-chat.gif)

## Prerequisites
- It assumes you have models for your admins and users in place.
Expand All @@ -16,47 +16,57 @@ Get a chat for your ActiveAdmin app out of the box.
## Installation
Add to Gemfile:
```ruby
gem 'active_admin_chat'
gem 'activeadmin-chat'
```

And then run:
```bash
$ bundle install
```

Install ActiveAdminChat:
This gem requires Webpacker for the Javascript. Add the npm package:
```bash
$ rails generate active_admin_chat:install
$ yarn add activeadmin-chat
```

And install it:
```bash
$ yarn install
```

Install `ActiveAdmin::Chat`:
```bash
$ rails generate active_admin:chat:install
```
It will generate:
- `Conversation` and `Message` models and migrations.
- Initializer that configures the model names for conversation, message, admin user and user.
- Default chat page.

You can customize the namings of the models when installing ActiveAdminChat with the usage of the `--conversation_model_name`, `--message_model_name`, `--admin_user_model_name` and `--user_model_name` flags.
You can customize the namings of the models when installing `ActiveAdmin::Chat` with the usage of the `--conversation_model_name`, `--message_model_name`, `--admin_user_model_name` and `--user_model_name` flags.

For example:
```bash
$ rails generate active_admin_chat:install --conversation_model_name=chat
$ rails generate active_admin:chat:install --conversation_model_name=chat
```

Once you've successfully installed ActiveAdminChat, run:
Once you've successfully installed `ActiveAdmin::Chat`, run:
```bash
$ rails db:migrate
```

Add including of CSS to `app/assets/stylesheets/active_admin.css.scss`:
```css
@import 'active_admin_chat';
@import 'active_admin/chat';
```

And including of JS to `app/assets/javascripts/active_admin.js`:
Create a file named `app/javascript/packs/activeadmin-chat.js`, with the following content:
```js
#= require active_admin_chat
import 'activeadmin-chat';
```

### Example diagram
![](admin_chat_diagram.png?raw=true "Chat diagram")
![](images/activeadmin-chat_diagram.png?raw=true "Chat diagram")

## Usage
All you need to get the chat up and running is to authenticate your users in the websocket connection in `app/channels/application_cable/connection.rb`. It's important that you identify them as the `current_user` here, this will be used by the gem internally.
Expand Down Expand Up @@ -128,12 +138,12 @@ end
```

## Contributing
Bug reports (please use Issues) and pull requests are welcome on GitHub at https://github.com/rootstrap/active_admin_chat. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
Bug reports (please use Issues) and pull requests are welcome on GitHub at https://github.com/rootstrap/activeadmin-chat. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

## Credits
**Active Admin Chat** is maintained by [Rootstrap](http://www.rootstrap.com) with the help of our [contributors](https://github.com/rootstrap/active_admin_chat/contributors).
**Active Admin Chat** is maintained by [Rootstrap](http://www.rootstrap.com) with the help of our [contributors](https://github.com/rootstrap/activeadmin-chat/contributors).

[<img src="https://s3-us-west-1.amazonaws.com/rootstrap.com/img/rs.png" width="100"/>](http://www.rootstrap.com)
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require 'rdoc/task'

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'ActiveAdminChat'
rdoc.title = 'ActiveAdmin::Chat'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('lib/**/*.rb')
Expand Down
28 changes: 13 additions & 15 deletions active_admin_chat.gemspec → activeadmin-chat.gemspec
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
$LOAD_PATH.push File.expand_path('lib', __dir__)
# frozen_string_literal: true

# Maintain your gem's version:
require 'active_admin_chat/version'
require_relative 'lib/active_admin/chat/version'

# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = 'active_admin_chat'
s.version = ActiveAdminChat::VERSION
s.name = 'activeadmin-chat'
s.version = ActiveAdmin::Chat::VERSION
s.authors = ['Santiago Bartesaghi', 'Federico Aldunate']
s.email = ['santiago.bartesaghi@rootstrap.com', 'federico@rootstrap.com']
s.homepage = 'https://github.com/rootstrap/active_admin_chat'
s.homepage = 'https://github.com/rootstrap/activeadmin-chat'
s.summary = 'ActiveAdmin chat plugin'
s.description = s.summary
s.license = 'MIT'

s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md']
s.require_paths = ['lib']

s.required_ruby_version = '>= 2.2.2'
s.required_ruby_version = '>= 2.5.0'

s.add_dependency 'activeadmin', '>= 1.0.0'
s.add_dependency 'rails', '>= 5.0.0'
s.add_dependency 'sassc-rails', '~> 2.1.2'
s.add_dependency 'activeadmin', '>= 2.0'
s.add_dependency 'rails', '>= 5.2'
s.add_dependency 'webpacker', '>= 5.0'

s.add_development_dependency 'action-cable-testing', '~> 0.4.0'
s.add_development_dependency 'action-cable-testing', '>= 0.4.0'
s.add_development_dependency 'byebug', '~> 10.0.0'
s.add_development_dependency 'capybara', '~> 3.1.1'
s.add_development_dependency 'database_cleaner', '~> 1.8.4'
s.add_development_dependency 'capybara', '~> 3.32.2'
s.add_development_dependency 'factory_bot_rails', '~> 4.11.1'
s.add_development_dependency 'generator_spec', '~> 0.9.4'
s.add_development_dependency 'puma', '~> 4.3.3'
s.add_development_dependency 'rspec-rails', '~> 3.8'
s.add_development_dependency 'rubocop', '~> 0.59.2'
s.add_development_dependency 'selenium-webdriver', '~> 3.0'
s.add_development_dependency 'simplecov', '~> 0.17.1'
s.add_development_dependency 'sqlite3', '~> 1.4.0'
s.add_development_dependency 'timecop', '~> 0.9.1'
s.add_development_dependency 'sqlite3', '>= 1.3.0'
end
Empty file.
3 changes: 0 additions & 3 deletions app/assets/javascripts/active_admin_chat.js

This file was deleted.

Empty file.
4 changes: 0 additions & 4 deletions app/assets/javascripts/active_admin_chat/cable.js.erb

This file was deleted.

Loading