Skip to content

Commit c3b9e43

Browse files
committed
Add not-seeded state for tenant
1 parent cc2dd04 commit c3b9e43

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

wizard-server/src/Wizard/Api/Resource/Config/ClientConfigDTO.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import Wizard.Model.Tenant.Config.TenantConfig
88
import Wizard.Model.User.UserProfile
99

1010
data ClientConfigDTO
11-
= HousekeepingInProgressClientConfigDTO
11+
= NotSeededClientConfigDTO
12+
{ message :: String
13+
}
14+
| HousekeepingInProgressClientConfigDTO
1215
{ message :: String
1316
}
1417
| ClientConfigDTO

wizard-server/src/Wizard/Model/Tenant/Tenant.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ data Tenant = Tenant
2626
deriving (Show, Eq, Generic)
2727

2828
data TenantState
29-
= PendingHousekeepingTenantState
29+
= NotSeededTenantState
30+
| PendingHousekeepingTenantState
3031
| HousekeepingInProgressTenantState
3132
| ReadyForUseTenantState
3233
deriving (Show, Eq, Generic, Read)

wizard-server/src/Wizard/Service/Config/Client/ClientConfigService.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ getClientConfig mServerUrl mClientUrl = do
3232
else getCurrentTenant
3333
unless tenant.enabled (throwError . NotExistsError $ _ERROR_VALIDATION__TENANT_OR_ACTIVE_PLAN_ABSENCE (fromMaybe "not-provided" mServerUrl))
3434
case tenant.state of
35+
NotSeededTenantState -> do
36+
return $ NotSeededClientConfigDTO {message = "We’re currently preparing the instance for you"}
3537
PendingHousekeepingTenantState -> do
3638
let mCreatedByUuid = fmap (.uuid) mCurrentUser
3739
migrateToLatestMetamodelVersionCommand tenant mCreatedByUuid

wizard-server/src/Wizard/Service/Tenant/TenantMapper.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ fromAdminCreateDTO reqDto aUuid serverConfig now =
100100
, updatedAt = now
101101
}
102102

103-
fromCommand :: CreateOrUpdateTenantCommand -> ServerConfig -> UTCTime -> UTCTime -> Tenant
104-
fromCommand command serverConfig createdAt updatedAt =
103+
fromCommand :: CreateOrUpdateTenantCommand -> TenantState -> ServerConfig -> UTCTime -> UTCTime -> Tenant
104+
fromCommand command state serverConfig createdAt updatedAt =
105105
let (serverDomain, url) =
106106
case command.customDomain of
107107
Just customDomain -> (customDomain, f' "https://%s" [customDomain])
@@ -121,7 +121,7 @@ fromCommand command serverConfig createdAt updatedAt =
121121
, analyticsClientUrl = Just $ createReportingClientUrl url
122122
, signalBridgeUrl = serverConfig.cloud.signalBridgeUrl
123123
, enabled = command.enabled
124-
, state = ReadyForUseTenantState
124+
, state = state
125125
, createdAt = createdAt
126126
, updatedAt = updatedAt
127127
}
@@ -144,7 +144,7 @@ fromChangeDTO tenant reqDto serverConfig =
144144
, analyticsClientUrl = Just $ createReportingClientUrl url
145145
, signalBridgeUrl = tenant.signalBridgeUrl
146146
, enabled = tenant.enabled
147-
, state = ReadyForUseTenantState
147+
, state = tenant.state
148148
, createdAt = tenant.createdAt
149149
, updatedAt = tenant.updatedAt
150150
}

wizard-server/src/Wizard/Service/Tenant/TenantService.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ createTenantByCommand :: CreateOrUpdateTenantCommand -> AppContextM ()
8181
createTenantByCommand command = do
8282
now <- liftIO getCurrentTime
8383
serverConfig <- asks serverConfig
84-
let tenant = fromCommand command serverConfig now now
84+
let tenant = fromCommand command NotSeededTenantState serverConfig now now
8585
insertTenant tenant
8686
createConfig tenant.uuid now
8787
createLimitBundle tenant.uuid now
@@ -115,7 +115,7 @@ modifyTenantFromCommand command =
115115
now <- liftIO getCurrentTime
116116
serverConfig <- asks serverConfig
117117
tenant <- findTenantByUuid command.uuid
118-
let updatedTenant = fromCommand command serverConfig tenant.createdAt now
118+
let updatedTenant = fromCommand command tenant.state serverConfig tenant.createdAt now
119119
updateTenantByUuid updatedTenant
120120
modifyLimitBundle command.uuid command.limits
121121
return updatedTenant

0 commit comments

Comments
 (0)