Skip to content

Commit

Permalink
Merge branch 'release/3.15.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sojan-official committed Nov 19, 2024
2 parents 622f29a + 7d9800d commit 959d2c0
Show file tree
Hide file tree
Showing 310 changed files with 14,031 additions and 8,699 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ gem 'reverse_markdown'
group :production do
# we dont want request timing out in development while using byebug
gem 'rack-timeout'
# for heroku autoscaling
gem 'judoscale-rails', require: false
gem 'judoscale-sidekiq', require: false
end

group :development do
Expand Down
13 changes: 10 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,13 @@ GEM
hana (~> 1.3)
regexp_parser (~> 2.0)
uri_template (~> 0.7)
judoscale-rails (1.8.2)
judoscale-ruby (= 1.8.2)
railties
judoscale-ruby (1.8.2)
judoscale-sidekiq (1.8.2)
judoscale-ruby (= 1.8.2)
sidekiq (>= 5.0)
jwt (2.8.1)
base64
kaminari (1.2.2)
Expand Down Expand Up @@ -633,8 +640,7 @@ GEM
retriable (3.1.2)
reverse_markdown (2.1.1)
nokogiri
rexml (3.3.6)
strscan
rexml (3.3.9)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.2)
Expand Down Expand Up @@ -764,7 +770,6 @@ GEM
stackprof (0.2.25)
statsd-ruby (1.5.0)
stripe (8.5.0)
strscan (3.1.0)
telephone_number (1.4.20)
test-prof (1.2.1)
thor (1.3.1)
Expand Down Expand Up @@ -893,6 +898,8 @@ DEPENDENCIES
jbuilder
json_refs
json_schemer
judoscale-rails
judoscale-sidekiq
jwt
kaminari
koala
Expand Down
30 changes: 23 additions & 7 deletions app/controllers/api/v1/accounts/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController

def index
@portal_articles = @portal.articles
@all_articles = @portal_articles.search(list_params)
@articles_count = @all_articles.count

set_article_count

@articles = @articles.search(list_params)

@articles = if list_params[:category_slug].present?
@all_articles.order_by_position.page(@current_page)
@articles.order_by_position.page(@current_page)
else
@all_articles.order_by_updated_at.page(@current_page)
@articles.order_by_updated_at.page(@current_page)
end
end

Expand Down Expand Up @@ -43,6 +45,19 @@ def reorder

private

def set_article_count
# Search the params without status and author_id, use this to
# compute mine count published draft etc
base_search_params = list_params.except(:status, :author_id)
@articles = @portal_articles.search(base_search_params)

@articles_count = @articles.count
@mine_articles_count = @articles.search_by_author(Current.user.id).count
@published_articles_count = @articles.published.count
@draft_articles_count = @articles.draft.count
@archived_articles_count = @articles.archived.count
end

def fetch_article
@article = @portal.articles.find(params[:id])
end
Expand All @@ -53,9 +68,10 @@ def portal

def article_params
params.require(:article).permit(
:title, :slug, :position, :content, :description, :position, :category_id, :author_id, :associated_article_id, :status, meta: [:title,
:description,
{ tags: [] }]
:title, :slug, :position, :content, :description, :position, :category_id, :author_id, :associated_article_id, :status,
:locale, meta: [:title,
:description,
{ tags: [] }]
)
end

Expand Down
57 changes: 44 additions & 13 deletions app/controllers/api/v1/accounts/integrations/captain_controller.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,53 @@
class Api::V1::Accounts::Integrations::CaptainController < Api::V1::Accounts::BaseController
before_action :check_admin_authorization?
before_action :fetch_hook
before_action :hook

def sso_url
params_string =
"token=#{URI.encode_www_form_component(@hook['settings']['access_token'])}" \
"&email=#{URI.encode_www_form_component(@hook['settings']['account_email'])}" \
"&account_id=#{URI.encode_www_form_component(@hook['settings']['account_id'])}"
def proxy
response = HTTParty.send(request_method, request_url, body: permitted_params[:body].to_json, headers: headers)
render plain: response.body, status: response.code
end

installation_config = InstallationConfig.find_by(name: 'CAPTAIN_APP_URL')
private

sso_url = "#{installation_config.value}/sso?#{params_string}"
render json: { sso_url: sso_url }, status: :ok
def headers
{
'X-User-Email' => hook.settings['account_email'],
'X-User-Token' => hook.settings['access_token'],
'Content-Type' => 'application/json',
'Accept' => '*/*'
}
end

private
def request_path
request_route = with_leading_hash_on_route(params[:route])

return 'api/sessions/profile' if request_route == '/sessions/profile'

"api/accounts/#{hook.settings['account_id']}#{request_route}"
end

def request_url
base_url = InstallationConfig.find_by(name: 'CAPTAIN_API_URL').value
URI.join(base_url, request_path).to_s
end

def hook
@hook ||= Current.account.hooks.find_by!(app_id: 'captain')
end

def request_method
method = permitted_params[:method].downcase
raise 'Invalid or missing HTTP method' unless %w[get post put patch delete options head].include?(method)

method
end

def with_leading_hash_on_route(request_route)
return '' if request_route.blank?

request_route.start_with?('/') ? request_route : "/#{request_route}"
end

def fetch_hook
@hook = Current.account.hooks.find_by!(app_id: 'captain')
def permitted_params
params.permit(:method, :route, body: {})
end
end
18 changes: 14 additions & 4 deletions app/controllers/api/v1/accounts/portals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def show
end

def create
@portal = Current.account.portals.build(portal_params)
@portal = Current.account.portals.build(portal_params.merge(live_chat_widget_params))
@portal.custom_domain = parsed_custom_domain
@portal.save!
process_attached_logo
end

def update
ActiveRecord::Base.transaction do
@portal.update!(portal_params) if params[:portal].present?
@portal.update!(portal_params.merge(live_chat_widget_params)) if params[:portal].present?
# @portal.custom_domain = parsed_custom_domain
process_attached_logo if params[:blob_id].present?
rescue StandardError => e
Expand Down Expand Up @@ -70,11 +70,21 @@ def permitted_params

def portal_params
params.require(:portal).permit(
:account_id, :color, :custom_domain, :header_text, :homepage_link, :name, :page_title, :slug, :archived, { config: [:default_locale,
{ allowed_locales: [] }] }
:account_id, :color, :custom_domain, :header_text, :homepage_link,
:name, :page_title, :slug, :archived, { config: [:default_locale, { allowed_locales: [] }] }
)
end

def live_chat_widget_params
permitted_params = params.permit(:inbox_id)
return {} if permitted_params[:inbox_id].blank?

inbox = Inbox.find(permitted_params[:inbox_id])
return {} unless inbox.web_widget?

{ channel_web_widget_id: inbox.channel.id }
end

def portal_member_params
params.require(:portal).permit(:account_id, member_ids: [])
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def order_by_sort_param

def set_article
@article = @portal.articles.find_by(slug: permitted_params[:article_slug])
@article.increment_view_count
@article.increment_view_count if @article.published?
@parsed_content = render_article_content(@article.content)
end

Expand Down
7 changes: 4 additions & 3 deletions app/javascript/dashboard/api/helpCenter/articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ class ArticlesAPI extends PortalsAPI {
}

createArticle({ portalSlug, articleObj }) {
const { content, title, author_id, category_id } = articleObj;
const { content, title, authorId, categoryId, locale } = articleObj;
return axios.post(`${this.url}/${portalSlug}/articles`, {
content,
title,
author_id,
category_id,
author_id: authorId,
category_id: categoryId,
locale,
});
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/dashboard/api/integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class IntegrationsAPI extends ApiClient {
return axios.delete(`${this.baseUrl()}/integrations/hooks/${hookId}`);
}

fetchCaptainURL() {
return axios.get(`${this.baseUrl()}/integrations/captain/sso_url`);
requestCaptain(body) {
return axios.post(`${this.baseUrl()}/integrations/captain/proxy`, body);
}
}

Expand Down
74 changes: 48 additions & 26 deletions app/javascript/dashboard/assets/scss/_woot.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
@apply hidden;
}

.n-blue-border {
@apply border-n-blue-border;
}

.n-blue-text {
@apply text-n-blue-text;
}

// scss-lint:disable PropertySortOrder
@layer base {
/* NEXT COLORS START */
Expand Down Expand Up @@ -103,24 +111,25 @@
--teal-11: 0 133 115;
--teal-12: 13 61 56;

--background-color: 248 248 248;
--background-color: 253 253 253;
--text-blue: 8 109 224;
--border-container: 236 236 236;
--border-strong: 235 235 235;
--border-weak: 234 234 234;
--solid-1: 255 255 255;
--solid-2: 252 252 252;
--solid-2: 255 255 255;
--solid-3: 255 255 255;
--solid-active: 250 251 251;
--white-alpha: 255 255 255 0.1;
--border-weak: 231 231 231;
--border-strong: 235 235 235;
--amber-solid: 252 232 193;
--blue-solid: 218 236 255;
--blue: 39 129 246;

/* alpha is added by default */
--alpha-1: 36, 38, 48, 0.06;
--alpha-2: 130, 134, 150, 0.12;
--alpha-3: 255, 255, 255, 0.9;
--solid-active: 255 255 255;
--solid-amber: 252 232 193;
--solid-blue: 218 236 255;

--alpha-1: 67, 67, 67, 0.06;
--alpha-2: 201, 202, 207, 0.15;
--alpha-3: 255, 255, 255, 0.96;
--black-alpha-1: 0, 0, 0, 0.12;
--black-alpha-2: 0, 0, 0, 0.04;
--border-blue: 39, 129, 246, 0.5;
--white-alpha: 255, 255, 255, 0.1;
}

body.dark {
Expand Down Expand Up @@ -178,22 +187,23 @@
--teal-12: 173 240 221;

--background-color: 18 18 19;
--border-strong: 52 52 52;
--border-weak: 38 38 42;
--solid-1: 23 23 26;
--solid-2: 29 30 36;
--solid-3: 36 38 48;
--solid-active: 51 53 64;
--border-weak: 34 34 37;
--border-strong: 46 47 49;
--amber-solid: 42 37 30;
--blue-solid: 16 49 91;
--blue: 126 182 255;

/* alpha is added by default */
--alpha-1: 35, 37, 45, 0.8;
--alpha-2: 130, 134, 150, 0.15;
--alpha-3: 32, 33, 37, 0.9;
--solid-3: 44 45 54;
--solid-active: 53 57 66;
--solid-amber: 42 37 30;
--solid-blue: 16 49 91;
--text-blue: 126 182 255;

--alpha-1: 36, 36, 36, 0.8;
--alpha-2: 139, 147, 182, 0.15;
--alpha-3: 36, 38, 45, 0.9;
--black-alpha-1: 0, 0, 0, 0.3;
--black-alpha-2: 0, 0, 0, 0.2;
--border-blue: 39, 129, 246, 0.5;
--border-container: 236, 236, 236, 0;
--white-alpha: 255, 255, 255, 0.1;
}
/* NEXT COLORS END */
Expand Down Expand Up @@ -540,3 +550,15 @@
--color-orange-900: 255 224 194;
}
}

@layer utilities {
/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
}
8 changes: 7 additions & 1 deletion app/javascript/dashboard/assets/scss/widgets/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ hr {
ul,
ol,
dl {
@apply mb-2 list-disc list-outside leading-[1.65];
@apply list-disc list-outside leading-[1.65];
}

ul:not(.reset-base),
ol:not(.reset-base),
dl:not(.reset-base) {
@apply mb-0;
}

// Form elements
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/dashboard/assets/scss/widgets/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ button {
}

// @TODDO - Remove after moving all buttons to woot-button
.icon+.button__content {
.icon + .button__content {
@apply w-auto;
}

Expand Down
Loading

0 comments on commit 959d2c0

Please sign in to comment.