module IHP.IDE.SchemaDesigner.View.Policies.Edit where import IHP.ViewPrelude import IHP.IDE.SchemaDesigner.Types import qualified IHP.IDE.SchemaDesigner.Compiler as Compiler import IHP.IDE.ToolServer.Types import IHP.IDE.SchemaDesigner.View.Layout data EditPolicyView = EditPolicyView { statements :: [Statement] , tableName :: Text , columns :: [Column] , policy :: Statement } instance View EditPolicyView where html EditPolicyView { .. } = [hsx|
{renderObjectSelector (zip [0..] statements) (Just tableName)} {renderColumnSelector tableName (zip [0..] columns) statements}
{migrationStatus} {renderModal modal} |] where modalContent = [hsx|
This SQL expression needs to return True if the row should be visible to the current user. This is the USING condition of the Postgres Policy
Use this to e.g. disallow users changing the user_id to another user's id. This is the CHECK condition of the Postgres Policy
|] modalFooter = mempty modalCloseUrl = pathTo ShowTableAction { tableName } modalTitle = "Edit Policy" modal = Modal { modalContent, modalFooter, modalCloseUrl, modalTitle } using = policy.using |> maybe "" Compiler.compileExpression check = policy.check |> maybe "" Compiler.compileExpression autocompleteSuggestions = columns |> map (.name) |> intercalate ","