mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 02:57:57 +00:00 
			
		
		
		
	Chore: Feature Flags for Channels (#1010)
This commit is contained in:
		| @@ -40,10 +40,23 @@ export default { | |||||||
|       type: String, |       type: String, | ||||||
|       required: true, |       required: true, | ||||||
|     }, |     }, | ||||||
|  |     enabledFeatures: { | ||||||
|  |       type: Object, | ||||||
|  |       required: true, | ||||||
|  |     }, | ||||||
|   }, |   }, | ||||||
|   methods: { |   methods: { | ||||||
|     isActive(channel) { |     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() { |     onItemClick() { | ||||||
|       if (this.isActive(this.channel)) { |       if (this.isActive(this.channel)) { | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ | |||||||
|         v-for="channel in channelList" |         v-for="channel in channelList" | ||||||
|         :key="channel" |         :key="channel" | ||||||
|         :channel="channel" |         :channel="channel" | ||||||
|  |         :enabled-features="enabledFeatures" | ||||||
|         @channel-item-click="initChannelAuth" |         @channel-item-click="initChannelAuth" | ||||||
|       /> |       /> | ||||||
|     </div> |     </div> | ||||||
| @@ -19,6 +20,7 @@ | |||||||
| import ChannelItem from 'dashboard/components/widgets/ChannelItem'; | import ChannelItem from 'dashboard/components/widgets/ChannelItem'; | ||||||
| import router from '../../../index'; | import router from '../../../index'; | ||||||
| import PageHeader from '../SettingsSubPageHeader'; | import PageHeader from '../SettingsSubPageHeader'; | ||||||
|  | import { mapGetters } from 'vuex'; | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|   components: { |   components: { | ||||||
| @@ -35,9 +37,25 @@ export default { | |||||||
|         'telegram', |         'telegram', | ||||||
|         'line', |         'line', | ||||||
|       ], |       ], | ||||||
|  |       enabledFeatures: {}, | ||||||
|     }; |     }; | ||||||
|   }, |   }, | ||||||
|  |   computed: { | ||||||
|  |     account() { | ||||||
|  |       return this.$store.getters['accounts/getAccount'](this.accountId); | ||||||
|  |     }, | ||||||
|  |     ...mapGetters({ | ||||||
|  |       accountId: 'getCurrentAccountId', | ||||||
|  |     }), | ||||||
|  |   }, | ||||||
|  |   mounted() { | ||||||
|  |     this.initializeEnabledFeatures(); | ||||||
|  |   }, | ||||||
|   methods: { |   methods: { | ||||||
|  |     async initializeEnabledFeatures() { | ||||||
|  |       await this.$store.dispatch('accounts/get', this.accountId); | ||||||
|  |       this.enabledFeatures = this.account.features; | ||||||
|  |     }, | ||||||
|     initChannelAuth(channel) { |     initChannelAuth(channel) { | ||||||
|       const params = { |       const params = { | ||||||
|         page: 'new', |         page: 'new', | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ | |||||||
| # Table name: users | # Table name: users | ||||||
| # | # | ||||||
| #  id                     :integer          not null, primary key | #  id                     :integer          not null, primary key | ||||||
| #  availability           :integer          default(0) | #  availability           :integer          default("online") | ||||||
| #  confirmation_sent_at   :datetime | #  confirmation_sent_at   :datetime | ||||||
| #  confirmation_token     :string | #  confirmation_token     :string | ||||||
| #  confirmed_at           :datetime | #  confirmed_at           :datetime | ||||||
|   | |||||||
| @@ -4,4 +4,4 @@ json.locale @account.locale | |||||||
| json.domain @account.domain | json.domain @account.domain | ||||||
| json.domain_emails_enabled @account.domain_emails_enabled | json.domain_emails_enabled @account.domain_emails_enabled | ||||||
| json.support_email @account.support_email | json.support_email @account.support_email | ||||||
| json.features @account.enabled_features | json.features @account.all_features | ||||||
|   | |||||||
| @@ -5,4 +5,5 @@ | |||||||
|   enabled: false |   enabled: false | ||||||
| - name: channel_facebook | - name: channel_facebook | ||||||
|   enabled: true |   enabled: true | ||||||
|  | - name: channel_twitter | ||||||
|  |   enabled: true | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								db/migrate/20200704173104_add_twitter_feature_flag.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								db/migrate/20200704173104_add_twitter_feature_flag.rb
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | |||||||
|  | class AddTwitterFeatureFlag < ActiveRecord::Migration[6.0] | ||||||
|  |   def change | ||||||
|  |     ConfigLoader.new.process | ||||||
|  |   end | ||||||
|  | end | ||||||
| @@ -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: 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 |   # These are extensions that must be enabled in order to support this database | ||||||
|   enable_extension "pg_stat_statements" |   enable_extension "pg_stat_statements" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sojan Jose
					Sojan Jose