module IHP.IDE.CodeGen.View.Generators where import IHP.ViewPrelude import IHP.IDE.ToolServer.Types import IHP.IDE.ToolServer.Layout import IHP.IDE.CodeGen.Types import qualified Data.Text as Text import IHP.IDE.ToolServer.Helper.View data GeneratorsView = GeneratorsView instance View GeneratorsView where html :: (?context::ControllerContext, ?view::GeneratorsView) => GeneratorsView -> Html html GeneratorsView GeneratorsView = [hsx| <div class="generators"> <div class="container pt-5"> {renderFlashMessages} <div class="generators-list"> {generator "Controller" (pathTo NewControllerAction) copyIcon} {generator "Action" (pathTo NewActionAction) copyIcon} {generator "View" (pathTo NewViewAction) copyIcon} {generator "Mail" (pathTo NewMailAction) copyIcon} {generator "Background Job" (pathTo NewJobAction) cogsIcon} {generator "Script" (pathTo NewScriptAction) copyIcon} {generator "Migration" (pathTo NewMigrationAction) dataIcon} {generator "Application" (pathTo NewApplicationAction) copyIcon} </div> </div> </div> |] where generator :: Text -> Text -> Html -> Html generator :: Text -> Text -> ((?context::ControllerContext) => Html) -> (?context::ControllerContext) => Html generator Text name Text path (?context::ControllerContext) => Html icon = [hsx| <a href={path} class="generator"> <div class="generator-icon">{icon}</div> <div class="generator-name">{name}</div> </a> |] renderPlan :: Either a mono -> Html renderPlan (Left a error) = [hsx|{error}|] renderPlan (Right mono actions) = [hsx|<div class="generator-actions">{forEach actions renderGeneratorAction}</div>|] renderGeneratorAction :: GeneratorAction -> Html renderGeneratorAction CreateFile { Text filePath :: Text fileContent :: Text $sel:filePath:CreateFile :: GeneratorAction -> Text $sel:fileContent:CreateFile :: GeneratorAction -> Text .. } = [hsx| <div class="generator-action CreateFile"> <div class="file-path">{filePath}</div> <div class="file-content">{Text.strip fileContent}</div> </div> |] renderGeneratorAction AppendToFile { Text $sel:filePath:CreateFile :: GeneratorAction -> Text $sel:fileContent:CreateFile :: GeneratorAction -> Text filePath :: Text fileContent :: Text .. } = [hsx| <div class="generator-action AppendToFile"> <div class="file-path">Append to {filePath}</div> <div class="file-content">{Text.strip fileContent}</div> </div> |] renderGeneratorAction AppendToMarker { Text $sel:filePath:CreateFile :: GeneratorAction -> Text $sel:fileContent:CreateFile :: GeneratorAction -> Text marker :: Text filePath :: Text fileContent :: Text $sel:marker:CreateFile :: GeneratorAction -> Text .. } = [hsx| <div class="generator-action AppendToFile"> <div class="file-path">Append to {filePath}</div> <div class="file-content">{Text.strip fileContent}</div> </div> |] renderGeneratorAction AddImport { Text $sel:filePath:CreateFile :: GeneratorAction -> Text $sel:fileContent:CreateFile :: GeneratorAction -> Text filePath :: Text fileContent :: Text .. } = [hsx| <div class="generator-action AddImport"> <div class="file-path">Append to {filePath}</div> <div class="file-content">{Text.strip fileContent}</div> </div> |] renderGeneratorAction AddAction { Text $sel:filePath:CreateFile :: GeneratorAction -> Text $sel:fileContent:CreateFile :: GeneratorAction -> Text filePath :: Text fileContent :: Text .. } = [hsx| <div class="generator-action AddImport"> <div class="file-path">Append to {filePath}</div> <div class="file-content">{Text.strip fileContent}</div> </div> |] renderGeneratorAction AddMountToFrontController { Text $sel:filePath:CreateFile :: GeneratorAction -> Text filePath :: Text applicationName :: Text $sel:applicationName:CreateFile :: GeneratorAction -> Text .. } = [hsx| <div class="generator-action AddMountToFrontController"> <div class="file-path">Mount to FrontController {filePath}</div> <div class="file-content">{Text.strip applicationName}</div> </div> |] renderGeneratorAction AddToDataConstructor { Text $sel:filePath:CreateFile :: GeneratorAction -> Text $sel:fileContent:CreateFile :: GeneratorAction -> Text dataConstructor :: Text filePath :: Text fileContent :: Text $sel:dataConstructor:CreateFile :: GeneratorAction -> Text .. } = [hsx| <div class="generator-action AddToDataConstructor"> <div class="file-path">Append to {filePath}</div> <div class="file-content">{Text.strip fileContent}</div> </div> |] renderGeneratorAction EnsureDirectory {} = Html forall a. Monoid a => a mempty renderGeneratorAction RunShellCommand {} = Html forall a. Monoid a => a mempty