Skip to content

Commit d957f2e

Browse files
chickenn00dleclaude
andcommitted
feat(integrations): keep activate button clickable on inactive plugin
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1ee5f52 commit d957f2e

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

packages/components/src/card-feature/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A card component for presenting a named feature or setting with a predictable, s
1111

1212
| State | Condition | Button | Dropdown | Badge |
1313
|---|---|---|---|---|
14-
| **Unmet requirements** | `requirements` is set | "Enable" — disabled | Hidden | Error badge with `requirements` text |
14+
| **Unmet requirements** | `requirements` is set | "Enable" — disabled (clickable if `requirementsActionable`) | Hidden | Error badge with `requirements` text |
1515
| **Disabled** | `!enabled`, no requirements | "Enable" | Hidden | None |
1616
| **Enabled** | `enabled`, no requirements | "Configure" | Shown if `moreControls` provided | Success badge ("Enabled") |
1717

@@ -155,6 +155,7 @@ import { __ } from '@wordpress/i18n';
155155
| `icon` | `CardFeatureIcon` || Icon displayed on the right. See `CardFeatureIcon` below. |
156156
| `enabled` | `boolean` | `false` | Whether the feature is currently enabled |
157157
| `requirements` | `string` || When set, enters the unmet-requirements state; value is used as the error badge text |
158+
| `requirementsActionable` | `boolean` | `false` | When `requirements` is set, keep the primary button clickable so it can remediate the unmet requirement |
158159
| `enableLabel` | `string` | `"Enable"` | Primary button label when not enabled |
159160
| `configureLabel` | `string` | `"Configure"` | Primary button label when enabled |
160161
| `onEnable` | `() => void` || Called when the primary button is clicked and the feature is not enabled |

packages/components/src/card-feature/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,17 @@ type CardFeatureProps = {
4949
/** Whether the feature is currently enabled. */
5050
enabled?: boolean;
5151
/**
52-
* When set, the card enters the "unmet requirements" state: the primary
53-
* button is disabled and an error badge displays this string.
52+
* When set, the card enters the "unmet requirements" state: an error
53+
* badge displays this string and the title/description are muted. By
54+
* default the primary button is disabled — set `requirementsActionable`
55+
* if the primary button is the remediation for the unmet requirement.
5456
*/
5557
requirements?: string;
58+
/**
59+
* When `requirements` is set, keep the primary button clickable so the
60+
* user can remediate the unmet requirement from this card.
61+
*/
62+
requirementsActionable?: boolean;
5663
/** Primary button label when not enabled. Default: "Enable". */
5764
enableLabel?: string;
5865
/** Primary button label when enabled. Default: "Configure". */
@@ -83,6 +90,7 @@ const CardFeature = ( {
8390
icon,
8491
enabled = false,
8592
requirements,
93+
requirementsActionable = false,
8694
enableLabel,
8795
configureLabel,
8896
onEnable,
@@ -151,7 +159,7 @@ const CardFeature = ( {
151159
<HStack expanded={ false } spacing="8px">
152160
<Button
153161
variant={ isConfigureState ? 'tertiary' : 'secondary' }
154-
disabled={ isMuted }
162+
disabled={ isMuted && ! requirementsActionable }
155163
onClick={ handleButtonClick }
156164
size="compact"
157165
>

src/wizards/audience/views/integrations/settings-section.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const SettingsSection = ( { integrations, loading, onToggleEnabled, onAct
6161
const missingPlugins = getMissingPlugins( integration );
6262
const uninstalledPlugin = missingPlugins.find( plugin => ! plugin.is_installed );
6363
const activatablePlugin = missingPlugins.length && ! uninstalledPlugin ? missingPlugins[ 0 ] : null;
64-
const requirements = uninstalledPlugin
64+
const requirements = missingPlugins.length
6565
? sprintf(
6666
/* translators: %s: comma-separated list of required plugin names. */
6767
__( 'Requires %s', 'newspack-plugin' ),
@@ -87,6 +87,7 @@ export const SettingsSection = ( { integrations, loading, onToggleEnabled, onAct
8787
icon={ INTEGRATION_ICONS[ id ] || DEFAULT_ICON }
8888
enabled={ isEnabled }
8989
requirements={ requirements }
90+
requirementsActionable={ !! activatablePlugin }
9091
enableLabel={ enableLabel }
9192
configureLabel={ needsSetup ? __( 'Configure', 'newspack-plugin' ) : undefined }
9293
onEnable={ onEnable }

0 commit comments

Comments
 (0)