Skip to content

Commit 5d18855

Browse files
committed
Fix gateway component lint formatting
1 parent d65e570 commit 5d18855

2 files changed

Lines changed: 49 additions & 14 deletions

File tree

addon/components/gateway/details.js

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,42 @@ export default class GatewayDetailsComponent extends Component {
117117
return this.diagnosticSummary.last_test_order_id;
118118
}
119119

120+
get credentialTileValue() {
121+
if (this.credentialStatus === 'success' || this.credentialStatus === 'ok') {
122+
return 'Verified';
123+
}
124+
125+
if (this.credentialStatus === 'failed') {
126+
return 'Failed';
127+
}
128+
129+
return 'Not Checked';
130+
}
131+
132+
get credentialAccentClass() {
133+
if (this.credentialStatus === 'success' || this.credentialStatus === 'ok') {
134+
return 'ledger-gateway-kpi-accent-green';
135+
}
136+
137+
if (this.credentialStatus === 'failed') {
138+
return 'ledger-gateway-kpi-accent-rose';
139+
}
140+
141+
return 'ledger-gateway-kpi-accent-slate';
142+
}
143+
144+
get webhookRegistrationResultMessage() {
145+
if (this.lastWebhookRegistrationAt) {
146+
return 'Provider webhook registration completed.';
147+
}
148+
149+
if (this.webhookStatus === 'configured') {
150+
return 'Webhook URL is configured, but no registration action has been recorded.';
151+
}
152+
153+
return 'No provider webhook registration stored.';
154+
}
155+
120156
get readinessItems() {
121157
return [
122158
{
@@ -145,16 +181,11 @@ export default class GatewayDetailsComponent extends Component {
145181
},
146182
{
147183
label: 'Credentials',
148-
value: this.credentialStatus === 'success' || this.credentialStatus === 'ok' ? 'Verified' : this.credentialStatus === 'failed' ? 'Failed' : 'Not Checked',
184+
value: this.credentialTileValue,
149185
status: this.credentialStatus,
150186
icon: 'key',
151187
caption: this.lastCredentialTestedAt ? 'Last provider auth test' : 'Run a provider check',
152-
accentClass:
153-
this.credentialStatus === 'success' || this.credentialStatus === 'ok'
154-
? 'ledger-gateway-kpi-accent-green'
155-
: this.credentialStatus === 'failed'
156-
? 'ledger-gateway-kpi-accent-rose'
157-
: 'ledger-gateway-kpi-accent-slate',
188+
accentClass: this.credentialAccentClass,
158189
},
159190
];
160191
}
@@ -307,11 +338,7 @@ export default class GatewayDetailsComponent extends Component {
307338
},
308339
{
309340
label: 'Webhook registration',
310-
value: this.lastWebhookRegistrationAt
311-
? 'Provider webhook registration completed.'
312-
: this.webhookStatus === 'configured'
313-
? 'Webhook URL is configured, but no registration action has been recorded.'
314-
: 'No provider webhook registration stored.',
341+
value: this.webhookRegistrationResultMessage,
315342
date: this.lastWebhookRegistrationAt,
316343
status: this.lastWebhookRegistrationAt ? 'success' : 'warning',
317344
},

addon/components/gateway/form.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export default class GatewayFormComponent extends Component {
190190
// When bound via {{on "input" (fn this.updateConfigField field.key)}} the second
191191
// argument is a DOM InputEvent, not the raw string value. Extract the actual
192192
// value from event.target.value in that case so credentials are stored correctly.
193-
const resolvedValue = value instanceof Event ? (value.target?.value ?? value) : (value?.value ?? value);
193+
const resolvedValue = this.resolveFieldValue(value);
194194
this.configValues = { ...this.configValues, [key]: resolvedValue };
195195
// Persist config back to the resource
196196
this.args.resource.set?.('config', { ...this.configValues });
@@ -216,10 +216,18 @@ export default class GatewayFormComponent extends Component {
216216
}
217217

218218
@action setResourceField(field, value) {
219-
const resolvedValue = value instanceof Event ? (value.target?.value ?? value) : (value?.value ?? value);
219+
const resolvedValue = this.resolveFieldValue(value);
220220
this.args.resource?.set?.(field, resolvedValue);
221221
}
222222

223+
resolveFieldValue(value) {
224+
if (value instanceof Event) {
225+
return value.target?.value ?? value;
226+
}
227+
228+
return value?.value ?? value;
229+
}
230+
223231
@action goToStep(index) {
224232
this.activeStep = index;
225233
}

0 commit comments

Comments
 (0)