Skip to content

Commit

Permalink
Move calcom url to application level setting
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanalicic committed Sep 22, 2022
1 parent 27acfde commit dfa5119
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 21 deletions.
10 changes: 6 additions & 4 deletions api/applicationsettingsservice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ components:
mainTenantSubdomainForSingleDomainMultitenancy:
allOf:
- $ref: '#/components/schemas/SettingDTO'
budibaseSSO:
allOf:
- $ref: '#/components/schemas/FeatureToggleDTO'
useOverviewPage:
allOf:
- $ref: '#/components/schemas/FeatureToggleDTO'

calcomUrl:
allOf:
- $ref: '#/components/schemas/SettingDTO'
budibaseAuthClientId:
allOf:
- $ref: '#/components/schemas/SettingDTO'

FeatureToggleDTO:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ public ApplicationSettingsDTO toDTO(ApplicationSettingsEntity applicationSetting
toFeatureToggleDTO(applicationSettings.getUseTenantService()))
.mainTenantSubdomainForSingleDomainMultitenancy(
toSettingDTO(applicationSettings.getMainTenantSubdomainForSingleDomainMultitenancy()))
.budibaseSSO(toFeatureToggleDTO(applicationSettings.getBudibaseSSO()))
.useOverviewPage(toFeatureToggleDTO(applicationSettings.getUseOverviewPage()));
.useOverviewPage(toFeatureToggleDTO(applicationSettings.getUseOverviewPage()))
.calcomUrl(toSettingDTO(applicationSettings.getCalcomUrl()))
.budibaseAuthClientId(toSettingDTO(applicationSettings.getBudibaseAuthClientId()));
}

private SettingDTO toSettingDTO(MainTenantSubdomainForSingleDomainMultitenancy mainTenantSubdomainForSingleDomainMultitenancy) {
if (mainTenantSubdomainForSingleDomainMultitenancy == null) {
private SettingDTO toSettingDTO(Object setting) {
if (setting == null) {
return null;
}
Boolean readOnly = getFieldValue(setting, "readOnly", Boolean.class);
String value = getFieldValue(setting, "value", String.class);
return new SettingDTO()
.value(mainTenantSubdomainForSingleDomainMultitenancy.getValue())
.readOnly(mainTenantSubdomainForSingleDomainMultitenancy.getReadOnly());
.readOnly(readOnly)
.value(value);
}

private FeatureToggleDTO toFeatureToggleDTO(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import de.caritas.cob.consultingtypeservice.api.model.ApplicationSettingsEntity;
import de.caritas.cob.consultingtypeservice.api.repository.ApplicationSettingsRepository;
import de.caritas.cob.consultingtypeservice.schemas.model.BudibaseSSO;
import de.caritas.cob.consultingtypeservice.schemas.model.BudibaseAuthClientId;
import de.caritas.cob.consultingtypeservice.schemas.model.CalcomUrl;
import de.caritas.cob.consultingtypeservice.schemas.model.DisableVideoAppointments;
import de.caritas.cob.consultingtypeservice.schemas.model.EnableWalkthrough;
import de.caritas.cob.consultingtypeservice.schemas.model.MainTenantSubdomainForSingleDomainMultitenancy;
Expand Down Expand Up @@ -58,7 +59,8 @@ private ApplicationSettingsEntity createDefaultApplicationSettings() {
.withReadOnly(false)
.withValue(mainTenantSubdomainForSingleDomainMultitenancy));
entity.setUseOverviewPage(new UseOverviewPage().withValue(false).withReadOnly(false));
entity.setBudibaseSSO(new BudibaseSSO().withValue(false).withReadOnly(false));
entity.setCalcomUrl(new CalcomUrl().withValue("calcomUrl").withReadOnly(false));
entity.setBudibaseAuthClientId(new BudibaseAuthClientId().withValue("budibaseAuthClientId").withReadOnly(false));
return entity;
}
}
19 changes: 17 additions & 2 deletions src/main/resources/schemas/application-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"readOnly"
]
},
"budibaseSSO": {
"useOverviewPage": {
"type": "object",
"properties": {
"value": {
Expand All @@ -129,11 +129,26 @@
"readOnly"
]
},
"useOverviewPage": {
"calcomUrl": {
"type": "object",
"properties": {
"value": {
"type": "string"
},
"readOnly": {
"type": "boolean"
}
},
"required": [
"value",
"readOnly"
]
},
"budibaseAuthClientId": {
"type": "object",
"properties": {
"value": {
"type": "string"
},
"readOnly": {
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ void getApplicationSettings_Should_ReturnApplicationSettings_When_UserIsNotAuthe
.andExpect(jsonPath("$.disableVideoAppointments.readOnly").value(false))
.andExpect(jsonPath("$.mainTenantSubdomainForSingleDomainMultitenancy.value").value("app"))
.andExpect(jsonPath("$.mainTenantSubdomainForSingleDomainMultitenancy.readOnly").value(false))
.andExpect(jsonPath("$.budibaseSSO.value").value(false))
.andExpect(jsonPath("$.budibaseSSO.readOnly").value(false))
.andExpect(jsonPath("$.budibaseAuthClientId.value").value("budibaseAuthClientId"))
.andExpect(jsonPath("$.budibaseAuthClientId.readOnly").value(false))
.andExpect(jsonPath("$.calcomUrl.value").value("calcomUrl"))
.andExpect(jsonPath("$.calcomUrl.readOnly").value(false))
.andExpect(jsonPath("$.useOverviewPage.value").value(false))
.andExpect(jsonPath("$.useOverviewPage.readOnly").value(false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import de.caritas.cob.consultingtypeservice.api.model.ApplicationSettingsDTO;
import de.caritas.cob.consultingtypeservice.api.model.ApplicationSettingsEntity;
import de.caritas.cob.consultingtypeservice.schemas.model.BudibaseSSO;
import de.caritas.cob.consultingtypeservice.schemas.model.BudibaseAuthClientId;
import de.caritas.cob.consultingtypeservice.schemas.model.CalcomUrl;
import de.caritas.cob.consultingtypeservice.schemas.model.DisableVideoAppointments;
import de.caritas.cob.consultingtypeservice.schemas.model.EnableWalkthrough;
import de.caritas.cob.consultingtypeservice.schemas.model.MainTenantSubdomainForSingleDomainMultitenancy;
Expand All @@ -29,7 +30,8 @@ void toDTO_Should_ConvertToDTEmptySettings() {
assertThat(applicationSettingsDTO.getMultitenancyEnabled()).isNull();
assertThat(applicationSettingsDTO.getEnableWalkthrough()).isNull();
assertThat(applicationSettingsDTO.getUseTenantService()).isNull();
assertThat(applicationSettingsDTO.getBudibaseSSO()).isNull();
assertThat(applicationSettingsDTO.getBudibaseAuthClientId()).isNull();
assertThat(applicationSettingsDTO.getCalcomUrl()).isNull();
assertThat(applicationSettingsDTO.getUseOverviewPage()).isNull();
}

Expand All @@ -55,8 +57,10 @@ void toDTO_Should_ConvertToDTOAllSettings() {
assertThat(applicationSettingsDTO.getDisableVideoAppointments().getReadOnly()).isFalse();
assertThat(applicationSettingsDTO.getMainTenantSubdomainForSingleDomainMultitenancy().getValue()).isEqualTo("app");
assertThat(applicationSettingsDTO.getMainTenantSubdomainForSingleDomainMultitenancy().getReadOnly()).isFalse();
assertThat(applicationSettingsDTO.getBudibaseSSO().getValue()).isFalse();
assertThat(applicationSettingsDTO.getBudibaseSSO().getReadOnly()).isFalse();
assertThat(applicationSettingsDTO.getBudibaseAuthClientId().getReadOnly()).isEqualTo(false);
assertThat(applicationSettingsDTO.getBudibaseAuthClientId().getValue()).isEqualTo("budibaseAuthClientId");
assertThat(applicationSettingsDTO.getCalcomUrl().getValue()).isEqualTo("calcomUrl");
assertThat(applicationSettingsDTO.getCalcomUrl().getReadOnly()).isEqualTo(false);
assertThat(applicationSettingsDTO.getUseOverviewPage().getValue()).isFalse();
assertThat(applicationSettingsDTO.getUseOverviewPage().getReadOnly()).isFalse();
}
Expand All @@ -69,7 +73,8 @@ private ApplicationSettingsEntity giveApplicationSettings() {
settings.setEnableWalkthrough(new EnableWalkthrough().withReadOnly(false).withValue(true));
settings.setDisableVideoAppointments(new DisableVideoAppointments().withReadOnly(false).withValue(true));
settings.setMainTenantSubdomainForSingleDomainMultitenancy(new MainTenantSubdomainForSingleDomainMultitenancy().withReadOnly(false).withValue("app"));
settings.setBudibaseSSO(new BudibaseSSO().withReadOnly(false).withValue(false));
settings.setBudibaseAuthClientId(new BudibaseAuthClientId().withReadOnly(false).withValue("budibaseAuthClientId"));
settings.setCalcomUrl(new CalcomUrl().withReadOnly(false).withValue("calcomUrl"));
settings.setUseOverviewPage(new UseOverviewPage().withReadOnly(false).withValue(false));
return settings;
}
Expand Down

0 comments on commit dfa5119

Please sign in to comment.