chore: Use feature_flags attribute instead of settings_flags (#6820)

* chore: Use feature_flag instead of settings_flag

* Remove unnecessary changes
This commit is contained in:
Pranav Raj S
2023-04-04 09:56:58 -07:00
committed by GitHub
parent b7d0016d99
commit ebd5fbef17
7 changed files with 31 additions and 18 deletions

View File

@@ -39,12 +39,12 @@
<label v-if="featureInboundEmailEnabled"> <label v-if="featureInboundEmailEnabled">
{{ $t('GENERAL_SETTINGS.FORM.FEATURES.INBOUND_EMAIL_ENABLED') }} {{ $t('GENERAL_SETTINGS.FORM.FEATURES.INBOUND_EMAIL_ENABLED') }}
</label> </label>
<label v-if="featureCustomDomainEmailEnabled"> <label v-if="featureCustomReplyDomainEnabled">
{{ {{
$t('GENERAL_SETTINGS.FORM.FEATURES.CUSTOM_EMAIL_DOMAIN_ENABLED') $t('GENERAL_SETTINGS.FORM.FEATURES.CUSTOM_EMAIL_DOMAIN_ENABLED')
}} }}
</label> </label>
<label v-if="featureCustomDomainEmailEnabled"> <label v-if="featureCustomReplyDomainEnabled">
{{ $t('GENERAL_SETTINGS.FORM.DOMAIN.LABEL') }} {{ $t('GENERAL_SETTINGS.FORM.DOMAIN.LABEL') }}
<input <input
v-model="domain" v-model="domain"
@@ -52,7 +52,7 @@
:placeholder="$t('GENERAL_SETTINGS.FORM.DOMAIN.PLACEHOLDER')" :placeholder="$t('GENERAL_SETTINGS.FORM.DOMAIN.PLACEHOLDER')"
/> />
</label> </label>
<label v-if="featureCustomDomainEmailEnabled"> <label v-if="featureCustomReplyEmailEnabled">
{{ $t('GENERAL_SETTINGS.FORM.SUPPORT_EMAIL.LABEL') }} {{ $t('GENERAL_SETTINGS.FORM.SUPPORT_EMAIL.LABEL') }}
<input <input
v-model="supportEmail" v-model="supportEmail"
@@ -192,8 +192,16 @@ export default {
return !!this.features.inbound_emails; return !!this.features.inbound_emails;
}, },
featureCustomDomainEmailEnabled() { featureCustomReplyDomainEnabled() {
return this.featureInboundEmailEnabled && !!this.customEmailDomainEnabled; return (
this.featureInboundEmailEnabled && !!this.features.custom_reply_domain
);
},
featureCustomReplyEmailEnabled() {
return (
this.featureInboundEmailEnabled && !!this.features.custom_reply_email
);
}, },
getAccountId() { getAccountId() {
@@ -215,7 +223,6 @@ export default {
id, id,
domain, domain,
support_email, support_email,
custom_email_domain_enabled,
features, features,
auto_resolve_duration, auto_resolve_duration,
latest_chatwoot_version: latestChatwootVersion, latest_chatwoot_version: latestChatwootVersion,
@@ -227,7 +234,6 @@ export default {
this.id = id; this.id = id;
this.domain = domain; this.domain = domain;
this.supportEmail = support_email; this.supportEmail = support_email;
this.customEmailDomainEnabled = custom_email_domain_enabled;
this.features = features; this.features = features;
this.autoResolveDuration = auto_resolve_duration; this.autoResolveDuration = auto_resolve_duration;
this.latestChatwootVersion = latestChatwootVersion; this.latestChatwootVersion = latestChatwootVersion;

View File

@@ -10,7 +10,6 @@
# limits :jsonb # limits :jsonb
# locale :integer default("en") # locale :integer default("en")
# name :string not null # name :string not null
# settings_flags :integer default(0), not null
# status :integer default("active") # status :integer default("active")
# support_email :string(100) # support_email :string(100)
# created_at :datetime not null # created_at :datetime not null
@@ -33,10 +32,6 @@ class Account < ApplicationRecord
check_for_column: false check_for_column: false
}.freeze }.freeze
ACCOUNT_SETTINGS_FLAGS = {
1 => :custom_email_domain_enabled
}.freeze
validates :name, presence: true validates :name, presence: true
validates :auto_resolve_duration, numericality: { greater_than_or_equal_to: 1, less_than_or_equal_to: 999, allow_nil: true } validates :auto_resolve_duration, numericality: { greater_than_or_equal_to: 1, less_than_or_equal_to: 999, allow_nil: true }
validates :name, length: { maximum: 255 } validates :name, length: { maximum: 255 }
@@ -82,8 +77,6 @@ class Account < ApplicationRecord
has_many :whatsapp_channels, dependent: :destroy_async, class_name: '::Channel::Whatsapp' has_many :whatsapp_channels, dependent: :destroy_async, class_name: '::Channel::Whatsapp'
has_many :working_hours, dependent: :destroy_async has_many :working_hours, dependent: :destroy_async
has_flags ACCOUNT_SETTINGS_FLAGS.merge(column: 'settings_flags').merge(DEFAULT_QUERY_SETTING)
enum locale: LANGUAGES_CONFIG.map { |key, val| [val[:iso_639_1_code], key] }.to_h enum locale: LANGUAGES_CONFIG.map { |key, val| [val[:iso_639_1_code], key] }.to_h
enum status: { active: 0, suspended: 1 } enum status: { active: 0, suspended: 1 }

View File

@@ -6,7 +6,6 @@ if resource.custom_attributes.present?
json.subscribed_quantity resource.custom_attributes['subscribed_quantity'] json.subscribed_quantity resource.custom_attributes['subscribed_quantity']
end end
end end
json.custom_email_domain_enabled @account.custom_email_domain_enabled
json.domain @account.domain json.domain @account.domain
json.features @account.enabled_features json.features @account.enabled_features
json.id @account.id json.id @account.id

View File

@@ -49,3 +49,7 @@
enabled: true enabled: true
- name: auto_resolve_conversations - name: auto_resolve_conversations
enabled: true enabled: true
- name: custom_reply_email
enabled: false
- name: custom_reply_domain
enabled: false

View File

@@ -0,0 +1,13 @@
class RemoveSettingsFlagsFromAccount < ActiveRecord::Migration[6.1]
def up
change_table :accounts do |t|
t.remove :settings_flags
end
end
def down
change_table :accounts do |t|
t.integer :settings_flags, default: 0, null: false
end
end
end

View File

@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2023_03_28_131926) do ActiveRecord::Schema.define(version: 2023_04_04_030719) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements" enable_extension "pg_stat_statements"
@@ -50,7 +50,6 @@ ActiveRecord::Schema.define(version: 2023_03_28_131926) do
t.integer "locale", default: 0 t.integer "locale", default: 0
t.string "domain", limit: 100 t.string "domain", limit: 100
t.string "support_email", limit: 100 t.string "support_email", limit: 100
t.integer "settings_flags", default: 0, null: false
t.integer "feature_flags", default: 0, null: false t.integer "feature_flags", default: 0, null: false
t.integer "auto_resolve_duration" t.integer "auto_resolve_duration"
t.jsonb "limits", default: {} t.jsonb "limits", default: {}

View File

@@ -4,7 +4,6 @@ FactoryBot.define do
factory :account do factory :account do
sequence(:name) { |n| "Account #{n}" } sequence(:name) { |n| "Account #{n}" }
status { 'active' } status { 'active' }
custom_email_domain_enabled { false }
domain { 'test.com' } domain { 'test.com' }
support_email { 'support@test.com' } support_email { 'support@test.com' }
end end