easy_flow 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40a016478b5c039fb2f7400893c890980fd1c66f52b835f61be7a3a68061a71d
4
- data.tar.gz: c8c747889382a26e6c2d340b330f45a802932bac768da695845e697df722848c
3
+ metadata.gz: '09da0c518d71ed06c4d63399b2038696d15c770ee0706926bad55f81a3a58a34'
4
+ data.tar.gz: 68642f79f5418b7db09b3a7274948f8480f7519ca4224546b23bdb94e6e7db0d
5
5
  SHA512:
6
- metadata.gz: 4a42a48255633d247401da16dfb668d0c774c90e0f8a70df7bef426c6a7f5d59f674837337177856c3d7a0e7106993077d1038fbfe2bc0c6953a8624930a45bf
7
- data.tar.gz: 4bd045161d5eb15f7ed880df701d6ed7e5016a408fea9da21d98bc4234776b585c12099dcf9224d70a1003252bb12c6db69a38ffff45001d7f6e4898bd356c8d
6
+ metadata.gz: 2ae172d8e8851e18042c80217e2163f1e4b3cf829f556c2936ee41f353340b05eea8225d0fc3cd412186adb9c662f36380cbca51b1ef259455ea44e1ea5467f6
7
+ data.tar.gz: 5069ecd19aafa80210158466d6819233b1485bc6820f4d1f259ebcdb0c067b1fafa94ab72be84210d32acbc0c510d7e8c115cb303c0e304f17d87cbeb3587233
@@ -4,14 +4,24 @@ module EasyFlow
4
4
 
5
5
  layout -> { flow_host.layout }
6
6
  helper KeystoneUiHelper
7
+ helper AppRoutesHelper
8
+
9
+ before_action { AppRoutesHelper.define_app_route_helpers }
7
10
 
8
11
  rescue_from NotPublished, NotPermitted, Withdrawn, with: :refuse
9
12
 
10
13
  helper_method :flow_start_path, :flow_routes
11
14
 
15
+ class_attribute :host_route_prefix, instance_accessor: false
16
+
17
+ def self.routed_by(prefix)
18
+ self.host_route_prefix = prefix
19
+ end
20
+
12
21
  private
13
22
 
14
23
  def flow_routes
24
+ return HostRoutes.new(main_app, self.class.host_route_prefix) if self.class.host_route_prefix
15
25
  return easy_flow unless request.routes.equal?(EasyFlow::Engine.routes)
16
26
 
17
27
  @flow_routes ||= ActionDispatch::Routing::RoutesProxy.new(_routes, self, _routes.url_helpers)
@@ -13,10 +13,18 @@ module EasyFlow
13
13
 
14
14
  helper KeystoneUiHelper
15
15
  helper KeystoneUi::React::MountHelper
16
- helper EasyFlow::Engine.routes.url_helpers
16
+ helper AppRoutesHelper
17
+
18
+ before_action { AppRoutesHelper.define_app_route_helpers }
19
+
20
+ helper_method :flow_routes
17
21
 
18
22
  private
19
23
 
24
+ def flow_routes
25
+ @flow_routes ||= ActionDispatch::Routing::RoutesProxy.new(_routes, self, _routes.url_helpers)
26
+ end
27
+
20
28
  def refuse_a_host_not_set_up
21
29
  head :not_found unless flow_host.set_up?
22
30
  end
@@ -0,0 +1,12 @@
1
+ module EasyFlow
2
+ module AppRoutesHelper
3
+ def self.define_app_route_helpers
4
+ @app_route_helpers_defined ||= begin
5
+ (Rails.application.routes.named_routes.helper_names - EasyFlow::Engine.routes.named_routes.helper_names).each do |name|
6
+ define_method(name) { |*args, **options| main_app.public_send(name, *args, **options) }
7
+ end
8
+ true
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,11 +1,11 @@
1
1
  <%= ui_page(max_width: :lg) do %>
2
2
  <p class="mb-4">
3
- <%= link_to "← Back to the flow", manage_flow_path(@flow), class: "text-sm text-accent-600 hover:text-accent-700" %>
3
+ <%= link_to "← Back to the flow", flow_routes.manage_flow_path(@flow), class: "text-sm text-accent-600 hover:text-accent-700" %>
4
4
  </p>
5
5
 
6
- <%= ui_form_page(title: "Definition", back_url: manage_flow_path(@flow), subtitle: @flow.slug) %>
6
+ <%= ui_form_page(title: "Definition", back_url: flow_routes.manage_flow_path(@flow), subtitle: @flow.slug) %>
7
7
 
8
- <%= ui_form(action: manage_flow_definition_path(@flow), method: :patch) do %>
8
+ <%= ui_form(action: flow_routes.manage_flow_definition_path(@flow), method: :patch) do %>
9
9
  <%= ui_textarea(name: "definition", value: JSON.pretty_generate(@flow.document), rows: 30) %>
10
10
 
11
11
  <%= ui_button(label: "Save", type: :submit) %>
@@ -1,11 +1,11 @@
1
1
  <%= ui_page(max_width: :lg) do %>
2
2
  <p class="mb-4">
3
- <%= link_to "← Back to the flow", manage_flow_path(@flow), class: "text-sm text-accent-600 hover:text-accent-700" %>
3
+ <%= link_to "← Back to the flow", flow_routes.manage_flow_path(@flow), class: "text-sm text-accent-600 hover:text-accent-700" %>
4
4
  </p>
5
5
 
6
- <%= ui_form_page(title: "Edit details", back_url: manage_flow_path(@flow)) %>
6
+ <%= ui_form_page(title: "Edit details", back_url: flow_routes.manage_flow_path(@flow)) %>
7
7
 
8
- <%= ui_form(action: manage_flow_path(@flow), method: :patch) do %>
8
+ <%= ui_form(action: flow_routes.manage_flow_path(@flow), method: :patch) do %>
9
9
  <%= ui_section(title: "How this is introduced") do %>
10
10
  <label class="block text-sm font-medium mb-1">Title</label>
11
11
  <%= ui_input(name: "flow[title]", value: @flow.title) %>
@@ -6,9 +6,9 @@
6
6
  columns: [ { title: "Title" }, { slug: "Slug" }, { kind: "Kind" }, { status: "Status" } ],
7
7
  empty_message: "No flows yet."
8
8
  ) do |table| %>
9
- <% table.link(:title) { |flow| manage_flow_path(flow) } %>
9
+ <% table.link(:title) { |flow| flow_routes.manage_flow_path(flow) } %>
10
10
  <% table.actions do |flow| %>
11
- <%= ui_form(action: manage_flow_path(flow), method: :delete) do %>
11
+ <%= ui_form(action: flow_routes.manage_flow_path(flow), method: :delete) do %>
12
12
  <%= ui_button(label: "Remove", type: :submit, variant: :secondary) %>
13
13
  <% end %>
14
14
  <% end %>
@@ -19,7 +19,7 @@
19
19
  <%= ui_alert(message: @flow.errors.full_messages.to_sentence, type: :error) %>
20
20
  <% end %>
21
21
 
22
- <%= ui_form(action: manage_flows_path, method: :post) do %>
22
+ <%= ui_form(action: flow_routes.manage_flows_path, method: :post) do %>
23
23
  <label class="block text-sm font-medium mb-1">Slug</label>
24
24
  <%= ui_input(name: "flow[slug]", placeholder: "e.g. business-scorecard") %>
25
25
 
@@ -14,13 +14,13 @@
14
14
  onclick="document.dispatchEvent(new CustomEvent('easy_flow:open-flow'))"
15
15
  class="inline-flex items-center justify-center font-semibold rounded-lg border-0 cursor-pointer bg-accent-600 text-white hover:bg-accent-700 text-base px-4 py-2">This flow</button>
16
16
 
17
- <%= ui_button(label: "Try it", href: manage_flow_preview_path(@flow), variant: :secondary) %>
17
+ <%= ui_button(label: "Try it", href: flow_routes.manage_flow_preview_path(@flow), variant: :secondary) %>
18
18
 
19
- <%= ui_button(label: "All flows", href: manage_flows_path, variant: :secondary) %>
19
+ <%= ui_button(label: "All flows", href: flow_routes.manage_flows_path, variant: :secondary) %>
20
20
  </div>
21
21
  </header>
22
22
 
23
- <%= react_ui("easy_flow/flow-editor", { base: manage_flow_canvas_path(@flow), token: form_authenticity_token, initial: @canvas },
23
+ <%= react_ui("easy_flow/flow-editor", { base: flow_routes.manage_flow_canvas_path(@flow), token: form_authenticity_token, initial: @canvas },
24
24
  class: "min-h-0 flex-1",
25
25
  data: { flow_canvas: true }) %>
26
26
  </div>
@@ -1,6 +1,6 @@
1
1
  <%= ui_page(max_width: :lg) do %>
2
2
  <p class="mb-4">
3
- <%= link_to "← Back to the flow", manage_flow_path(@flow), class: "text-sm text-accent-600 hover:text-accent-700" %>
3
+ <%= link_to "← Back to the flow", flow_routes.manage_flow_path(@flow), class: "text-sm text-accent-600 hover:text-accent-700" %>
4
4
  </p>
5
5
 
6
6
  <%= ui_page_header(title: "History", subtitle: @flow.title.presence || @flow.slug) %>
@@ -30,7 +30,7 @@
30
30
 
31
31
  <% unless version == @versions.first %>
32
32
  <%= button_to "Return the flow to this version",
33
- return_manage_flow_version_path(@flow, version),
33
+ flow_routes.return_manage_flow_version_path(@flow, version),
34
34
  form: { data: { turbo: false } }, data: { return: true },
35
35
  class: "mt-3 inline-flex items-center rounded-lg border border-gray-300 bg-white px-3 py-1.5 text-sm text-gray-900 hover:bg-gray-50 cursor-pointer" %>
36
36
  <% end %>
@@ -0,0 +1,14 @@
1
+ module EasyFlow
2
+ class HostRoutes
3
+ NAMES = %i[flow_path flow_runs_path flow_step_path run_path].freeze
4
+
5
+ def initialize(routes, prefix)
6
+ @routes = routes
7
+ @prefix = prefix
8
+ end
9
+
10
+ NAMES.each do |name|
11
+ define_method(name) { |*args, **options| @routes.public_send(:"#{@prefix}_#{name}", *args, **options) }
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module EasyFlow
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.3"
3
3
  end
data/lib/easy_flow.rb CHANGED
@@ -2,6 +2,7 @@ require "json"
2
2
  require "easy_flow/version"
3
3
  require "easy_flow/host"
4
4
  require "easy_flow/unset_host"
5
+ require "easy_flow/host_routes"
5
6
  require "easy_flow/engine"
6
7
 
7
8
  module EasyFlow
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -61,6 +61,7 @@ files:
61
61
  - app/controllers/easy_flow/manage/flows_controller.rb
62
62
  - app/controllers/easy_flow/manage/previews_controller.rb
63
63
  - app/controllers/easy_flow/manage/versions_controller.rb
64
+ - app/helpers/easy_flow/app_routes_helper.rb
64
65
  - app/javascript/easy_flow/canvas.jsx
65
66
  - app/javascript/easy_flow/canvas/Canvas.jsx
66
67
  - app/javascript/easy_flow/canvas/Connector.jsx
@@ -136,6 +137,7 @@ files:
136
137
  - lib/easy_flow.rb
137
138
  - lib/easy_flow/engine.rb
138
139
  - lib/easy_flow/host.rb
140
+ - lib/easy_flow/host_routes.rb
139
141
  - lib/easy_flow/unset_host.rb
140
142
  - lib/easy_flow/version.rb
141
143
  homepage: https://github.com/DYB-Development/easy_flow