chore: Add ee helper, custom_attributes to account (#5058)
This commit is contained in:
@@ -15,6 +15,11 @@ class ApiClient {
|
||||
|
||||
baseUrl() {
|
||||
let url = this.apiVersion;
|
||||
|
||||
if (this.options.enterprise) {
|
||||
url = `/enterprise${url}`;
|
||||
}
|
||||
|
||||
if (this.options.accountScoped) {
|
||||
const isInsideAccountScopedURLs = window.location.pathname.includes(
|
||||
'/app/accounts'
|
||||
|
||||
@@ -5,7 +5,7 @@ import InboxesAPI from '../../api/inboxes';
|
||||
import WebChannel from '../../api/channel/webChannel';
|
||||
import FBChannel from '../../api/channel/fbChannel';
|
||||
import TwilioChannel from '../../api/channel/twilioChannel';
|
||||
import { parseAPIErrorResponse } from '../utils/api';
|
||||
import { throwErrorMessage } from '../utils/api';
|
||||
|
||||
const buildInboxData = inboxParams => {
|
||||
const formData = new FormData();
|
||||
@@ -43,11 +43,6 @@ export const state = {
|
||||
},
|
||||
};
|
||||
|
||||
const throwErrorMessage = error => {
|
||||
const errorMessage = parseAPIErrorResponse(error);
|
||||
throw new Error(errorMessage);
|
||||
};
|
||||
|
||||
export const getters = {
|
||||
getInboxes($state) {
|
||||
return $state.records;
|
||||
|
||||
@@ -55,3 +55,8 @@ export const parseAPIErrorResponse = error => {
|
||||
}
|
||||
return error;
|
||||
};
|
||||
|
||||
export const throwErrorMessage = error => {
|
||||
const errorMessage = parseAPIErrorResponse(error);
|
||||
throw new Error(errorMessage);
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
getLoadingStatus,
|
||||
parseAPIErrorResponse,
|
||||
setLoadingStatus,
|
||||
throwErrorMessage,
|
||||
} from '../api';
|
||||
|
||||
describe('#getLoadingStatus', () => {
|
||||
@@ -37,3 +38,14 @@ describe('#parseAPIErrorResponse', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#throwErrorMessage', () => {
|
||||
it('throws correct error', () => {
|
||||
const errorFn = function throwErrorMessageFn() {
|
||||
throwErrorMessage({
|
||||
response: { data: { message: 'Error Message [message]' } },
|
||||
});
|
||||
};
|
||||
expect(errorFn).toThrow('Error Message [message]');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# auto_resolve_duration :integer
|
||||
# custom_attributes :jsonb
|
||||
# domain :string(100)
|
||||
# feature_flags :integer default(0), not null
|
||||
# limits :jsonb
|
||||
|
||||
@@ -1,9 +1,2 @@
|
||||
json.id @account.id
|
||||
json.name @account.name
|
||||
json.locale @account.locale
|
||||
json.domain @account.domain
|
||||
json.custom_email_domain_enabled @account.custom_email_domain_enabled
|
||||
json.support_email @account.support_email
|
||||
json.features @account.all_features
|
||||
json.auto_resolve_duration @account.auto_resolve_duration
|
||||
json.partial! 'api/v1/models/account.json.jbuilder', resource: @account
|
||||
json.latest_chatwoot_version @latest_chatwoot_version
|
||||
|
||||
@@ -1,7 +1 @@
|
||||
json.id @account.id
|
||||
json.name @account.name
|
||||
json.locale @account.locale
|
||||
json.domain @account.domain
|
||||
json.custom_email_domain_enabled @account.custom_email_domain_enabled
|
||||
json.support_email @account.support_email
|
||||
json.features @account.enabled_features
|
||||
json.partial! 'api/v1/models/account.json.jbuilder', resource: @account
|
||||
|
||||
10
app/views/api/v1/models/_account.json.jbuilder
Normal file
10
app/views/api/v1/models/_account.json.jbuilder
Normal file
@@ -0,0 +1,10 @@
|
||||
json.auto_resolve_duration resource.auto_resolve_duration
|
||||
json.created_at resource.created_at
|
||||
json.custom_attributes resource.custom_attributes
|
||||
json.custom_email_domain_enabled @account.custom_email_domain_enabled
|
||||
json.domain @account.domain
|
||||
json.features @account.enabled_features
|
||||
json.id @account.id
|
||||
json.locale @account.locale
|
||||
json.name @account.name
|
||||
json.support_email @account.support_email
|
||||
Reference in New Issue
Block a user