Merge branch 'develop' into feat-macros-frontend
This commit is contained in:
commit
3685ca1091
22 changed files with 91 additions and 10 deletions
|
@ -135,7 +135,7 @@ GEM
|
||||||
byebug (11.1.3)
|
byebug (11.1.3)
|
||||||
climate_control (1.1.1)
|
climate_control (1.1.1)
|
||||||
coderay (1.1.3)
|
coderay (1.1.3)
|
||||||
commonmarker (0.23.5)
|
commonmarker (0.23.6)
|
||||||
concurrent-ruby (1.1.10)
|
concurrent-ruby (1.1.10)
|
||||||
connection_pool (2.2.5)
|
connection_pool (2.2.5)
|
||||||
crack (0.4.5)
|
crack (0.4.5)
|
||||||
|
|
|
@ -16,7 +16,9 @@ class Api::V1::Accounts::MacrosController < Api::V1::Accounts::BaseController
|
||||||
@macro.save!
|
@macro.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
def show; end
|
def show
|
||||||
|
head :not_found if @macro.nil?
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@macro.destroy!
|
@macro.destroy!
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
class Public::Api::V1::PortalsController < PublicController
|
class Public::Api::V1::PortalsController < PublicController
|
||||||
before_action :ensure_custom_domain_request, only: [:show]
|
before_action :ensure_custom_domain_request, only: [:show]
|
||||||
before_action :portal
|
before_action :portal
|
||||||
|
before_action :redirect_to_portal_with_locale, only: [:show]
|
||||||
layout 'portal'
|
layout 'portal'
|
||||||
|
|
||||||
def show; end
|
def show; end
|
||||||
|
@ -9,5 +10,12 @@ class Public::Api::V1::PortalsController < PublicController
|
||||||
|
|
||||||
def portal
|
def portal
|
||||||
@portal ||= Portal.find_by!(slug: params[:slug], archived: false)
|
@portal ||= Portal.find_by!(slug: params[:slug], archived: false)
|
||||||
|
@locale = params[:locale] || @portal.default_locale
|
||||||
|
end
|
||||||
|
|
||||||
|
def redirect_to_portal_with_locale
|
||||||
|
return if params[:locale].present?
|
||||||
|
|
||||||
|
redirect_to "/hc/#{@portal.slug}/#{@portal.default_locale}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -188,6 +188,10 @@ export default {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
message() {
|
message() {
|
||||||
|
if (this.contentType === 'input_csat') {
|
||||||
|
return this.$t('CONVERSATION.CSAT_REPLY_MESSAGE');
|
||||||
|
}
|
||||||
|
|
||||||
// If the message is an email, emailMessageContent would be present
|
// If the message is an email, emailMessageContent would be present
|
||||||
// In that case, we would use letter package to render the email
|
// In that case, we would use letter package to render the email
|
||||||
if (this.emailMessageContent && this.isIncoming) {
|
if (this.emailMessageContent && this.isIncoming) {
|
||||||
|
|
|
@ -4,7 +4,12 @@ export const buildPortalURL = portalSlug => {
|
||||||
return `${baseURL}/hc/${portalSlug}`;
|
return `${baseURL}/hc/${portalSlug}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const buildPortalArticleURL = (portalSlug, categorySlug, articleId) => {
|
export const buildPortalArticleURL = (
|
||||||
|
portalSlug,
|
||||||
|
categorySlug,
|
||||||
|
locale,
|
||||||
|
articleId
|
||||||
|
) => {
|
||||||
const portalURL = buildPortalURL(portalSlug);
|
const portalURL = buildPortalURL(portalSlug);
|
||||||
return `${portalURL}/${categorySlug}/${articleId}`;
|
return `${portalURL}/${locale}/${categorySlug}/${articleId}`;
|
||||||
};
|
};
|
||||||
|
|
29
app/javascript/dashboard/helper/specs/portalHelper.spec.js
Normal file
29
app/javascript/dashboard/helper/specs/portalHelper.spec.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import { buildPortalArticleURL, buildPortalURL } from '../portalHelper';
|
||||||
|
|
||||||
|
describe('PortalHelper', () => {
|
||||||
|
describe('buildPortalURL', () => {
|
||||||
|
it('returns the correct url', () => {
|
||||||
|
window.chatwootConfig = {
|
||||||
|
hostURL: 'https://app.chatwoot.com',
|
||||||
|
helpCenterURL: 'https://help.chatwoot.com',
|
||||||
|
};
|
||||||
|
expect(buildPortalURL('handbook')).toEqual(
|
||||||
|
'https://help.chatwoot.com/hc/handbook'
|
||||||
|
);
|
||||||
|
window.chatwootConfig = {};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('buildPortalArticleURL', () => {
|
||||||
|
it('returns the correct url', () => {
|
||||||
|
window.chatwootConfig = {
|
||||||
|
hostURL: 'https://app.chatwoot.com',
|
||||||
|
helpCenterURL: 'https://help.chatwoot.com',
|
||||||
|
};
|
||||||
|
expect(buildPortalArticleURL('handbook', 'culture', 'fr', 1)).toEqual(
|
||||||
|
'https://help.chatwoot.com/hc/handbook/fr/culture/1'
|
||||||
|
);
|
||||||
|
window.chatwootConfig = {};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"CONVERSATION": {
|
"CONVERSATION": {
|
||||||
"SELECT_A_CONVERSATION": "Please select a conversation from left pane",
|
"SELECT_A_CONVERSATION": "Please select a conversation from left pane",
|
||||||
|
"CSAT_REPLY_MESSAGE": "Please rate the conversation",
|
||||||
"404": "Sorry, we cannot find the conversation. Please try again",
|
"404": "Sorry, we cannot find the conversation. Please try again",
|
||||||
"SWITCH_VIEW_LAYOUT": "Switch the layout",
|
"SWITCH_VIEW_LAYOUT": "Switch the layout",
|
||||||
"DASHBOARD_APP_TAB_MESSAGES": "Messages",
|
"DASHBOARD_APP_TAB_MESSAGES": "Messages",
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="edit-article--container">
|
<div class="edit-article--container">
|
||||||
<input
|
<resizable-text-area
|
||||||
v-model="articleTitle"
|
v-model="articleTitle"
|
||||||
type="text"
|
type="text"
|
||||||
|
rows="1"
|
||||||
class="article-heading"
|
class="article-heading"
|
||||||
:placeholder="$t('HELP_CENTER.EDIT_ARTICLE.TITLE_PLACEHOLDER')"
|
:placeholder="$t('HELP_CENTER.EDIT_ARTICLE.TITLE_PLACEHOLDER')"
|
||||||
@focus="onFocus"
|
@focus="onFocus"
|
||||||
|
@ -23,11 +24,13 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { debounce } from '@chatwoot/utils';
|
import { debounce } from '@chatwoot/utils';
|
||||||
|
import ResizableTextArea from 'shared/components/ResizableTextArea';
|
||||||
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor.vue';
|
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
WootMessageEditor,
|
WootMessageEditor,
|
||||||
|
ResizableTextArea,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
article: {
|
article: {
|
||||||
|
@ -83,7 +86,8 @@ export default {
|
||||||
font-size: var(--font-size-giga);
|
font-size: var(--font-size-giga);
|
||||||
font-weight: var(--font-weight-bold);
|
font-weight: var(--font-weight-bold);
|
||||||
min-height: var(--space-jumbo);
|
min-height: var(--space-jumbo);
|
||||||
max-height: var(--space-jumbo);
|
max-height: 64rem;
|
||||||
|
height: auto;
|
||||||
border: 0px solid transparent;
|
border: 0px solid transparent;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
color: var(--s-900);
|
color: var(--s-900);
|
||||||
|
|
|
@ -90,6 +90,7 @@ export default {
|
||||||
return buildPortalArticleURL(
|
return buildPortalArticleURL(
|
||||||
slug,
|
slug,
|
||||||
this.article.category.slug,
|
this.article.category.slug,
|
||||||
|
this.article.category.locale,
|
||||||
this.article.id
|
this.article.id
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -149,6 +149,7 @@ export default {
|
||||||
.container {
|
.container {
|
||||||
padding: 0 var(--space-normal);
|
padding: 0 var(--space-normal);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
overflow: auto;
|
||||||
.articles--loader {
|
.articles--loader {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -126,5 +126,6 @@ export default {
|
||||||
}
|
}
|
||||||
.is-sidebar-open {
|
.is-sidebar-open {
|
||||||
flex: 0.7;
|
flex: 0.7;
|
||||||
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -11,4 +11,12 @@ class ApplicationRecord < ActiveRecord::Base
|
||||||
|
|
||||||
"#{self.class.name}Drop".constantize.new(self)
|
"#{self.class.name}Drop".constantize.new(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def normalize_empty_string_to_nil(attrs = [])
|
||||||
|
attrs.each do |attr|
|
||||||
|
self[attr] = nil if self[attr].blank?
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,6 +38,7 @@ class Portal < ApplicationRecord
|
||||||
source: :user
|
source: :user
|
||||||
has_one_attached :logo
|
has_one_attached :logo
|
||||||
|
|
||||||
|
before_validation -> { normalize_empty_string_to_nil(%i[custom_domain homepage_link]) }
|
||||||
validates :account_id, presence: true
|
validates :account_id, presence: true
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
validates :slug, presence: true, uniqueness: true
|
validates :slug, presence: true, uniqueness: true
|
||||||
|
|
|
@ -10,6 +10,7 @@ json.category do
|
||||||
json.id article.category_id
|
json.id article.category_id
|
||||||
json.name article.category.name
|
json.name article.category.name
|
||||||
json.slug article.category.slug
|
json.slug article.category.slug
|
||||||
|
json.locale article.category.locale
|
||||||
end
|
end
|
||||||
|
|
||||||
if article.portal.present?
|
if article.portal.present?
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% category.articles.published.take(5).each do |article| %>
|
<% category.articles.published.take(5).each do |article| %>
|
||||||
<div class="flex justify-between content-center h-8 my-1">
|
<div class="flex justify-between content-center my-1">
|
||||||
<a
|
<a
|
||||||
class="text-slate-800 hover:underline leading-8"
|
class="text-slate-800 hover:underline leading-8"
|
||||||
href="/hc/<%= portal.slug %>/<%= category.locale %>/<%= category.slug %>/<%= article.id %>"
|
href="/hc/<%= portal.slug %>/<%= category.locale %>/<%= category.slug %>/<%= article.id %>"
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<% if @portal.config["allowed_locales"].length > 1 %>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<div class="inline-flex relative w-24">
|
<div class="inline-flex relative w-24">
|
||||||
<select
|
<select
|
||||||
|
@ -32,5 +33,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<%= render "public/api/v1/portals/hero", portal: @portal %>
|
<%= render "public/api/v1/portals/hero", portal: @portal %>
|
||||||
<div class="max-w-5xl w-full flex-grow mx-auto py-8 px-4">
|
<div class="max-w-5xl w-full flex-grow mx-auto py-8 px-4">
|
||||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-x-32 gap-y-0 lg:gap-y-12">
|
<div class="grid grid-cols-1 lg:grid-cols-2 gap-x-32 gap-y-0 lg:gap-y-12">
|
||||||
<% @portal.categories.where(locale: params[:locale]).each do |category| %>
|
<% @portal.categories.where(locale: @locale).each do |category| %>
|
||||||
<%= render "public/api/v1/portals/category-block", category: category, portal: @portal %>
|
<%= render "public/api/v1/portals/category-block", category: category, portal: @portal %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
shared: &shared
|
shared: &shared
|
||||||
version: '2.9.0'
|
version: '2.9.1'
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *shared
|
<<: *shared
|
||||||
|
|
|
@ -287,6 +287,7 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get 'hc/:slug', to: 'public/api/v1/portals#show'
|
||||||
get 'hc/:slug/:locale', to: 'public/api/v1/portals#show'
|
get 'hc/:slug/:locale', to: 'public/api/v1/portals#show'
|
||||||
get 'hc/:slug/:locale/categories', to: 'public/api/v1/portals/categories#index'
|
get 'hc/:slug/:locale/categories', to: 'public/api/v1/portals/categories#index'
|
||||||
get 'hc/:slug/:locale/:category_slug', to: 'public/api/v1/portals/categories#show'
|
get 'hc/:slug/:locale/:category_slug', to: 'public/api/v1/portals/categories#show'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@chatwoot/chatwoot",
|
"name": "@chatwoot/chatwoot",
|
||||||
"version": "2.9.0",
|
"version": "2.9.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"eslint": "eslint app/**/*.{js,vue}",
|
"eslint": "eslint app/**/*.{js,vue}",
|
||||||
|
|
|
@ -173,6 +173,13 @@ RSpec.describe 'Api::V1::Accounts::MacrosController', type: :request do
|
||||||
expect(json_response['payload']['name']).to eql(macro.name)
|
expect(json_response['payload']['name']).to eql(macro.name)
|
||||||
expect(json_response['payload']['created_by']['id']).to eql(administrator.id)
|
expect(json_response['payload']['created_by']['id']).to eql(administrator.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'return not_found status when macros not available' do
|
||||||
|
get "/api/v1/accounts/#{account.id}/macros/15",
|
||||||
|
headers: administrator.create_new_auth_token
|
||||||
|
|
||||||
|
expect(response).to have_http_status(:not_found)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,11 @@ RSpec.describe Portal, type: :model do
|
||||||
expect(portal).not_to be_valid
|
expect(portal).not_to be_valid
|
||||||
expect(portal.errors.full_messages[0]).to eq('Cofig in portal on some_other_key is not supported.')
|
expect(portal.errors.full_messages[0]).to eq('Cofig in portal on some_other_key is not supported.')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'converts empty string to nil' do
|
||||||
|
portal.update(custom_domain: '')
|
||||||
|
expect(portal.custom_domain).to be_nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue