Skip to content

Commit

Permalink
Fix client docs locale (#458)
Browse files Browse the repository at this point in the history
* exclude number nth

* docs client i18n fix

* collection selector on docs , checkbox fix

* load i18n listen on dev env

* dashboard links to tester & playground

* fix current locale set on client

* lint
  • Loading branch information
michelson committed Aug 6, 2021
1 parent 43c9493 commit 3719141
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 45 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ gem "biz", "~> 1.8"
# gem "i18n-js"
gem "i18n-js", "~> 4.0.0.alpha1"


gem "globalize", github: "globalize/globalize"

# Reduces boot times through caching; required in config/boot.rb
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Rails.application.load_tasks
namespace :locales do
desc "compile i18n before compile"
task :build do
system('yarn i18n:export')
system("yarn i18n:export")
end
end

Expand Down
5 changes: 2 additions & 3 deletions app/graphql/mutations/predicates/delete_predicate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ class Predicates::DeletePredicate < Mutations::BaseMutation
def resolve(app_key:, id:)
current_user = context[:current_user]
@app = current_user.apps.find_by(key: app_key)
if @app.segments.size == 1
raise "server does not allow empty segments, we kept one"
end
raise "server does not allow empty segments, we kept one" if @app.segments.size == 1

@segment = @app.segments.find(id)
@segment.delete
{ segment: @segment, errors: @segment.errors }
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packages/store/src/graphql/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { refreshToken } from '../actions/auth'
const graphql = (query, variables, callbacks) => {
const { auth, current_user } = store.getState()

const locale = current_user.lang || I18n.defaultLocale
const locale = current_user.lang || (window.I18n && window.I18n.defaultLocale) || 'en'

const config = {
authorization: `Bearer ${auth.accessToken}`,
Expand Down
4 changes: 0 additions & 4 deletions app/javascript/src/locales/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -12245,10 +12245,6 @@
}
}
},
"nth": {
"ordinalized": "#<Proc:0x00007fd0e5582e20 /Users/michelson/.rvm/gems/ruby-2.7.2/gems/activesupport-6.1.3.1/lib/active_support/locale/en.rb:26 (lambda)>",
"ordinals": "#<Proc:0x00007fd0e5583cd0 /Users/michelson/.rvm/gems/ruby-2.7.2/gems/activesupport-6.1.3.1/lib/active_support/locale/en.rb:7 (lambda)>"
},
"percentage": {
"format": {
"delimiter": "",
Expand Down
45 changes: 23 additions & 22 deletions app/javascript/src/pages/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,18 @@ import { withRouter, Link } from 'react-router-dom'
import { connect } from 'react-redux'
import WebSetup from '@chaskiq/components/src/components/webSetup'
import Badge from '@chaskiq/components/src/components/Badge'
import { useHistory } from "react-router-dom";

import Content from '@chaskiq/components/src/components/Content'
import PageHeader from '@chaskiq/components/src/components/PageHeader'

import DashboardItem from './reports/ReportItem'

import {
MoreIcon,
WebhooksIcon,
ApiIcon,
DashboardIcon,
PlatformIcon,
ConversationChatIcon,
AssignmentIcon,
CampaignsIcon,
MailingIcon,
AutoMessages,
BannersIcon,
ToursIcon,
BotIcon,
OutboundIcon,
NewconversationIcon,
SettingsIcon,
HelpCenterIcon,
ArticlesIcon,
CollectionsIcon,
ChatIcon,
BillingIcon,
IntegrationsIcon,
TeamIcon,
MessengerIcon,
AppSettingsIcon,
ChartsIcons,
} from '@chaskiq/components/src/components/icons'
Expand All @@ -42,6 +23,7 @@ import {
setCurrentSection,
setCurrentPage
} from '@chaskiq/store/src/actions/navigation'
import { LinkButton } from '@chaskiq/components/src/components/RouterLink'

export function Home() {
return (
Expand All @@ -59,6 +41,8 @@ function Dashboard(props) {
dispatch(setCurrentPage(null))
}, [])

const history = useHistory()


const actions = [
{
Expand All @@ -70,6 +54,7 @@ function Dashboard(props) {
render: ()=>(
<div className="mt-2 text-sm text-gray-500">
<span className="truncate--">

{I18n.t('dashboard.status')}{' '}
{app.activeMessenger && (
<Badge size="sm" variant="green">
Expand Down Expand Up @@ -138,8 +123,24 @@ function Dashboard(props) {
}}
/>

<WebSetup />


<div className="py-3 flex space-x-3 justify-end">
<WebSetup />

<LinkButton
variant="outlined"
onClick={ ()=> window.open(`/tester/${app.key}`, '_blank').focus() }
target="blank">
Chat tester
</LinkButton>

<LinkButton
variant="outlined"
onClick={ ()=> history.push("/playground") }>
Playground
</LinkButton>
</div>

</div>

<div key={'dashboard-status'} className="space-y-2">
Expand Down
11 changes: 7 additions & 4 deletions app/javascript/src/pages/articles/collections/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,11 @@ class CollectionDetail extends Component {
if (collection) {
this.getCollection()
}
this.setState({ addArticlesDialog: false })
},
error: () => {
this.setState({ addArticlesDialog: false })
},
error: () => {},
}
)
}
Expand Down Expand Up @@ -469,17 +472,17 @@ class AddArticleDialog extends Component {
<List>
{this.state.articles.map((o) => (
<ListItem key={`article-list-${o.id}`}>
<Input
<input
type="checkbox"
checked={o.id}
// checked={o.id}
// onChange={handleChange('checkedA')}
value={o.id}
name="article[]"
/>

<ListItemText
primary={o.title}
secondary={<p noWrap>{o.state}</p>}
secondary={<p>{o.state}</p>}
/>
</ListItem>
))}
Expand Down
5 changes: 4 additions & 1 deletion app/models/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ class Article < ApplicationRecord

scope :without_section, -> { where(article_section_id: nil).order(position: :asc) }
scope :with_section, -> { where.not(article_section_id: nil).order(position: :asc) }
scope :without_collection, -> { where(article_collection_id: nil).order(position: :asc) }
scope :without_collection, lambda {
where(article_collection_id: [nil, 0])
.order(position: :asc)
}

aasm column: :state do
state :draft, initial: true
Expand Down
3 changes: 1 addition & 2 deletions app/models/article_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class ArticleSetting < ApplicationRecord

validates :subdomain,
exclusion: { in: %w[www],
message: "%{value} is reserved."
},
message: "%{value} is reserved." },
presence: true,
uniqueness: true,
allow_blank: true
Expand Down
2 changes: 1 addition & 1 deletion app/services/message_apis/csat/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def report(path, integration, options)
options = integration.app.conversation_events.custom_counts("plugins.csat", "val")
data_options = MessageApis::Csat::Presenter.csat_buttons[:options]

total = options.map{|o| o.freq.to_f }.inject(:+)
total = options.map { |o| o.freq.to_f }.inject(:+)

{
id: "csat-plugin",
Expand Down
4 changes: 2 additions & 2 deletions app/services/message_apis/csat/presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ def self.configure_hook(kind:, ctx:)

definitions = [

#{
# {
# type: "input",
# id: "label",
# label: "CSAT label",
# placeholder: "How would you rate your experience with our service?",
# save_state: "unsaved"
#},
# },
csat_buttons,
{
type: "button",
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<script> window.chaskiq_cable_url = "<%= ENV['WS'] %>"</script>

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<% #= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
Expand Down
1 change: 1 addition & 0 deletions config/i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ translations:
- "*"
- "!*.ransack"
- "!*.faker"
- "!*.number.nth"
- file: "app/javascript/src/locales/messenger-translations.json"
patterns: ["*.messenger.*"]
6 changes: 4 additions & 2 deletions config/initializers/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
# skips faker & ransack
# I18n.load_path -= I18n.load_path.grep(/faker|ransack/)

require "i18n-js/listen"
I18nJS.listen
if Rails.env.development?
require "i18n-js/listen"
I18nJS.listen
end

0 comments on commit 3719141

Please sign in to comment.