refactor(app-config): remove canCustomConnect virtual attribute
This commit is contained in:
@@ -39,9 +39,3 @@ exports[`AppConfig model > jsonSchema should have correct validations 1`] = `
|
||||
"type": "object",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`AppConfig model > virtualAttributes should return correct properties 1`] = `
|
||||
[
|
||||
"canCustomConnect",
|
||||
]
|
||||
`;
|
||||
|
@@ -32,14 +32,6 @@ class AppConfig extends Base {
|
||||
},
|
||||
});
|
||||
|
||||
static get virtualAttributes() {
|
||||
return ['canCustomConnect'];
|
||||
}
|
||||
|
||||
get canCustomConnect() {
|
||||
return !this.disabled && this.allowCustomConnection;
|
||||
}
|
||||
|
||||
async getApp() {
|
||||
if (!this.key) return null;
|
||||
|
||||
|
@@ -36,14 +36,14 @@ describe('AppConfig model', () => {
|
||||
expect(AppConfig.virtualAttributes).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe('canCustomConnect', () => {
|
||||
describe('allowCustomConnection', () => {
|
||||
it('should return true when app is enabled and allows custom connection', async () => {
|
||||
const appConfig = await createAppConfig({
|
||||
disabled: false,
|
||||
allowCustomConnection: true,
|
||||
});
|
||||
|
||||
expect(appConfig.canCustomConnect).toBe(true);
|
||||
expect(appConfig.allowCustomConnection).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false when app is disabled', async () => {
|
||||
@@ -52,7 +52,7 @@ describe('AppConfig model', () => {
|
||||
allowCustomConnection: true,
|
||||
});
|
||||
|
||||
expect(appConfig.canCustomConnect).toBe(false);
|
||||
expect(appConfig.allowCustomConnection).toBe(false);
|
||||
});
|
||||
|
||||
it(`should return false when app doesn't allow custom connection`, async () => {
|
||||
@@ -61,7 +61,7 @@ describe('AppConfig model', () => {
|
||||
allowCustomConnection: false,
|
||||
});
|
||||
|
||||
expect(appConfig.canCustomConnect).toBe(false);
|
||||
expect(appConfig.allowCustomConnection).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -6,7 +6,6 @@ const appConfigSerializer = (appConfig) => {
|
||||
shared: appConfig.shared,
|
||||
disabled: appConfig.disabled,
|
||||
connectionAllowed: appConfig.connectionAllowed,
|
||||
canCustomConnect: appConfig.canCustomConnect,
|
||||
createdAt: appConfig.createdAt.getTime(),
|
||||
updatedAt: appConfig.updatedAt.getTime(),
|
||||
};
|
||||
|
@@ -17,7 +17,6 @@ describe('appConfig serializer', () => {
|
||||
shared: appConfig.shared,
|
||||
disabled: appConfig.disabled,
|
||||
connectionAllowed: appConfig.connectionAllowed,
|
||||
canCustomConnect: appConfig.canCustomConnect,
|
||||
createdAt: appConfig.createdAt.getTime(),
|
||||
updatedAt: appConfig.updatedAt.getTime(),
|
||||
};
|
||||
|
@@ -7,7 +7,6 @@ const getAppConfigMock = (appConfig) => {
|
||||
shared: appConfig.shared,
|
||||
disabled: appConfig.disabled,
|
||||
connectionAllowed: appConfig.connectionAllowed,
|
||||
canCustomConnect: appConfig.canCustomConnect,
|
||||
createdAt: appConfig.createdAt.getTime(),
|
||||
updatedAt: appConfig.updatedAt.getTime(),
|
||||
},
|
||||
|
@@ -93,7 +93,10 @@ function ChooseConnectionSubstep(props) {
|
||||
appWithConnections?.map((connection) => optionGenerator(connection)) ||
|
||||
[];
|
||||
|
||||
if (!appConfig?.data || appConfig?.data?.canCustomConnect) {
|
||||
if (
|
||||
!appConfig?.data ||
|
||||
(!appConfig.data?.disabled && appConfig.data?.allowCustomConnection)
|
||||
) {
|
||||
options.push({
|
||||
label: formatMessage('chooseConnectionSubstep.addNewConnection'),
|
||||
value: ADD_CONNECTION_VALUE,
|
||||
|
@@ -77,7 +77,8 @@ export default function Application() {
|
||||
|
||||
const connectionOptions = React.useMemo(() => {
|
||||
const shouldHaveCustomConnection =
|
||||
appConfig?.data?.connectionAllowed && appConfig?.data?.canCustomConnect;
|
||||
appConfig?.data?.connectionAllowed &&
|
||||
appConfig?.data?.allowCustomConnection;
|
||||
|
||||
const options = [
|
||||
{
|
||||
@@ -155,8 +156,9 @@ export default function Application() {
|
||||
disabled={
|
||||
!allowed ||
|
||||
(appConfig?.data &&
|
||||
!appConfig?.data?.disabled &&
|
||||
!appConfig?.data?.connectionAllowed &&
|
||||
!appConfig?.data?.canCustomConnect) ||
|
||||
!appConfig?.data?.allowCustomConnection) ||
|
||||
connectionOptions.every(({ disabled }) => disabled)
|
||||
}
|
||||
options={connectionOptions}
|
||||
|
@@ -461,7 +461,6 @@ export const AppConfigPropType = PropTypes.shape({
|
||||
key: PropTypes.string,
|
||||
allowCustomConnection: PropTypes.bool,
|
||||
connectionAllowed: PropTypes.bool,
|
||||
canCustomConnect: PropTypes.bool,
|
||||
shared: PropTypes.bool,
|
||||
disabled: PropTypes.bool,
|
||||
});
|
||||
|
Reference in New Issue
Block a user