Show app connection state and update link

This commit is contained in:
Maikel Linke
2023-12-14 12:57:28 +11:00
parent 12e5a0d1e1
commit e1730f25d6
5 changed files with 85 additions and 2 deletions

View File

@@ -10,7 +10,17 @@
.connected-app__connection
- if @enterprise.connected_apps.present?
.connected-app__note
= t ".note"
- link = @enterprise.connected_apps[0].data&.fetch("link", false)
- if link
%p= t ".note"
%div
%a{ href: link, target: "_blank", class: "button" }
= t ".link_label"
- else
%p
%i.spinner.fa.fa-spin.fa-circle-o-notch
 
= t ".saving_changes"
%hr
.connected-app__description

View File

@@ -15,6 +15,9 @@
}
.connected-app__note {
display: flex;
justify-content: space-between;
background-color: #f8f9fa;
border: none;
border-left: 4px solid #008397;
@@ -22,4 +25,13 @@
box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.05), 0px 2px 2px rgba(0, 0, 0, 0.07);
margin: 2em 0;
padding: 0.5em 1em;
align-items: center;
gap: 1em;
* {
flex-shrink: 0;
}
p {
flex-shrink: 1;
}
}

View File

@@ -1284,9 +1284,11 @@ en:
title: "Discover Regenerative"
tagline: "Allow website to publish your enterprise information."
action: "Share data"
saving_changes: "Saving changes"
note: |
In order for this enterprise to be published, you need to include
regenerative details and accept the Terms and Conditions.
link_label: "Update details"
description_html: |
<p>
Discover Regenerative makes it easier for buyers to discover

View File

@@ -0,0 +1,54 @@
---
http_interactions:
- request:
method: post
uri: https://n8n.openfoodnetwork.org.uk/webhook/regen/connect-enterprise
body:
encoding: UTF-8
string: '{"id":"4da377c8-0c8f-4aaa-8f85-f2a218a13d6e","at":"2023-12-14 12:52:53
+1100","event":"connect-app","data":{"enterprise_id":45,"access_token":"2c5f828a1da2f5a87798e6d3ee44daee6729b2963db6d264"}}'
headers:
User-Agent:
- openfoodnetwork_webhook/1.0
Content-Type:
- application/json
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept:
- "*/*"
response:
status:
code: 200
message: OK
headers:
Server:
- nginx
Date:
- Thu, 14 Dec 2023 01:52:55 GMT
Content-Type:
- text/html; charset=utf-8
Content-Length:
- '35'
Connection:
- keep-alive
Etag:
- W/"23-GW39X6dSljjgz4GPY7ICa+eNupE"
Vary:
- Accept-Encoding
Strict-Transport-Security:
- max-age=63072000
X-Xss-Protection:
- 1; mode=block
X-Download-Options:
- noopen
X-Content-Type-Options:
- nosniff
X-Permitted-Cross-Domain-Policies:
- none
Referrer-Policy:
- same-origin
body:
encoding: UTF-8
string: '{"link":"https://example.net/edit"}'
recorded_at: Thu, 14 Dec 2023 01:52:55 GMT
recorded_with: VCR 6.2.0

View File

@@ -2,7 +2,7 @@
require "system_helper"
describe "Connected Apps", feature: :connected_apps do
describe "Connected Apps", feature: :connected_apps, vcr: true do
let(:enterprise) { create(:enterprise) }
before do
@@ -37,6 +37,11 @@ describe "Connected Apps", feature: :connected_apps do
click_button "Share data"
expect(page).to_not have_button "Share data"
expect(page).to have_content "Saving changes"
perform_enqueued_jobs(only: ConnectAppJob)
page.refresh # TODO: update via cable_ready
expect(page).to have_content "include regenerative details"
expect(page).to have_link "Update details"
end
end