forked from Stwissel/node-red-contrib-salesforce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection-config.html
183 lines (178 loc) · 8.46 KB
/
connection-config.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<script type="text/javascript">
RED.nodes.registerType('connection-config', {
category: 'config',
defaults: {
name: {
value: '',
required: true
},
poturl: {
value: '',
required: false
},
consumerKey: {
value: '',
required: false
},
consumerSecret: {
value: '',
required: false
},
callbackUrl: {
required: true
},
environment: {
value: 'production',
required: true
},
useEnvCredentials: {
value: true
},
allowMsgCredentials: {
value: false
},
username: {
value: '',
required: false
},
password: {
value: '',
required: false
},
},
label: function() {
return this.name || this.username + ' connection';
},
oneditprepare: function() {
setTimeout(function() {
var jqCurDialog = $("[aria-describedby='node-config-dialog']:visible");
var dialogWidth = ($(window).width() - 100);
if (dialogWidth > 700) {
dialogWidth = 700;
}
jqCurDialog.css('width', dialogWidth);
jqCurDialog.css('left', (($(window).width() - dialogWidth) / 2));
// jqCurDialog.css('min-height', '580px');
// increase for form field size
$(".form-row label").width('150px');
}, 0);
$("#node-config-input-useEnvCredentials").change(function() {
$("#credentials").toggle(!this.checked);
});
$("#node-config-input-environment").change(function() {
var curEnv = $("#node-config-input-environment");
if (curEnv.val() && curEnv.val().substring(0, 6) == 'custom') {
$("#node-config-rown-poturl").show();
} else {
$("#node-config-rown-poturl").hide();
}
});
},
// reset the form label size
oneditsave: function() {
if (this.useEnvCredentials) {
delete this.username;
delete this.password;
delete this.consumerKey;
delete this.consumerSecret;
}
//$(".form-row label").width('100px');
},
// reset the form label size
oneditcancel: function() {
//$(".form-row label").width('100px');
},
oneditdelete: function() {
//$(".form-row label").width('100px');
}
});
</script>
<script type="text/x-red" data-template-name="connection-config">
<div class="form-row">
<label for="node-config-input-name"><i class="icon-bookmark"></i> Name</label>
<input type="text" id="node-config-input-name" />
</div>
<div class="form-row" style="white-space:nowrap">
<label for="node-config-input-callbackUrl"><i class="fa fa-history"></i> Callback URL</label>
<input type="text" id="node-config-input-callbackUrl" placeholder="http://localhost:3000/oauth/_callback" />
</div>
<div class="form-row">
<label for="node-config-input-environment"><i class="fa fa-tasks"></i> Environment</label>
<select id="node-config-input-environment">
<option value="production">Production</option>
<option value="sandbox">Sandbox</option>
<option value="customproduction">Production (Custom)</option>
<option value="customsandbox">Sandbox (Custom)</option>
<option value="custommarketing">Marketing Cloud (Custom)</option>
<option value="customcommerce">Commerce Cloud (Custom)</option>
</select>
</div>
<div class="form-row" id="node-config-rown-poturl">
<label for="node-config-input-poturl"><i class="icon-bookmark"></i> Instance URL</label>
<input type="text" id="node-config-input-poturl" />
</div>
<div class="form-row">
<input type="checkbox" id="node-config-input-allowMsgCredentials" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-config-input-allowMsgCredentials" style="width: auto; white-space:nowrap;">Allow credentials in msg object</label>
</div>
<div class="form-row">
<input type="checkbox" id="node-config-input-useEnvCredentials" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-config-input-useEnvCredentials" style="width: auto; white-space:nowrap;">Use environment variables for credentials</label>
</div>
<div id="credentials">
<div class="form-row credentials" style="white-space:nowrap">
<label for="node-config-input-consumerKey"><i class="fa fa-key"></i> Consumer Key</label>
<input type="text" id="node-config-input-consumerKey" />
</div>
<div class="form-row credentials" style="white-space:nowrap">
<label for="node-config-input-consumerSecret"><i class="fa fa-user-secret"></i> Consumer Secret</label>
<input type="password" id="node-config-input-consumerSecret" />
</div>
<div class="form-row credentials">
<label for="node-config-input-username"><i class="fa fa-user"></i> Username</label>
<input type="text" id="node-config-input-username" />
</div>
<div class="form-row credentials">
<label for="node-config-input-password"><i class="fa fa-lock"></i> Password</label>
<input type="password" id="node-config-input-password" />
</div>
</div>
</script>
<script type="text/x-red" data-help-name="connection-config">
<h3>Setting up a config node</h3>
<ul>
<li><b>Name</b>: NodeRED internal name of the connection. When you use environment credentials: prefix of the credential variables (see below)
</li>
<li><b>Callback URL</b>: needs to match the setting in the connected app. use <code><NodeRedURL>/oauth/_callback</code> as default
</li>
<li><b>Environment</b>: Production or Sandbox. DevEditions are Sandbox. When you pick the "custom" option, you can specify the URL of your specific instance. This avoids potential "connection" error that sometimes occurs with oauth
</li>
<li><b>Instance URL</b> (only shows for Environment "custom"): URL to your Salesforce instance (optional). Use it when you get "invalid client id" errors when connecting to Salesforce or when you use a ScratchOrg
</li>
<li><b>Allow credentials in msg object</b>: With this option enabled the configuration is checking for the <code>sf</code> property in the msg object and retrieves username, password, ConsumerKey and ConsumerSecret from it. (Thx to benariss for the
idea/code)
</li>
<li><b>Use environment credentials</b>: Ignores the credential entries below and tries to read environment variables (e.g from a Heroku deployment). The variables are the name of this node and _ConsumerKey, _ConsumerSecret, _UserName and _Password.
So if this Node is called <code>SFTest</code>, it will look for:
<ul>
<li>Consumer Key: <code>SFTest_ConsumerKey</code></li>
<li>Consumer Secret: <code>SFTest_ConsumerSecret</code></li>
<li>User Name: <code>SFTest_UserName</code></li>
<li>Password: <code>SFTest_PassWord</code></li>
</ul>
Typically user name used here is the integration user
</li>
<li>Environment credentials <b>unchecked</b>: Fill in the values (will get updated in future)
<ul>
<li><b>Consumer Key</b>: Values from the Connected App setting in your instance
</li>
<li><b>Consumer Secret</b>: Values from the Connected App setting in your instance
</li>
<li><b>Username</b>: Credentials to get an Oauth token. Typically integration user. Not recommended, use environment instead
</li>
<li><b>Username/Password</b>: Credentials to get an Oauth token. Typically integration user. Not recommended, use environment instead
</li>
</ul>
</li>
</ul>
</script>