install warning stuff complete

This commit is contained in:
Keagan McClelland
2021-01-13 17:24:11 -07:00
committed by Aiden McClelland
parent 81d11842f0
commit 7c3238cf8d
4 changed files with 39 additions and 25 deletions

View File

@@ -210,6 +210,7 @@ getAvailableAppByIdLogic appId = do
, appAvailableFullReleaseNotes = storeAppVersionInfoReleaseNotes latest , appAvailableFullReleaseNotes = storeAppVersionInfoReleaseNotes latest
, appAvailableFullDependencyRequirements = HM.elems dependencyRequirements , appAvailableFullDependencyRequirements = HM.elems dependencyRequirements
, appAvailableFullVersions = storeAppVersionInfoVersion <$> storeAppVersions , appAvailableFullVersions = storeAppVersionInfoVersion <$> storeAppVersions
, appAvailableFullInstallWarning = storeAppVersionInfoInstallWarning latest
} }
getAppLogsByIdR :: AppId -> Handler (JSONResponse [Text]) getAppLogsByIdR :: AppId -> Handler (JSONResponse [Text])
@@ -286,6 +287,7 @@ getInstalledAppByIdLogic appId = do
, appInstalledFullLastBackup = backupTime , appInstalledFullLastBackup = backupTime
, appInstalledFullTorAddress = Nothing , appInstalledFullTorAddress = Nothing
, appInstalledFullConfiguredRequirements = [] , appInstalledFullConfiguredRequirements = []
, appInstalledFullUninstallWarning = Nothing
} }
serverApps <- AppMgr2.list [AppMgr2.flags|-s -d|] serverApps <- AppMgr2.list [AppMgr2.flags|-s -d|]
let remapped = remapAppMgrInfo jobCache serverApps let remapped = remapAppMgrInfo jobCache serverApps
@@ -293,6 +295,7 @@ getInstalledAppByIdLogic appId = do
let let
installed = do installed = do
(status, version, AppMgr2.InfoRes {..}) <- hoistMaybe (HM.lookup appId remapped) (status, version, AppMgr2.InfoRes {..}) <- hoistMaybe (HM.lookup appId remapped)
manifest' <- lift $ LAsync.async $ AppMgr2.infoResManifest <<$>> AppMgr2.info [AppMgr2.flags|-M|] appId
instructions' <- lift $ LAsync.async $ AppMgr2.instructions appId instructions' <- lift $ LAsync.async $ AppMgr2.instructions appId
requirements <- LAsync.runConcurrently $ flip requirements <- LAsync.runConcurrently $ flip
HML.traverseWithKey HML.traverseWithKey
@@ -312,16 +315,19 @@ getInstalledAppByIdLogic appId = do
(HM.lookup depId installCache $> AppStatusTmp Installing) (HM.lookup depId installCache $> AppStatusTmp Installing)
<|> (view _1 <$> HM.lookup depId remapped) <|> (view _1 <$> HM.lookup depId remapped)
pure $ dependencyInfoToDependencyRequirement (AsInstalled STrue) (base, depStatus, depInfo) pure $ dependencyInfoToDependencyRequirement (AsInstalled STrue) (base, depStatus, depInfo)
manifest <- lift $ LAsync.wait manifest'
instructions <- lift $ LAsync.wait instructions' instructions <- lift $ LAsync.wait instructions'
backupTime <- lift $ LAsync.wait backupTime' backupTime <- lift $ LAsync.wait backupTime'
pure AppInstalledFull { appInstalledFullBase = AppBase appId infoResTitle (iconUrl appId version) pure AppInstalledFull
, appInstalledFullStatus = status { appInstalledFullBase = AppBase appId infoResTitle (iconUrl appId version)
, appInstalledFullVersionInstalled = version , appInstalledFullStatus = status
, appInstalledFullInstructions = instructions , appInstalledFullVersionInstalled = version
, appInstalledFullLastBackup = backupTime , appInstalledFullInstructions = instructions
, appInstalledFullTorAddress = infoResTorAddress , appInstalledFullLastBackup = backupTime
, appInstalledFullConfiguredRequirements = HM.elems requirements , appInstalledFullTorAddress = infoResTorAddress
} , appInstalledFullConfiguredRequirements = HM.elems requirements
, appInstalledFullUninstallWarning = manifest >>= AppManifest.appManifestUninstallWarning
}
runMaybeT (installing <|> installed) `orThrowM` NotFoundE "appId" (show appId) runMaybeT (installing <|> installed) `orThrowM` NotFoundE "appId" (show appId)
postUninstallAppR :: AppId -> Handler (JSONResponse (WithBreakages ())) postUninstallAppR :: AppId -> Handler (JSONResponse (WithBreakages ()))
@@ -645,6 +651,7 @@ getAvailableAppVersionInfoLogic appId appVersionSpec = do
pure AppVersionInfo { appVersionInfoVersion = storeAppVersionInfoVersion pure AppVersionInfo { appVersionInfoVersion = storeAppVersionInfoVersion
, appVersionInfoReleaseNotes = storeAppVersionInfoReleaseNotes , appVersionInfoReleaseNotes = storeAppVersionInfoReleaseNotes
, appVersionInfoDependencyRequirements = HM.elems requirements , appVersionInfoDependencyRequirements = HM.elems requirements
, appVersionInfoInstallWarning = storeAppVersionInfoInstallWarning
} }
postAutoconfigureR :: AppId -> AppId -> Handler (JSONResponse (WithBreakages AutoconfigureChangesRes)) postAutoconfigureR :: AppId -> AppId -> Handler (JSONResponse (WithBreakages AutoconfigureChangesRes))

View File

@@ -72,6 +72,7 @@ data AppAvailableFull = AppAvailableFull
, appAvailableFullDescriptionShort :: Text , appAvailableFullDescriptionShort :: Text
, appAvailableFullDescriptionLong :: Text , appAvailableFullDescriptionLong :: Text
, appAvailableFullReleaseNotes :: Text , appAvailableFullReleaseNotes :: Text
, appAvailableFullInstallWarning :: Maybe Text
, appAvailableFullDependencyRequirements :: [Full AppDependencyRequirement] , appAvailableFullDependencyRequirements :: [Full AppDependencyRequirement]
, appAvailableFullVersions :: NonEmpty Version , appAvailableFullVersions :: NonEmpty Version
} }
@@ -128,6 +129,7 @@ data AppInstalledFull = AppInstalledFull
, appInstalledFullInstructions :: Maybe Text , appInstalledFullInstructions :: Maybe Text
, appInstalledFullLastBackup :: Maybe UTCTime , appInstalledFullLastBackup :: Maybe UTCTime
, appInstalledFullConfiguredRequirements :: [Stripped AppDependencyRequirement] , appInstalledFullConfiguredRequirements :: [Stripped AppDependencyRequirement]
, appInstalledFullUninstallWarning :: Maybe Text
} }
instance ToJSON AppInstalledFull where instance ToJSON AppInstalledFull where
toJSON AppInstalledFull {..} = object toJSON AppInstalledFull {..} = object
@@ -146,6 +148,7 @@ data AppVersionInfo = AppVersionInfo
{ appVersionInfoVersion :: Version { appVersionInfoVersion :: Version
, appVersionInfoReleaseNotes :: Text , appVersionInfoReleaseNotes :: Text
, appVersionInfoDependencyRequirements :: [Full AppDependencyRequirement] , appVersionInfoDependencyRequirements :: [Full AppDependencyRequirement]
, appVersionInfoInstallWarning :: Maybe Text
} }
instance ToJSON AppVersionInfo where instance ToJSON AppVersionInfo where
toJSON AppVersionInfo {..} = object toJSON AppVersionInfo {..} = object

View File

@@ -48,7 +48,7 @@ instance FromJSON AssetMapping where
pure $ AssetMapping { .. } pure $ AssetMapping { .. }
data AppManifest where data AppManifest where
AppManifest :: { appManifestId :: AppId AppManifest ::{ appManifestId :: AppId
, appManifestVersion :: Version , appManifestVersion :: Version
, appManifestTitle :: Text , appManifestTitle :: Text
, appManifestDescShort :: Text , appManifestDescShort :: Text
@@ -60,6 +60,7 @@ data AppManifest where
, appManifestAssets :: [AssetMapping] , appManifestAssets :: [AssetMapping]
, appManifestOnionVersion :: OnionVersion , appManifestOnionVersion :: OnionVersion
, appManifestDependencies :: HM.HashMap AppId VersionRange , appManifestDependencies :: HM.HashMap AppId VersionRange
, appManifestUninstallWarning :: Maybe Text
} -> AppManifest } -> AppManifest
uiAvailable :: AppManifest -> Bool uiAvailable :: AppManifest -> Bool
@@ -67,18 +68,19 @@ uiAvailable AppManifest {..} = isJust $ HM.lookup 80 appManifestPortMapping
instance FromJSON AppManifest where instance FromJSON AppManifest where
parseJSON = withObject "App Manifest " $ \o -> do parseJSON = withObject "App Manifest " $ \o -> do
appManifestId <- o .: "id" appManifestId <- o .: "id"
appManifestVersion <- o .: "version" appManifestVersion <- o .: "version"
appManifestTitle <- o .: "title" appManifestTitle <- o .: "title"
appManifestDescShort <- o .: "description" >>= (.: "short") appManifestDescShort <- o .: "description" >>= (.: "short")
appManifestDescLong <- o .: "description" >>= (.: "long") appManifestDescLong <- o .: "description" >>= (.: "long")
appManifestReleaseNotes <- o .: "release-notes" appManifestReleaseNotes <- o .: "release-notes"
appManifestPortMapping <- o .: "ports" >>= fmap HM.fromList . traverse parsePortMapping appManifestPortMapping <- o .: "ports" >>= fmap HM.fromList . traverse parsePortMapping
appManifestImageType <- o .: "image" >>= (.: "type") appManifestImageType <- o .: "image" >>= (.: "type")
appManifestMount <- o .: "mount" appManifestMount <- o .: "mount"
appManifestAssets <- o .: "assets" >>= traverse parseJSON appManifestAssets <- o .: "assets" >>= traverse parseJSON
appManifestOnionVersion <- o .: "hidden-service-version" appManifestOnionVersion <- o .: "hidden-service-version"
appManifestDependencies <- o .:? "dependencies" .!= HM.empty >>= traverse parseDepInfo appManifestDependencies <- o .:? "dependencies" .!= HM.empty >>= traverse parseDepInfo
appManifestUninstallWarning <- o .:? "uninstall-warning"
pure $ AppManifest { .. } pure $ AppManifest { .. }
where where
parsePortMapping = withObject "Port Mapping" $ \o -> liftA2 (,) (o .: "tor") (o .: "internal") parsePortMapping = withObject "Port Mapping" $ \o -> liftA2 (,) (o .: "tor") (o .: "internal")

View File

@@ -24,16 +24,18 @@ data StoreApp = StoreApp
deriving (Eq, Show) deriving (Eq, Show)
data StoreAppVersionInfo = StoreAppVersionInfo data StoreAppVersionInfo = StoreAppVersionInfo
{ storeAppVersionInfoVersion :: Version { storeAppVersionInfoVersion :: Version
, storeAppVersionInfoReleaseNotes :: Text , storeAppVersionInfoReleaseNotes :: Text
, storeAppVersionInfoInstallWarning :: Maybe Text
} }
deriving (Eq, Show) deriving (Eq, Show)
instance Ord StoreAppVersionInfo where instance Ord StoreAppVersionInfo where
compare = compare `on` storeAppVersionInfoVersion compare = compare `on` storeAppVersionInfoVersion
instance FromJSON StoreAppVersionInfo where instance FromJSON StoreAppVersionInfo where
parseJSON = withObject "Store App Version Info" $ \o -> do parseJSON = withObject "Store App Version Info" $ \o -> do
storeAppVersionInfoVersion <- o .: "version" storeAppVersionInfoVersion <- o .: "version"
storeAppVersionInfoReleaseNotes <- o .: "release-notes" storeAppVersionInfoReleaseNotes <- o .: "release-notes"
storeAppVersionInfoInstallWarning <- o .: "install-warning"
pure StoreAppVersionInfo { .. } pure StoreAppVersionInfo { .. }
instance ToJSON StoreAppVersionInfo where instance ToJSON StoreAppVersionInfo where
toJSON StoreAppVersionInfo {..} = toJSON StoreAppVersionInfo {..} =