-
Notifications
You must be signed in to change notification settings - Fork 668
ODC-6786: Add cluster configuration extension, page, and options for console customization #12159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-robot
merged 4 commits into
openshift:master
from
christoph-jerolimov:cluster-configuration
Oct 20, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c32440e
Add cluster configuration extension and configuration page
christoph-jerolimov afce33c
Add customize option to console detail page (#7)
debsmita1 e524425
Implement cluster configuration options
christoph-jerolimov 8812f02
add telemetry event for cluster configuration changes (#8)
debsmita1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...es/console-app/src/components/cluster-configuration/ClusterConfigurationCheckboxField.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import * as React from 'react'; | ||
| import { FormGroup, Checkbox } from '@patternfly/react-core'; | ||
| import { ClusterConfigurationCheckboxField } from '@console/dynamic-plugin-sdk/src'; | ||
| import { FormLayout } from '@console/shared/src/components/cluster-configuration'; | ||
| import { ResolvedClusterConfigurationItem } from './types'; | ||
|
|
||
| type ClusterConfigurationCheckboxFieldProps = { | ||
| item: ResolvedClusterConfigurationItem; | ||
| field: ClusterConfigurationCheckboxField; | ||
| }; | ||
|
|
||
| const ClusterConfigurationCheckboxField: React.FC<ClusterConfigurationCheckboxFieldProps> = ({ | ||
| item, | ||
| // field, | ||
| }) => { | ||
| const handleOnChange = (checked: boolean) => { | ||
| // eslint-disable-next-line no-console | ||
| console.log('xxx onChange', checked); | ||
| }; | ||
| return ( | ||
| <FormGroup | ||
| fieldId={item.id} | ||
| label={item.label} | ||
| helperText={item.description} | ||
| data-test={`${item.id} field`} | ||
| > | ||
| <FormLayout> | ||
| <Checkbox id="" title="asd" onChange={handleOnChange} /> | ||
| </FormLayout> | ||
| </FormGroup> | ||
| ); | ||
| }; | ||
|
|
||
| export default ClusterConfigurationCheckboxField; | ||
29 changes: 29 additions & 0 deletions
29
...ages/console-app/src/components/cluster-configuration/ClusterConfigurationCustomField.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import * as React from 'react'; | ||
| // import { UserPreferenceCustomField as CustomFieldType } from '@console/dynamic-plugin-sdk/src'; | ||
| import { ClusterConfigurationCustomField } from '@console/dynamic-plugin-sdk/src'; | ||
| import { ResolvedCodeRefProperties } from '@console/dynamic-plugin-sdk/src/types'; | ||
| import { FormLayout } from '@console/shared/src/components/cluster-configuration'; | ||
| import { ErrorBoundaryInline } from '@console/shared/src/components/error'; | ||
| import { ResolvedClusterConfigurationItem } from './types'; | ||
|
|
||
| type ClusterConfigurationCustomFieldProps = { | ||
| item: ResolvedClusterConfigurationItem; | ||
| field: ResolvedCodeRefProperties<ClusterConfigurationCustomField>; | ||
| }; | ||
|
|
||
| const ClusterConfigurationCustomField: React.FC<ClusterConfigurationCustomFieldProps> = ({ | ||
| item, | ||
| field, | ||
| }) => { | ||
| const CustomComponent = field.component; | ||
|
|
||
| return ( | ||
| <ErrorBoundaryInline> | ||
| <FormLayout> | ||
| <CustomComponent {...field.props} readonly={item.readonly} /> | ||
| </FormLayout> | ||
| </ErrorBoundaryInline> | ||
| ); | ||
| }; | ||
|
|
||
| export default ClusterConfigurationCustomField; |
67 changes: 67 additions & 0 deletions
67
...es/console-app/src/components/cluster-configuration/ClusterConfigurationDropdownField.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import * as React from 'react'; | ||
| import { FormGroup, Select, SelectOption, SelectVariant } from '@patternfly/react-core'; | ||
| import { ClusterConfigurationDropdownField } from '@console/dynamic-plugin-sdk/src'; | ||
| import { FormLayout } from '@console/shared/src/components/cluster-configuration'; | ||
| import { useDebounceCallback } from './hooks'; | ||
| import { ResolvedClusterConfigurationItem } from './types'; | ||
|
|
||
| type ClusterConfigurationTextFieldProps = { | ||
| item: ResolvedClusterConfigurationItem; | ||
| field: ClusterConfigurationDropdownField; | ||
| }; | ||
|
|
||
| const ClusterConfigurationTextField: React.FC<ClusterConfigurationTextFieldProps> = ({ | ||
| item, | ||
| field, | ||
| }) => { | ||
| const [value, setValue] = React.useState<string>(field.defaultValue); | ||
|
|
||
| const [isOpen, setIsOpen] = React.useState(false); | ||
| const handleToggle = (open: boolean) => setIsOpen(open); | ||
|
|
||
| const save = useDebounceCallback(() => { | ||
| // eslint-disable-next-line no-console | ||
| console.log('xxx save'); | ||
| }, 2000); | ||
| const handleChange = (_, newValue: string) => { | ||
| setIsOpen(false); | ||
| setValue(newValue); | ||
| // eslint-disable-next-line no-console | ||
| console.log('xxx handleChange', newValue); | ||
| save(newValue); | ||
| }; | ||
|
|
||
| const options = field.options.map((option) => ( | ||
|
||
| <SelectOption | ||
| key={option.value} | ||
| value={option.value} | ||
| label={option.label} | ||
| description={option.description} | ||
| /> | ||
| )); | ||
|
|
||
| return ( | ||
| <FormGroup | ||
| fieldId={item.id} | ||
| label={item.label} | ||
| helperText={item.description} | ||
| data-test={`${item.id} field`} | ||
| > | ||
| <FormLayout> | ||
| <Select | ||
| toggleId={item.id} | ||
| variant={SelectVariant.single} | ||
| isOpen={isOpen} | ||
| onToggle={handleToggle} | ||
| selections={value} | ||
| onSelect={handleChange} | ||
| isDisabled={item.readonly} | ||
| > | ||
| {options} | ||
| </Select> | ||
| </FormLayout> | ||
| </FormGroup> | ||
| ); | ||
| }; | ||
|
|
||
| export default ClusterConfigurationTextField; | ||
21 changes: 21 additions & 0 deletions
21
...d/packages/console-app/src/components/cluster-configuration/ClusterConfigurationField.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import * as React from 'react'; | ||
| import { ClusterConfigurationFieldType } from '@console/dynamic-plugin-sdk/src'; | ||
| import ClusterConfigurationCustomField from './ClusterConfigurationCustomField'; | ||
| import { ResolvedClusterConfigurationItem } from './types'; | ||
|
|
||
| const componentForFieldType = { | ||
| // WIP: | ||
| // [ClusterConfigurationFieldType.text]: ClusterConfigurationTextField, | ||
| // [ClusterConfigurationFieldType.checkbox]: ClusterConfigurationCheckboxField, | ||
| // [ClusterConfigurationFieldType.dropdown]: ClusterConfigurationDropdownField, | ||
| [ClusterConfigurationFieldType.custom]: ClusterConfigurationCustomField, | ||
| }; | ||
|
|
||
| const ClusterConfigurationField: React.FC<{ item: ResolvedClusterConfigurationItem }> = ({ | ||
| item, | ||
| }) => { | ||
| const Field = componentForFieldType[item.field.type]; | ||
| return Field ? <Field item={item} field={item.field} /> : null; | ||
| }; | ||
|
|
||
| export default ClusterConfigurationField; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this?