Skip to content

Commit a5db3c8

Browse files
authored
Merge pull request #16 from woocommerce/feat/simplify-api-key-flow
Simplify API key flow: always read-only + redesigned post-connect card
2 parents 66cb655 + 337a782 commit a5db3c8

6 files changed

Lines changed: 196 additions & 486 deletions

File tree

includes/setup/assets/setup.css

Lines changed: 78 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,6 @@ select.hey-woo-setup__input {
183183
line-height: 1.5;
184184
}
185185

186-
.hey-woo-setup__field-help--write-warn {
187-
background: #fff8e5;
188-
border-left: 3px solid #f0c33c;
189-
color: #5a4200;
190-
padding: 8px 10px;
191-
border-radius: 0 3px 3px 0;
192-
}
193-
194186
/* ---- Action row (right-aligned button zone) ---- */
195187

196188
.hey-woo-setup__actions {
@@ -208,35 +200,102 @@ select.hey-woo-setup__input {
208200
justify-content: space-between;
209201
gap: 16px;
210202
flex-wrap: wrap;
211-
padding-bottom: 18px;
212-
margin-bottom: 18px;
213-
border-bottom: 1px solid #f0f0f1;
214203
}
215204

216205
.hey-woo-setup__keyrow-meta {
217206
min-width: 0;
218207
flex: 1 1 auto;
219208
}
220209

221-
.hey-woo-setup__keyrow-meta p {
210+
.hey-woo-setup__keyrow-label {
211+
display: flex;
212+
align-items: center;
213+
gap: 10px;
214+
margin-bottom: 6px;
215+
}
216+
217+
/*
218+
* The label is already styled via .hey-woo-setup__field-label, but it
219+
* carries a default margin-bottom that adds an extra gap below the
220+
* row when it lives inside the flex container above. Reset to 0 so
221+
* the keyrow-label gap is the only spacing between the label and the
222+
* pill.
223+
*/
224+
.hey-woo-setup__keyrow-label .hey-woo-setup__field-label {
225+
margin-bottom: 0;
226+
}
227+
228+
/*
229+
* Connection status pill. Borrows the colour palette from WooCommerce
230+
* core's order-status pills (status-processing for LIVE, status-cancelled
231+
* for OFF) so the indicator reads visually consistent with the rest of
232+
* WC admin without coupling to WC's actual `.order-status` selectors —
233+
* those are scoped to the order list and could shift in a future WC
234+
* release.
235+
*/
236+
.hey-woo-setup__pill {
237+
display: inline-flex;
238+
align-items: center;
239+
padding: 2px 10px;
240+
background: #e5e5e5;
241+
color: #777;
242+
font-size: 10px;
243+
font-weight: 600;
244+
letter-spacing: .05em;
245+
text-transform: uppercase;
246+
border-radius: 12px;
247+
line-height: 1.6;
248+
}
249+
250+
.hey-woo-setup__pill--live {
251+
background: #c6e1c6;
252+
color: #5b841b;
253+
}
254+
255+
.hey-woo-setup__pill--off {
256+
background: #e5e5e5;
257+
color: #777;
258+
}
259+
260+
.hey-woo-setup__keyrow-name {
222261
margin: 0;
223-
font-size: 14px;
262+
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
263+
font-size: 13px;
224264
color: #1d2327;
225265
}
226266

227267
.hey-woo-setup__keyrow-actions {
228268
display: flex;
229-
gap: 8px;
269+
align-items: center;
270+
gap: 18px;
230271
flex-wrap: wrap;
231272
}
232273

274+
.hey-woo-setup__textlink {
275+
color: #2271b1;
276+
text-decoration: underline;
277+
font-size: 14px;
278+
line-height: 1.5;
279+
}
280+
281+
.hey-woo-setup__textlink:hover,
282+
.hey-woo-setup__textlink:focus {
283+
color: #135e96;
284+
}
285+
233286
/*
234-
* Permissions toggle below the keyrow. The keyrow's bottom border
235-
* already provides the separator; drop the field's bottom margin so
236-
* the card padding handles spacing to Step 2.
287+
* Help text below the keyrow. Same colour/size as field-help, with
288+
* extra top margin to separate from the keyrow's flex row instead of
289+
* a stacked field above. Surfaces the rotation-on-escalation guidance
290+
* (regenerate before broadening if the bundle has been shared) and
291+
* the Read/Write vs. Write distinction without putting the controls
292+
* back in this card.
237293
*/
238-
.hey-woo-setup__field--keyperms {
239-
margin-bottom: 0;
294+
.hey-woo-setup__keyrow-help {
295+
margin: 14px 0 0;
296+
color: #6b7280;
297+
font-size: 12px;
298+
line-height: 1.5;
240299
}
241300

242301
/* ---- Tabs (Step 2) ---- */

includes/setup/assets/setup.js

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
* Hey Woo setup page client-side wiring.
33
*
44
* - Tab switcher for the Step 2 "Easy install" / "Manual setup" panels.
5-
* - Generate button that reads the description + permissions form
6-
* fields and navigates to the nonce-protected admin-post URL with
7-
* those values appended as query args.
8-
* - Inline "Read + Write" warning toggle on the permissions dropdown.
95
* - Copy-to-clipboard for the manual snippets.
106
*/
117
(function () {
@@ -58,69 +54,6 @@
5854
});
5955
}
6056

61-
function initGenerate() {
62-
var button = document.querySelector('[data-hey-woo-generate]');
63-
if (!button) {
64-
return;
65-
}
66-
67-
button.addEventListener('click', function () {
68-
if (button.disabled) {
69-
return;
70-
}
71-
var base = button.getAttribute('data-hey-woo-action-base') || '';
72-
if (!base) {
73-
return;
74-
}
75-
76-
var permissionsInput = document.getElementById('hey-woo-permissions');
77-
var permissions = permissionsInput ? permissionsInput.value : 'read';
78-
79-
var separator = base.indexOf('?') >= 0 ? '&' : '?';
80-
var url = base + separator + 'permissions=' + encodeURIComponent(permissions);
81-
82-
button.disabled = true;
83-
button.textContent = button.dataset.busyLabel || 'Generating…';
84-
window.location.href = url;
85-
});
86-
}
87-
88-
function initWriteWarning() {
89-
var permissionsInput = document.getElementById('hey-woo-permissions');
90-
var warning = document.querySelector('[data-hey-woo-write-warning]');
91-
if (!permissionsInput || !warning) {
92-
return;
93-
}
94-
95-
function update() {
96-
warning.hidden = permissionsInput.value !== 'read_write';
97-
}
98-
99-
permissionsInput.addEventListener('change', update);
100-
update();
101-
}
102-
103-
function initPermsToggle() {
104-
var select = document.querySelector('[data-hey-woo-perm-toggle]');
105-
if (!select) {
106-
return;
107-
}
108-
// Snapshot the on-load value so a no-op change doesn't trigger
109-
// navigation, and so we can restore the visible value if the
110-
// admin uses the back button without the page reloading.
111-
select.dataset.previousValue = select.value;
112-
113-
select.addEventListener('change', function () {
114-
var option = select.options[select.selectedIndex];
115-
var url = option ? option.getAttribute('data-url') : '';
116-
if (!url || select.value === select.dataset.previousValue) {
117-
return;
118-
}
119-
select.disabled = true;
120-
window.location.href = url;
121-
});
122-
}
123-
12457
function copyText(text, button) {
12558
if (!text) {
12659
return;
@@ -184,9 +117,6 @@
184117

185118
function init() {
186119
initTabs();
187-
initGenerate();
188-
initWriteWarning();
189-
initPermsToggle();
190120
initCopy();
191121
}
192122

0 commit comments

Comments
 (0)