Skip to content

Commit

Permalink
Stage (chaskiq#339)
Browse files Browse the repository at this point in the history
* refactor hooks controller

* code refactors

* js lint suggestions

* New translations  (German)

* update mimetype

* langs
  • Loading branch information
michelson authored Mar 25, 2021
1 parent bf8ec86 commit cca8a14
Show file tree
Hide file tree
Showing 60 changed files with 1,129 additions and 1,027 deletions.
12 changes: 8 additions & 4 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ checks:
config:
threshold: 4
similar-code:
enabled: true
config:
threshold: #language-specific defaults. overrides affect all languages.
languages:
ruby:
threshold: 3
javascript:
enabled: false
threshold: 30
identical-code:
enabled: true
config:
Expand All @@ -44,7 +47,7 @@ plugins:
rubocop:
enabled: false
eslint:
enabled: true
enabled: false
exclude_patterns:
- "config/"
- "db/"
Expand All @@ -58,4 +61,5 @@ exclude_patterns:
- "**/vendor/"
- "**/*.d.ts"
- babel.config.js
- lib/app_packages_catalog.rb
#- app/javascript/**/*
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ GEM
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.1104)
mimemagic (0.3.5)
mimemagic (0.3.6)
mini_magick (4.11.0)
mini_mime (1.0.2)
mini_portile2 (2.5.0)
Expand Down
1 change: 1 addition & 0 deletions app/graphql/types/article_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ArticleType < Types::BaseObject
field :collection, Types::CollectionType, null: true
field :section, Types::SectionType, null: true
field :updated_at, type: GraphQL::Types::ISO8601DateTime, null: true
field :updated_at_ago, type: String, null: true

def content
object.article_content.as_json(only: %i[html_content serialized_content text_content])
Expand Down
11 changes: 5 additions & 6 deletions app/javascript/src/components/LangChooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,13 @@ function LangChooser ({
value: I18n.locale,
label: I18n.t(`common.langs.${I18n.locale}`)
}}
label={'select language'}
label={ I18n.t("common.select_language") }
data={{}}
options={
[
{ label: I18n.t('common.langs.en'), value: 'en' },
{ label: I18n.t('common.langs.es'), value: 'es' },
{ label: I18n.t('common.langs.pt'), value: 'pt' }
]
Object.keys(I18n.t("common.langs")).map((o)=> (
{ label: I18n.t(`common.langs.${o}`) , value: o }
)
)
}>
</Input>}

Expand Down
6 changes: 4 additions & 2 deletions app/javascript/src/components/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function List ({ children, shadowless }) {

export function ListItem ({ avatar, action, children, onClick, divider }) {
const clicableClasses = onClick && 'cursor-pointer'

return (
<li className={`${divider ? 'border-b' : ''}`}>
<div
Expand Down Expand Up @@ -52,9 +53,10 @@ export function ListItem ({ avatar, action, children, onClick, divider }) {
)
}

export function ListItemText ({ primary, secondary, terciary }) {
export function ListItemText ({ primary, secondary, terciary, cols }) {
const colsMd = cols ? cols : 2
return (
<div className="min-w-0 flex-1 px-4 md:grid md:grid-cols-2 md:gap-4">
<div className={`min-w-0 flex-1 px-4 md:grid md:grid-cols-${colsMd} md:gap-4`}>
<div>
{primary && primary}

Expand Down
5 changes: 5 additions & 0 deletions app/javascript/src/graphql/docsQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const ARTICLES_UNCATEGORIZED = `
content
state
updatedAt
description
author{
id
name
Expand Down Expand Up @@ -126,6 +127,7 @@ export const ARTICLE = `
content
state
updatedAt
description
collection{
slug
title
Expand Down Expand Up @@ -193,6 +195,8 @@ export const ARTICLE_COLLECTION_WITH_SECTIONS = `
title
slug
updatedAt
description
updatedAt
author{
id
avatarUrl
Expand All @@ -208,6 +212,7 @@ export const ARTICLE_COLLECTION_WITH_SECTIONS = `
id
title
slug
description
updatedAt
author{
id
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/src/pages/Integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ function Integrations ({ app, dispatch }) {
success: (data) => {
setTabValue(0)

if (!isEmpty(data.integrationsCreate.errors)) {
dispatch(errorMessage(I18n.t('settings.integrations.create_error')))
return
}

const integration = data.integrationsCreate.integration
const newIntegrations = integrations.map((o) =>
o.name === integration.name ? integration : o
Expand Down
15 changes: 9 additions & 6 deletions app/javascript/src/pages/docs/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ export default function Article (props) {
src={article.author.avatarUrl}
/>

<div className={'ml-4'}>
<p className="text-lg leading-6 font-medium text-gray-900">
Written by {article.author.name}
</p>

<p className="text-base leading-6 text-gray-500">
<div className={'ml-2'}>
{
article.author.name &&
<p className="text-md leading-6 font-light text-gray-900">
Written by <span className="font-semibold">{article.author.name}</span>
</p>
}

<p className="text-md leading-6 font-light text-gray-500">
{'updated '}
<Moment fromNow>{article.updatedAt}</Moment>
</p>
Expand Down
135 changes: 67 additions & 68 deletions app/javascript/src/pages/docs/collectionSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Tooltip from 'rc-tooltip'
import Breadcrumbs from '../../components/Breadcrumbs'
import translation from './translation'
import Avatar from '../../components/Avatar'

import Moment from 'react-moment'
import { Link } from 'react-router-dom'
import List, {
ListItem,
Expand Down Expand Up @@ -104,6 +104,64 @@ export default function CollectionsWithSections ({ match, lang, subdomain }) {
)
}

function renderArticles(article, section){
return (
<ListItem
divider
key={`${section}-${article.id}`}
>
<ListItemText
cols={1}
primary={
<div className="flex flex-col">
<Link
className="text-lg mb-2 leading-6 font-bold text-gray-900"
color={'primary'}
to={`/${lang}/articles/${article.slug}`}
>
{translation(article.title)}
</Link>

<div className="flex items-center">
<Avatar
variant="small"
alt={article.author.displayName}
src={article.author.avatarUrl}
/>
<div className="space-y-1">
{
article.author.displayName &&
<p className="ml-1.5 text-xs font-light text-gray-400">
Written by{' '}
<strong className="text-gray-800 font-semibold">
{article.author.displayName}
</strong>
</p>
}
{
article.updatedAt &&
<p className="ml-1.5 text-xs font-light text-gray-400">
Updated {" "}
<Moment fromNow>
{article.updatedAt}
</Moment>
</p>
}
</div>

</div>
</div>
}
secondary={
<p className="py-2 font-md text-gray-500 font-light">
{article.description}
</p>}
/>
</ListItem>

)
}

return (
<div className="flex flex-row justify-center items-baseline bg-gray-100 py-8">
{collections && (
Expand All @@ -116,7 +174,7 @@ export default function CollectionsWithSections ({ match, lang, subdomain }) {
]}
></Breadcrumbs>

<div className="py-4">
<div className="my-4 py-4 md:py-8 bg-gray-200 md:px-8 px-3 rounded-sm">
<div>
<p className="py-4 mt-2 text-2xl lg:text-3xl leading-8 font-extrabold tracking-tight text-gray-900 sm:text-6xl sm:leading-10">
{translation(collections.title)}
Expand Down Expand Up @@ -165,39 +223,12 @@ export default function CollectionsWithSections ({ match, lang, subdomain }) {
}
</div>

<div>
{collections.baseArticles.map((article) => (
<ListItem divider key={`articles-base-${article.id}`}>
<ListItemText
primary={
<div className="flex flex-col">
<Link
className="text-lg mb-2 leading-6 font-bold text-gray-900"
color={'primary'}
to={`/${lang}/articles/${article.slug}`}
>
{translation(article.title)}
</Link>

<div className="flex items-center">
<Avatar
variant="small"
alt={article.author.displayName}
src={article.author.avatarUrl}
/>
<p className="ml-4">
written by{' '}
<strong>
{article.author.displayName}
</strong>
</p>
</div>
</div>
}
secondary={article.description}
/>
</ListItem>
))}
<div className="py-4">
<List>
{collections.baseArticles.map((article) => (
renderArticles(article, 'articles-base' )
))}
</List>
</div>

{collections.sections.map((section) => (
Expand All @@ -214,39 +245,7 @@ export default function CollectionsWithSections ({ match, lang, subdomain }) {
<div>
<List>
{section.articles.map((article) => (
<ListItem
divider
key={`section-article-${article.id}`}
>
<ListItemText
primary={
<div className="flex flex-col">
<Link
className="text-lg mb-2 leading-6 font-bold text-gray-900"
color={'primary'}
to={`/${lang}/articles/${article.slug}`}
>
{translation(article.title)}
</Link>

<div className="flex items-center">
<Avatar
variant="small"
alt={article.author.displayName}
src={article.author.avatarUrl}
/>
<p className="ml-4">
written by{' '}
<strong>
{article.author.displayName}
</strong>
</p>
</div>
</div>
}
secondary={article.description}
/>
</ListItem>
renderArticles(article, 'section-articles' )
))}
</List>
</div>
Expand Down
2 changes: 2 additions & 0 deletions app/models/app_package_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class AppPackageIntegration < ApplicationRecord

validate do
app_package.definitions.each do |definition|
next unless definition[:required]

key = definition[:name].to_sym
next unless self.class.stored_attributes[:settings].include?(key)

Expand Down
2 changes: 1 addition & 1 deletion app/services/message_apis/base_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def trigger(event); end
def process_event(params, package); end

def enqueue_process_event(params, package)
HookMessageReceiverJob.perform_now(
HookMessageReceiverJob.perform_later(
id: package.id,
params: params.permit!.to_h
)
Expand Down
4 changes: 1 addition & 3 deletions app/services/message_apis/inbox_sections/presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ def self.initialize_hook(kind:, ctx:)
type_value = ctx.dig(:values, :type)
block_type = ctx.dig(:values, :block_type)

puts "AAAAA #{ctx}"

if type_value === 'content'

# case ctx.dig(:values, :block_type)
Expand Down Expand Up @@ -210,7 +208,7 @@ def self.content_hook(kind:, ctx:)
definitions = [
{
type: 'text',
text: user.display_name,
text: user.display_name.empty? ? '---' : user.display_name,
style: 'header',
align: 'center'
},
Expand Down
4 changes: 2 additions & 2 deletions config/locales/af.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ af:
en: English
es: Spanish
pt: Portuguese
redirecting: Redirecting
select_language: Select Language
redirecting: Redirecting
select_language: Select Language
send_on_enter: Publish on enter
home:
welcome: Welcome to
Expand Down
4 changes: 2 additions & 2 deletions config/locales/ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ ar:
en: English
es: Spanish
pt: Portuguese
redirecting: Redirecting
select_language: Select Language
redirecting: Redirecting
select_language: Select Language
send_on_enter: Publish on enter
home:
welcome: Welcome to
Expand Down
4 changes: 2 additions & 2 deletions config/locales/ca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ ca:
en: English
es: Spanish
pt: Portuguese
redirecting: Redirecting
select_language: Select Language
redirecting: Redirecting
select_language: Select Language
send_on_enter: Publish on enter
home:
welcome: Welcome to
Expand Down
Loading

0 comments on commit cca8a14

Please sign in to comment.