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