mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Add Vine connected app
The connection/disconnection logic is yet to be implemented
This commit is contained in:
@@ -4,13 +4,14 @@
|
||||
#
|
||||
# Here we store keys and links to access the app.
|
||||
class ConnectedApp < ApplicationRecord
|
||||
TYPES = ['discover_regen', 'affiliate_sales_data'].freeze
|
||||
TYPES = ['discover_regen', 'affiliate_sales_data', 'vine'].freeze
|
||||
|
||||
belongs_to :enterprise
|
||||
after_destroy :disconnect
|
||||
|
||||
scope :discover_regen, -> { where(type: "ConnectedApp") }
|
||||
scope :affiliate_sales_data, -> { where(type: "ConnectedApps::AffiliateSalesData") }
|
||||
scope :vine, -> { where(type: "ConnectedApps::Vine") }
|
||||
|
||||
scope :connecting, -> { where(data: nil) }
|
||||
scope :ready, -> { where.not(data: nil) }
|
||||
|
||||
15
app/models/connected_apps/vine.rb
Normal file
15
app/models/connected_apps/vine.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# An enterprise can opt-in to use VINE API to manage vouchers
|
||||
#
|
||||
module ConnectedApps
|
||||
class Vine < ConnectedApp
|
||||
def connect(api_key: )
|
||||
# TODO
|
||||
end
|
||||
|
||||
def disconnect
|
||||
# TODO
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
%section.connected_app
|
||||
.connected-app__head
|
||||
%div
|
||||
%h3= t ".title"
|
||||
%p= t ".tagline"
|
||||
.connected-app__vine
|
||||
- if connected_app.nil?
|
||||
= form_with url: admin_enterprise_connected_apps_path(enterprise.id) do |f|
|
||||
.connected-app__vine-content
|
||||
.vine-api-key
|
||||
= f.hidden_field :type, value: "ConnectedApps::Vine"
|
||||
= f.label :vine_api_key, t(".vine_api_key")
|
||||
%span.required *
|
||||
= f.text_field :vine_api_key, { disabled: !managed_by_user?(enterprise) }
|
||||
%div
|
||||
- disabled = managed_by_user?(enterprise) ? {} : { disabled: true, "data-disable-with": false }
|
||||
= f.submit t(".enable"), disabled
|
||||
|
||||
-# This is only seen by super-admins:
|
||||
%em= t(".need_to_be_manager") unless managed_by_user?(enterprise)
|
||||
- else
|
||||
.connected-app__vine-content
|
||||
.vine-disable
|
||||
= button_to t(".disable"), admin_enterprise_connected_app_path(connected_app.id, enterprise_id: enterprise.id), method: :delete
|
||||
%hr
|
||||
.connected-app__description
|
||||
= t ".description_html"
|
||||
@@ -34,7 +34,9 @@
|
||||
border: none;
|
||||
border-left: $border-radius solid $color-3;
|
||||
border-radius: $border-radius;
|
||||
box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.05), 0px 2px 2px rgba(0, 0, 0, 0.07);
|
||||
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;
|
||||
|
||||
@@ -47,3 +49,22 @@
|
||||
flex-shrink: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.connected-app__vine {
|
||||
margin: 1em 0;
|
||||
|
||||
.connected-app__vine-content {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: end;
|
||||
|
||||
.vine-api-key {
|
||||
width: 100%;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.vine-disable {
|
||||
margin-left: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,6 +753,7 @@ en:
|
||||
connected_apps_enabled:
|
||||
discover_regen: Discover Regenerative portal
|
||||
affiliate_sales_data: DFC anonymised orders API for research purposes
|
||||
vine: Voucher Engine (VINE)
|
||||
update:
|
||||
resource: Connected app settings
|
||||
|
||||
@@ -1418,6 +1419,22 @@ en:
|
||||
target="_blank"><b>Learn more about Discover Regenerative</b>
|
||||
<i class="icon-external-link"></i></a>
|
||||
</p>
|
||||
vine:
|
||||
title: "Voucher Engine (VINE)"
|
||||
tagline: "Enable the use of VINE api to handle vouchers"
|
||||
enable: "Connect"
|
||||
disable: "Disconnect"
|
||||
need_to_be_manager: "Only managers can connect apps."
|
||||
vine_api_key: "VINE API Key"
|
||||
description_html: |
|
||||
<p>
|
||||
To enable VINE for your enterprise, enter your API key.
|
||||
</p>
|
||||
<p>
|
||||
<a href="#" target="_blank"><b>VINE</b>
|
||||
<i class="icon-external-link"></i></a>
|
||||
</p>
|
||||
|
||||
actions:
|
||||
edit_profile: Settings
|
||||
properties: Properties
|
||||
|
||||
Reference in New Issue
Block a user