diff --git a/app/javascript/dashboard/components/widgets/ChannelItem.vue b/app/javascript/dashboard/components/widgets/ChannelItem.vue index 948bff103..bd4636fd8 100644 --- a/app/javascript/dashboard/components/widgets/ChannelItem.vue +++ b/app/javascript/dashboard/components/widgets/ChannelItem.vue @@ -40,10 +40,23 @@ export default { type: String, required: true, }, + enabledFeatures: { + type: Object, + required: true, + }, }, methods: { isActive(channel) { - return ['facebook', 'website', 'twitter', 'twilio'].includes(channel); + if (Object.keys(this.enabledFeatures) === 0) { + return false; + } + if (channel === 'facebook') { + return this.enabledFeatures.channel_facebook; + } + if (channel === 'twitter') { + return this.enabledFeatures.channel_facebook; + } + return ['website', 'twilio'].includes(channel); }, onItemClick() { if (this.isActive(this.channel)) { diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/ChannelList.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/ChannelList.vue index 12bba91d3..a5db5a5c1 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/ChannelList.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/ChannelList.vue @@ -9,6 +9,7 @@ v-for="channel in channelList" :key="channel" :channel="channel" + :enabled-features="enabledFeatures" @channel-item-click="initChannelAuth" /> @@ -19,6 +20,7 @@ import ChannelItem from 'dashboard/components/widgets/ChannelItem'; import router from '../../../index'; import PageHeader from '../SettingsSubPageHeader'; +import { mapGetters } from 'vuex'; export default { components: { @@ -35,9 +37,25 @@ export default { 'telegram', 'line', ], + enabledFeatures: {}, }; }, + computed: { + account() { + return this.$store.getters['accounts/getAccount'](this.accountId); + }, + ...mapGetters({ + accountId: 'getCurrentAccountId', + }), + }, + mounted() { + this.initializeEnabledFeatures(); + }, methods: { + async initializeEnabledFeatures() { + await this.$store.dispatch('accounts/get', this.accountId); + this.enabledFeatures = this.account.features; + }, initChannelAuth(channel) { const params = { page: 'new', diff --git a/app/models/user.rb b/app/models/user.rb index b025fabea..6a1c53eed 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,7 +3,7 @@ # Table name: users # # id :integer not null, primary key -# availability :integer default(0) +# availability :integer default("online") # confirmation_sent_at :datetime # confirmation_token :string # confirmed_at :datetime diff --git a/app/views/api/v1/accounts/show.json.jbuilder b/app/views/api/v1/accounts/show.json.jbuilder index 26d1c640e..446d1accb 100644 --- a/app/views/api/v1/accounts/show.json.jbuilder +++ b/app/views/api/v1/accounts/show.json.jbuilder @@ -4,4 +4,4 @@ json.locale @account.locale json.domain @account.domain json.domain_emails_enabled @account.domain_emails_enabled json.support_email @account.support_email -json.features @account.enabled_features +json.features @account.all_features diff --git a/config/features.yml b/config/features.yml index 0ce1518a1..ab683e29a 100644 --- a/config/features.yml +++ b/config/features.yml @@ -5,4 +5,5 @@ enabled: false - name: channel_facebook enabled: true - +- name: channel_twitter + enabled: true diff --git a/db/migrate/20200704173104_add_twitter_feature_flag.rb b/db/migrate/20200704173104_add_twitter_feature_flag.rb new file mode 100644 index 000000000..047313d70 --- /dev/null +++ b/db/migrate/20200704173104_add_twitter_feature_flag.rb @@ -0,0 +1,5 @@ +class AddTwitterFeatureFlag < ActiveRecord::Migration[6.0] + def change + ConfigLoader.new.process + end +end diff --git a/db/schema.rb b/db/schema.rb index 6db971114..b6337dbcd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_06_29_122646) do +ActiveRecord::Schema.define(version: 2020_07_04_173104) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements"