collavre_slack 0.2.6 → 0.2.8
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8700d4cf3be0ac6d384a5d4860da91cffb2216951c2689e480103d833100dac1
|
|
4
|
+
data.tar.gz: 050735120aa672d534ec4473aa83e7996e0b1e688d0581bccbd93a1a3d5a4eef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 301365a9d7c37b398a393ddf9aafc80a77352fbff14b006ee25deccf7f5b8dc04a64ff26922e850a009988c9dc9e8f8a2c56fd13aaae82f44942ef2298720b6f
|
|
7
|
+
data.tar.gz: 627a82d5443d629fd14080ade5af31b634d8bf3682803a0725bed22d1e1e22d0c7ea7d071f312c12a424527a419d04875824ff778d74a5dddebf95186d206177
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { filterChannels, reconcileSelection, buildChannelViewModels } from './slack_channel_list.js';
|
|
2
2
|
import { csrfToken, showError, clearError, updateStepVisibility, openOAuthPopup, fetchWithCsrf, setupModalClose } from 'collavre/modules/integration_wizard';
|
|
3
|
+
import { alertDialog, confirmDialog } from 'collavre/lib/utils/dialog';
|
|
3
4
|
|
|
4
5
|
let slackIntegrationInitialized = false;
|
|
5
6
|
|
|
@@ -152,7 +153,7 @@ if (!slackIntegrationInitialized) {
|
|
|
152
153
|
deleteBtn.textContent = modal.dataset.deleteButtonLabel || 'Remove';
|
|
153
154
|
deleteBtn.style.cssText = 'padding:0.25em 0.5em;font-size:0.8em;';
|
|
154
155
|
deleteBtn.addEventListener('click', function () {
|
|
155
|
-
performDeleteLink(link);
|
|
156
|
+
performDeleteLink(link, deleteBtn);
|
|
156
157
|
});
|
|
157
158
|
|
|
158
159
|
li.appendChild(channelInfo);
|
|
@@ -189,10 +190,9 @@ if (!slackIntegrationInitialized) {
|
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
|
|
192
|
-
function performDeleteLink(link) {
|
|
193
|
-
if (!
|
|
193
|
+
async function performDeleteLink(link, btn) {
|
|
194
|
+
if (!(await confirmDialog(modal.dataset.deleteConfirm, { danger: true }))) return;
|
|
194
195
|
|
|
195
|
-
const btn = event.target;
|
|
196
196
|
btn.disabled = true;
|
|
197
197
|
btn.textContent = '...';
|
|
198
198
|
clearError(errorEl);
|
|
@@ -334,7 +334,7 @@ if (!slackIntegrationInitialized) {
|
|
|
334
334
|
openBtn.addEventListener('click', function () {
|
|
335
335
|
creativeId = this.dataset.creativeId;
|
|
336
336
|
if (!creativeId) {
|
|
337
|
-
|
|
337
|
+
alertDialog(modal.dataset.noCreative);
|
|
338
338
|
return;
|
|
339
339
|
}
|
|
340
340
|
modal.style.display = 'flex';
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
+
# Register Slack OAuth keys with the IntegrationSettings registry so the admin
|
|
2
|
+
# UI can surface them and `Collavre::IntegrationSettings::Resolver` can serve
|
|
3
|
+
# values via the DB > ENV > default precedence. Wrapped in `to_prepare` so
|
|
4
|
+
# definitions re-register on code reload in development.
|
|
5
|
+
Rails.application.config.to_prepare do
|
|
6
|
+
if defined?(Collavre::IntegrationSettings::Registry)
|
|
7
|
+
Collavre::IntegrationSettings::Registry.instance.register(
|
|
8
|
+
:slack_client_id, category: "slack", sensitive: false, requires_restart: true
|
|
9
|
+
)
|
|
10
|
+
Collavre::IntegrationSettings::Registry.instance.register(
|
|
11
|
+
:slack_client_secret, category: "slack", sensitive: true, requires_restart: true
|
|
12
|
+
)
|
|
13
|
+
Collavre::IntegrationSettings::Registry.instance.register(
|
|
14
|
+
:slack_signing_secret, category: "slack", sensitive: true, requires_restart: true
|
|
15
|
+
)
|
|
16
|
+
Collavre::IntegrationSettings::Registry.instance.register(
|
|
17
|
+
:slack_redirect_uri, category: "slack", sensitive: false, requires_restart: true
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Scopes still come from ENV (not registered as a managed integration setting
|
|
23
|
+
# in Phase 1). OAuth credentials are now resolved lazily by Configuration via
|
|
24
|
+
# the Resolver, so they are no longer assigned here.
|
|
1
25
|
CollavreSlack.configure do |config|
|
|
2
|
-
config.client_id = ENV.fetch("SLACK_CLIENT_ID", config.client_id)
|
|
3
|
-
config.client_secret = ENV.fetch("SLACK_CLIENT_SECRET", config.client_secret)
|
|
4
|
-
config.signing_secret = ENV.fetch("SLACK_SIGNING_SECRET", config.signing_secret)
|
|
5
|
-
config.redirect_uri = ENV.fetch("SLACK_REDIRECT_URI", config.redirect_uri)
|
|
6
26
|
config.scopes = ENV.fetch("SLACK_SCOPES", config.scopes)
|
|
7
27
|
end
|
|
@@ -1,13 +1,51 @@
|
|
|
1
1
|
module CollavreSlack
|
|
2
|
+
# Slack engine configuration.
|
|
3
|
+
#
|
|
4
|
+
# OAuth credential getters (`client_id`, `client_secret`, `signing_secret`,
|
|
5
|
+
# `redirect_uri`) resolve through `Collavre::IntegrationSettings::Resolver`,
|
|
6
|
+
# which honors the DB > ENV > registered default precedence. Writers are
|
|
7
|
+
# preserved so tests and explicit `CollavreSlack.configure` overrides keep
|
|
8
|
+
# working: an explicitly-assigned value short-circuits the resolver.
|
|
9
|
+
#
|
|
10
|
+
# Fallback to plain `ENV[...]` when the resolver is not usable:
|
|
11
|
+
# - `integration_settings` table missing (db:create, db:schema:load,
|
|
12
|
+
# assets:precompile, fresh installs)
|
|
13
|
+
# - DB connection not established
|
|
14
|
+
# - `Collavre::IntegrationSettings` API not present in the installed
|
|
15
|
+
# core `collavre` gem (e.g. `USE_COLLAVRE_GEM=true` pinned to a
|
|
16
|
+
# version predating this feature)
|
|
2
17
|
class Configuration
|
|
3
|
-
|
|
18
|
+
RESOLVER_KEYS = {
|
|
19
|
+
client_id: { registry: :slack_client_id, env: "SLACK_CLIENT_ID" },
|
|
20
|
+
client_secret: { registry: :slack_client_secret, env: "SLACK_CLIENT_SECRET" },
|
|
21
|
+
signing_secret: { registry: :slack_signing_secret, env: "SLACK_SIGNING_SECRET" },
|
|
22
|
+
redirect_uri: { registry: :slack_redirect_uri, env: "SLACK_REDIRECT_URI" }
|
|
23
|
+
}.freeze
|
|
24
|
+
|
|
25
|
+
attr_writer :client_id, :client_secret, :signing_secret, :redirect_uri
|
|
26
|
+
attr_accessor :scopes
|
|
4
27
|
|
|
5
28
|
def initialize
|
|
6
|
-
@client_id = ENV.fetch("SLACK_CLIENT_ID", "")
|
|
7
|
-
@client_secret = ENV.fetch("SLACK_CLIENT_SECRET", "")
|
|
8
|
-
@signing_secret = ENV.fetch("SLACK_SIGNING_SECRET", "")
|
|
9
|
-
@redirect_uri = ENV.fetch("SLACK_REDIRECT_URI", "")
|
|
10
29
|
@scopes = ENV.fetch("SLACK_SCOPES", "chat:write,channels:read,channels:history,groups:read,im:read,mpim:read,users:read,users:read.email,reactions:read,reactions:write")
|
|
11
30
|
end
|
|
31
|
+
|
|
32
|
+
RESOLVER_KEYS.each do |attr, meta|
|
|
33
|
+
define_method(attr) do
|
|
34
|
+
ivar = instance_variable_get(:"@#{attr}")
|
|
35
|
+
return ivar unless ivar.nil?
|
|
36
|
+
|
|
37
|
+
resolve_setting(meta[:registry], meta[:env])
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def resolve_setting(registry_key, env_var)
|
|
44
|
+
return ENV[env_var] unless defined?(Collavre::IntegrationSettings::Resolver)
|
|
45
|
+
|
|
46
|
+
Collavre::IntegrationSettings::Resolver.get(registry_key)
|
|
47
|
+
rescue ActiveRecord::StatementInvalid, ActiveRecord::ConnectionNotEstablished
|
|
48
|
+
ENV[env_var]
|
|
49
|
+
end
|
|
12
50
|
end
|
|
13
51
|
end
|