Class: Migrations::Preview

Inherits:
Components::Base
  • Object
show all
Defined in:
app/components/databasium/migrations/preview.rb

Instance Method Summary collapse

Constructor Details

#initialize(content:) ⇒ Preview

Returns a new instance of Preview.



4
5
6
# File 'app/components/databasium/migrations/preview.rb', line 4

def initialize(content:)
  @content = content
end

Instance Method Details

#view_templateObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/components/databasium/migrations/preview.rb', line 8

def view_template
  div(id: "migration_preview") do
    div(class: "bg-panel border-1 border-border p-4 rounded-2xl min-h-full") do
      if @content
        h1(class: "text-xl font-semibold mb-3") { "Preview Migration" }
        pre { @content }
        button(
          type: "submit",
          form: "migration_form",
          name: "add_migration",
          value: "Save",
          class: "bg-accent p-2 rounded-md w-fit mt-4"
        ) { "Save" }
      else
        h1(class: "text-xl font-semibold") { "Please fill out the form to see the preview" }
      end
    end
  end
end