Skip to content

Commit

Permalink
tech: bump rails to 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kugaevsky committed Feb 28, 2022
1 parent ad8a15f commit cedb6e8
Show file tree
Hide file tree
Showing 12 changed files with 971 additions and 370 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"env": { "browser": true },
"extends": ["airbnb"],
"plugins": ["@typescript-eslint"],
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": ["./tsconfig.json"] },
"rules": {
"import/no-unresolved": 0,
"react/jsx-filename-extension": [1, { "extensions": [".jsx", ".tsx"] }]
}
}
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ruby '3.1.1'

source 'https://rubygems.org'

gem 'rails', '~> 6.0.0'
gem 'rails-i18n', '~> 6.0.0'
gem 'rails', '~> 6.1'
gem 'rails-i18n', '~> 6.0'

# Databases
gem 'hiredis'
Expand Down
129 changes: 66 additions & 63 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,40 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.4.6)
actionpack (= 6.0.4.6)
actioncable (6.1.4.6)
actionpack (= 6.1.4.6)
activesupport (= 6.1.4.6)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.4.6)
actionpack (= 6.0.4.6)
activejob (= 6.0.4.6)
activerecord (= 6.0.4.6)
activestorage (= 6.0.4.6)
activesupport (= 6.0.4.6)
actionmailbox (6.1.4.6)
actionpack (= 6.1.4.6)
activejob (= 6.1.4.6)
activerecord (= 6.1.4.6)
activestorage (= 6.1.4.6)
activesupport (= 6.1.4.6)
mail (>= 2.7.1)
actionmailer (6.0.4.6)
actionpack (= 6.0.4.6)
actionview (= 6.0.4.6)
activejob (= 6.0.4.6)
actionmailer (6.1.4.6)
actionpack (= 6.1.4.6)
actionview (= 6.1.4.6)
activejob (= 6.1.4.6)
activesupport (= 6.1.4.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.4.6)
actionview (= 6.0.4.6)
activesupport (= 6.0.4.6)
rack (~> 2.0, >= 2.0.8)
actionpack (6.1.4.6)
actionview (= 6.1.4.6)
activesupport (= 6.1.4.6)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.4.6)
actionpack (= 6.0.4.6)
activerecord (= 6.0.4.6)
activestorage (= 6.0.4.6)
activesupport (= 6.0.4.6)
actiontext (6.1.4.6)
actionpack (= 6.1.4.6)
activerecord (= 6.1.4.6)
activestorage (= 6.1.4.6)
activesupport (= 6.1.4.6)
nokogiri (>= 1.8.5)
actionview (6.0.4.6)
activesupport (= 6.0.4.6)
actionview (6.1.4.6)
activesupport (= 6.1.4.6)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
Expand All @@ -50,29 +52,31 @@ GEM
activemodel (>= 4.1, < 7.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (6.0.4.6)
activesupport (= 6.0.4.6)
activejob (6.1.4.6)
activesupport (= 6.1.4.6)
globalid (>= 0.3.6)
activemodel (6.0.4.6)
activesupport (= 6.0.4.6)
activemodel (6.1.4.6)
activesupport (= 6.1.4.6)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (6.0.4.6)
activemodel (= 6.0.4.6)
activesupport (= 6.0.4.6)
activestorage (6.0.4.6)
actionpack (= 6.0.4.6)
activejob (= 6.0.4.6)
activerecord (= 6.0.4.6)
activerecord (6.1.4.6)
activemodel (= 6.1.4.6)
activesupport (= 6.1.4.6)
activestorage (6.1.4.6)
actionpack (= 6.1.4.6)
activejob (= 6.1.4.6)
activerecord (= 6.1.4.6)
activesupport (= 6.1.4.6)
marcel (~> 1.0.0)
activesupport (6.0.4.6)
mini_mime (>= 1.1.0)
activesupport (6.1.4.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
acts-as-taggable-on (9.0.1)
activerecord (>= 6.0, < 7.1)
addressable (2.8.0)
Expand Down Expand Up @@ -349,20 +353,20 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.4.6)
actioncable (= 6.0.4.6)
actionmailbox (= 6.0.4.6)
actionmailer (= 6.0.4.6)
actionpack (= 6.0.4.6)
actiontext (= 6.0.4.6)
actionview (= 6.0.4.6)
activejob (= 6.0.4.6)
activemodel (= 6.0.4.6)
activerecord (= 6.0.4.6)
activestorage (= 6.0.4.6)
activesupport (= 6.0.4.6)
bundler (>= 1.3.0)
railties (= 6.0.4.6)
rails (6.1.4.6)
actioncable (= 6.1.4.6)
actionmailbox (= 6.1.4.6)
actionmailer (= 6.1.4.6)
actionpack (= 6.1.4.6)
actiontext (= 6.1.4.6)
actionview (= 6.1.4.6)
activejob (= 6.1.4.6)
activemodel (= 6.1.4.6)
activerecord (= 6.1.4.6)
activestorage (= 6.1.4.6)
activesupport (= 6.1.4.6)
bundler (>= 1.15.0)
railties (= 6.1.4.6)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
Expand All @@ -377,12 +381,12 @@ GEM
rails_stdout_logging
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (6.0.4.6)
actionpack (= 6.0.4.6)
activesupport (= 6.0.4.6)
railties (6.1.4.6)
actionpack (= 6.1.4.6)
activesupport (= 6.1.4.6)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (>= 0.13)
thor (~> 1.0)
rainbow (3.1.1)
rake (13.0.6)
rb-fsevent (0.11.1)
Expand Down Expand Up @@ -509,11 +513,10 @@ GEM
temple (0.8.2)
test-prof (1.0.7)
thor (1.2.1)
thread_safe (0.3.6)
tilt (2.0.10)
timeout (0.2.0)
tzinfo (1.2.9)
thread_safe (~> 0.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
Expand Down Expand Up @@ -599,8 +602,8 @@ DEPENDENCIES
postrank-uri
pry-rails
puma-rails (>= 0.0.2)
rails (~> 6.0.0)
rails-i18n (~> 6.0.0)
rails (~> 6.1)
rails-i18n (~> 6.0)
rails_12factor
redcarpet
redis
Expand Down
6 changes: 1 addition & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ def define_common_meta_tags
end

def authenticated_path?
controller_namespace == My || new_event_path == request.original_fullpath
end

def controller_namespace
self.class.parent
controller_path.split('/').first == 'my' || new_event_path == request.original_fullpath
end
end
38 changes: 19 additions & 19 deletions app/javascript/packs/application.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import * as Turbolinks from 'turbolinks'
import railsUjs from 'rails-ujs'
import * as Turbolinks from 'turbolinks';
import railsUjs from '@rails/ujs';

import { ForeignLinkSwitcher } from './helpers/foreign-link-switcher'
import { MdcInit } from './mdc/mdc-init'
import { YandexInit } from './yandex/yandex-init'
import { ForeignLinkSwitcher } from './helpers/foreign-link-switcher';
import { MdcInit } from './mdc/mdc-init';
import { YandexInit } from './yandex/yandex-init';

Turbolinks.start()
railsUjs.start()
Turbolinks.start();
railsUjs.start();

function init(): void {
const foreignLinkCheckbox = document.getElementById('has_foreign_link')
if (!!foreignLinkCheckbox) ForeignLinkSwitcher.init()
MdcInit.init()
YandexInit.init()
const foreignLinkCheckbox = document.getElementById('has_foreign_link');
if (foreignLinkCheckbox) ForeignLinkSwitcher.init();
MdcInit.init();
YandexInit.init();

let uuid = null
const uuidEl = document.getElementById('uuid')
if (uuidEl) uuid = uuidEl.dataset.userId
let uuid = null;
const uuidEl = document.getElementById('uuid');
if (uuidEl) uuid = uuidEl.dataset.userId;
if (typeof ga === 'function') {
ga('set', '&uid', uuid)
ga('set', 'location', location.href)
ga('send', 'pageview')
ga('set', '&uid', uuid);
ga('set', 'location', location.href);
ga('send', 'pageview');
}
}

document.addEventListener('turbolinks:load', init)
init()
document.addEventListener('turbolinks:load', init);
init();
22 changes: 11 additions & 11 deletions app/javascript/packs/editor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as SimpleMDE from 'simplemde'
import flatpickr from 'flatpickr'
import { Russian } from 'flatpickr/dist/l10n/ru'
import * as SimpleMDE from 'simplemde';
import flatpickr from 'flatpickr';
import { Russian } from 'flatpickr/dist/l10n/ru';

function hasEditor(): boolean {
return document.querySelectorAll('.editor-toolbar').length > 0
return document.querySelectorAll('.editor-toolbar').length > 0;
}

function init(event?: Event): void {
Expand All @@ -15,21 +15,21 @@ function init(event?: Event): void {
dateFormat: 'd.m.Y H:i',
minDate: 'today',
locale: Russian,
})
});

const simplemdeElements = document.querySelectorAll('.mde-textarea')
const simplemdeElements = document.querySelectorAll('.mde-textarea');
if (simplemdeElements.length > 0 && !hasEditor()) {
simplemdeElements.forEach((el) => {
new SimpleMDE({
element: el,
indentWithTabs: false,
promptURLs: true,
spellChecker: false,
hideIcons: ['image']
})
})
hideIcons: ['image'],
});
});
}
}

document.addEventListener('turbolinks:load', init)
init()
document.addEventListener('turbolinks:load', init);
init();
39 changes: 21 additions & 18 deletions app/javascript/packs/helpers/foreign-link-switcher.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
export class ForeignLinkSwitcher {
private static instance: ForeignLinkSwitcher
private static initPage = location.href
private static instance: ForeignLinkSwitcher;

foreignLinkCheckbox = document.getElementById('has_foreign_link') as HTMLInputElement
foreignLinkSwitchedEl = document.getElementById('event_foreign_link_box') as HTMLDivElement
foreignLinkInput = document.getElementById('event_foreign_link') as HTMLInputElement
private static initPage = location.href;

foreignLinkCheckbox = document.getElementById('has_foreign_link') as HTMLInputElement;

foreignLinkSwitchedEl = document.getElementById('event_foreign_link_box') as HTMLDivElement;

foreignLinkInput = document.getElementById('event_foreign_link') as HTMLInputElement;

static init() {
if (!ForeignLinkSwitcher.instance || ForeignLinkSwitcher.initPage !== location.href) {
ForeignLinkSwitcher.initPage = location.href
ForeignLinkSwitcher.instance = new ForeignLinkSwitcher()
ForeignLinkSwitcher.initPage = location.href;
ForeignLinkSwitcher.instance = new ForeignLinkSwitcher();
document.addEventListener('turbolinks:request-start', (_: Event) => {
ForeignLinkSwitcher.initPage = null
})
ForeignLinkSwitcher.initPage = null;
});
}
return ForeignLinkSwitcher.instance
return ForeignLinkSwitcher.instance;
}

private get isChecked(): boolean {
return this.foreignLinkCheckbox.checked
return this.foreignLinkCheckbox.checked;
}

private constructor() {
if (this.isChecked) this.foreignLinkSwitchedEl.classList.remove('hidden')
this.bindEvents()
if (this.isChecked) this.foreignLinkSwitchedEl.classList.remove('hidden');
this.bindEvents();
}

bindEvents() {
this.foreignLinkCheckbox.addEventListener('change', (_: Event) => {
this.foreignLinkSwitchedEl.classList.toggle('hidden')
this.foreignLinkSwitchedEl.classList.toggle('hidden');
if (!this.isChecked) {
this.foreignLinkInput.value = ''
this.foreignLinkInput.setAttribute('disable', 'disabled')
this.foreignLinkInput.value = '';
this.foreignLinkInput.setAttribute('disable', 'disabled');
} else {
this.foreignLinkInput.removeAttribute('disabled')
this.foreignLinkInput.removeAttribute('disabled');
}
})
});
}
}
Loading

0 comments on commit cedb6e8

Please sign in to comment.