Skip to content

Commit 3b39023

Browse files
Merge pull request #723 from mbaldessari/ui-variants
Implement variants UI support
2 parents a571361 + 4cf9845 commit 3b39023

4 files changed

Lines changed: 43 additions & 11 deletions

File tree

console/locales/en/plugin__patterns-operator-console-plugin.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"Back to catalog": "Back to catalog",
99
"Cancel": "Cancel",
1010
"Catalog": "Catalog",
11+
"Catalog logo": "Catalog logo",
1112
"Catalog source": "Catalog source",
1213
"Checking vault status": "Checking vault status",
1314
"Cluster": "Cluster",
@@ -22,7 +23,6 @@
2223
"Enter manual value": "Enter manual value",
2324
"Enter or update the secrets that will be injected into Vault for this pattern. Fields left empty will retain their existing values in Vault.": "Enter or update the secrets that will be injected into Vault for this pattern. Fields left empty will retain their existing values in Vault.",
2425
"Enter or update the secrets that will be injected into Vault for this pattern. File and INI fields must be uploaded each time. Other fields may be left empty to keep existing Vault values.": "Enter or update the secrets that will be injected into Vault for this pattern. File and INI fields must be uploaded each time. Other fields may be left empty to keep existing Vault values.",
25-
"Enter value for {{fieldName}}": "Enter value for {{fieldName}}",
2626
"Error": "Error",
2727
"Extracted value preview": "Extracted value preview",
2828
"Failed to create pattern": "Failed to create pattern",
@@ -64,7 +64,6 @@
6464
"Pattern Status": "Pattern Status",
6565
"Pattern successfully removed": "Pattern successfully removed",
6666
"Patterns": "Patterns",
67-
"Please provide a value for this required field": "Please provide a value for this required field",
6867
"Reconciliation complete. Redirecting to catalog...": "Reconciliation complete. Redirecting to catalog...",
6968
"Reconciliation complete. Waiting for secret injection to finish...": "Reconciliation complete. Waiting for secret injection to finish...",
7069
"Reconciliation Status": "Reconciliation Status",
@@ -76,6 +75,7 @@
7675
"Secrets submitted successfully": "Secrets submitted successfully",
7776
"Select a section": "Select a section",
7877
"Select INI section": "Select INI section",
78+
"Select variant": "Select variant",
7979
"Spoke": "Spoke",
8080
"Static value": "Static value",
8181
"Sync": "Sync",
@@ -85,14 +85,14 @@
8585
"Tested Requirements:": "Tested Requirements:",
8686
"The pattern and all its associated resources have been fully deleted.": "The pattern and all its associated resources have been fully deleted.",
8787
"The vault injection job has been created.": "The vault injection job has been created.",
88-
"This field is required": "This field is required",
8988
"This is the sizing that has been tested. The pattern is expected to work on any similarly-sized architecture.": "This is the sizing that has been tested. The pattern is expected to work on any similarly-sized architecture.",
9089
"This pattern does not have a secret template defined.": "This pattern does not have a secret template defined.",
9190
"This will delete the pattern and all its deployed resources.": "This will delete the pattern and all its deployed resources.",
9291
"Tier": "Tier",
9392
"Uninstall": "Uninstall",
9493
"Uninstall Pattern": "Uninstall Pattern",
9594
"Upload an INI/configuration file to extract values": "Upload an INI/configuration file to extract values",
95+
"Variant": "Variant",
9696
"Vault policy: {{policy}}": "Vault policy: {{policy}}",
9797
"Vault Secret Injection": "Vault Secret Injection",
9898
"Waiting for applications": "Waiting for applications",

console/src/components/InstallPatternPage.tsx

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
DescriptionListTerm,
1818
Form,
1919
FormGroup,
20+
FormSelect,
21+
FormSelectOption,
2022
Label,
2123
PageSection,
2224
Spinner,
@@ -39,7 +41,7 @@ import {
3941
getMissingFileAndIniFields,
4042
secretTemplateHasFileOrIniFields,
4143
} from '../vaultSecrets';
42-
import { SecretTemplate, SecretFormData } from '../types';
44+
import { SecretTemplate, SecretFormData, Variant } from '../types';
4345
import { SecretFormExpandableSections } from './SecretForm/SecretFormExpandableSections';
4446
import { VaultInjectionStatusAlert } from './SecretForm/VaultInjectionStatusAlert';
4547
import './SecretForm/SecretForm.css';
@@ -73,6 +75,7 @@ export default function InstallPatternPage() {
7375
const [useOwnFork, setUseOwnFork] = React.useState(false);
7476
const [targetRevision, setTargetRevision] = React.useState('main');
7577
const [clusterGroupName, setClusterGroupName] = React.useState('hub');
78+
const [variants, setVariants] = React.useState<Variant[]>([]);
7679

7780
const [secretTemplate, setSecretTemplate] = React.useState<SecretTemplate | null>(null);
7881
const [secretFormData, setSecretFormData] = React.useState<SecretFormData>({});
@@ -94,7 +97,14 @@ export default function InstallPatternPage() {
9497
});
9598

9699
setPatternName(patternData.name);
97-
setClusterGroupName(patternData.clustergroupname);
100+
if (patternData.variants && patternData.variants.length > 0) {
101+
setVariants(patternData.variants);
102+
const defaultVariant =
103+
patternData.variants.find((v) => v.default) || patternData.variants[0];
104+
setClusterGroupName(defaultVariant.name);
105+
} else {
106+
setClusterGroupName(patternData.clustergroupname);
107+
}
98108
setTargetRepo(patternData.repo_url || '');
99109
// Only use the template if it has actual secrets defined
100110
const hasSecrets = template && template.secrets && template.secrets.length > 0;
@@ -574,6 +584,25 @@ export default function InstallPatternPage() {
574584
/>
575585
</FormGroup>
576586

587+
{variants.length > 1 && (
588+
<FormGroup label={t('Variant')} isRequired fieldId="pattern-variant">
589+
<FormSelect
590+
id="pattern-variant"
591+
value={clusterGroupName}
592+
onChange={(_event, value) => setClusterGroupName(value)}
593+
aria-label={t('Select variant')}
594+
>
595+
{variants.map((v) => (
596+
<FormSelectOption
597+
key={v.name}
598+
value={v.name}
599+
label={v.description ? `${v.name}${v.description}` : v.name}
600+
/>
601+
))}
602+
</FormSelect>
603+
</FormGroup>
604+
)}
605+
577606
{/* Secrets Configuration Section */}
578607
{secretTemplate && (
579608
<FormGroup label={t('Secrets Configuration')} fieldId="pattern-secrets">

console/src/components/PatternCatalogPage.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,7 @@ export default function PatternCatalogPage() {
488488
<Button
489489
variant="secondary"
490490
onClick={() =>
491-
navigate(
492-
`/patterns/secrets/${pattern.catalogKey || pattern.name}`,
493-
)
491+
navigate(`/patterns/secrets/${pattern.catalogKey || pattern.name}`)
494492
}
495493
>
496494
{t('Manage Secrets')}
@@ -515,9 +513,7 @@ export default function PatternCatalogPage() {
515513
variant="primary"
516514
isDisabled={isDisabled}
517515
onClick={() =>
518-
navigate(
519-
`/patterns/install/${pattern.catalogKey || pattern.name}`,
520-
)
516+
navigate(`/patterns/install/${pattern.catalogKey || pattern.name}`)
521517
}
522518
>
523519
{t('Install')}

console/src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ export interface ExternalRequirements {
2929
cluster_sizing_note?: string;
3030
}
3131

32+
export interface Variant {
33+
name: string;
34+
default?: boolean;
35+
description?: string;
36+
}
37+
3238
export interface Pattern {
3339
metadata_version: string;
3440
name: string;
@@ -49,6 +55,7 @@ export interface Pattern {
4955
extra_features?: ExtraFeatures;
5056
external_requirements?: ExternalRequirements;
5157
logo?: string;
58+
variants?: Variant[];
5259
/** The catalog directory key used to fetch this pattern. */
5360
catalogKey?: string;
5461
}

0 commit comments

Comments
 (0)