Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions frontend/packages/console-app/console-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,103 @@
"provider": { "$codeRef": "actions.useReplicationControllerActionsProvider" }
}
},

{
"type": "console.page/route",
"properties": {
"exact": true,
"path": ["/cluster-configuration", "/cluster-configuration/:group"],
"component": { "$codeRef": "clusterConfiguration.ClusterConfigurationPage" }
}
},

{
"type": "console.cluster-configuration/group",
"properties": {
"id": "general",
"label": "%console-app~General%"
}
},
{
"type": "console.cluster-configuration/group",
"properties": {
"id": "projects",
"label": "%console-app~Projects%",
"insertAfter": "general"
}
},
{
"type": "console.cluster-configuration/group",
"properties": {
"id": "developer",
"label": "%console-app~Developer%",
"insertAfter": "projects"
}
},
{
"type": "console.cluster-configuration/item",
"properties": {
"id": "console-app.customization.perspectives",
"groupId": "general",
"label": "%console-app~Perspectives%",
"description": "%console-app~Show or hide perspectives by enabling, disabling or adding access review checks.%",
"field": {
"type": "custom",
"component": { "$codeRef": "perspectiveConfiguration" }
},
"readAccessReview": [
{
"group": "operator.openshift.io/v1",
"resource": "consoles",
"verb": "get",
"name": "cluster"
}
],
"writeAccessReview": [
{
"group": "operator.openshift.io/v1",
"resource": "consoles",
"verb": "patch",
"name": "cluster"
}
]
}
},
{
"type": "console.cluster-configuration/item",
"properties": {
"id": "console-app.quick-start.QuickStartConfiguration",
"label": "%console-app~Quick Starts%",
"groupId": "general",
"description": "%console-app~Configure a list of Quick Starts that are not shown to users.%",
"field": {
"type": "custom",
"component": { "$codeRef": "quickStartConfiguration" }
},
"readAccessReview": [
{
"group": "operator.openshift.io/v1",
"resource": "consoles",
"verb": "get",
"name": "cluster"
},
{
"group": "console.openshift.io/v1",
"resource": "ConsoleQuickStart",
"verb": "list"
}
],
"writeAccessReview": [
{
"group": "operator.openshift.io/v1",
"resource": "consoles",
"verb": "patch",
"name": "cluster"
}
]
}
},

{
"type": "console.user-preference/group",
"properties": {
Expand Down
25 changes: 23 additions & 2 deletions frontend/packages/console-app/locales/en/console-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"Administrator": "Administrator",
"VolumeSnapshotContents": "VolumeSnapshotContents",
"General": "General",
"Projects": "Projects",
"Developer": "Developer",
"Perspectives": "Perspectives",
"Show or hide perspectives by enabling, disabling or adding access review checks.": "Show or hide perspectives by enabling, disabling or adding access review checks.",
"Quick Starts": "Quick Starts",
"Configure a list of Quick Starts that are not shown to users.": "Configure a list of Quick Starts that are not shown to users.",
"Language": "Language",
"Notifications": "Notifications",
"Applications": "Applications",
Expand Down Expand Up @@ -34,7 +40,6 @@
"Administration": "Administration",
"Observe": "Observe",
"Overview": "Overview",
"Projects": "Projects",
"Search": "Search",
"API Explorer": "API Explorer",
"Events": "Events",
Expand Down Expand Up @@ -226,6 +231,11 @@
"This Project will be used to initialize your command line terminal": "This Project will be used to initialize your command line terminal",
"Project name": "Project name",
"Connecting to your OpenShift command line terminal ...": "Connecting to your OpenShift command line terminal ...",
"Cluster configuration": "Cluster configuration",
"Set cluster-wide configuration for the console experience. Your changes will be autosaved and will affect after a refresh.": "Set cluster-wide configuration for the console experience. Your changes will be autosaved and will affect after a refresh.",
"Insufficient permissions": "Insufficient permissions",
"You do not have sufficient permissions to read any cluster configuration.": "You do not have sufficient permissions to read any cluster configuration.",
"{{section}} not found": "{{section}} not found",
"Enabled": "Enabled",
"Disabled": "Disabled",
"Name": "Name",
Expand All @@ -234,6 +244,7 @@
"Console plugins table": "Console plugins table",
"console plugins": "console plugins",
"Console plugins": "Console plugins",
"Customize": "Customize",
"Updating cluster to {{version}}": "Updating cluster to {{version}}",
"API Servers": "API Servers",
"Controller Managers": "Controller Managers",
Expand All @@ -249,6 +260,15 @@
"{{enabledCount}}/{{totalCount}} enabled": "{{enabledCount}}/{{totalCount}} enabled",
"View all": "View all",
"Single master": "Single master",
"Perspectives are enabled by default.": "Perspectives are enabled by default.",
"Only visible for privileged users": "Only visible for privileged users",
"Privileged users can list all namespaces.": "Privileged users can list all namespaces.",
"Only visible for unprivileged users": "Only visible for unprivileged users",
"Unprivileged users cannot list all namespaces.": "Unprivileged users cannot list all namespaces.",
"Disable this perspectives for all users.": "Disable this perspectives for all users.",
"Custom": "Custom",
"This perspective is shown based on custom access review rules. Please open the console configuration resource to inspect or update this rules.": "This perspective is shown based on custom access review rules. Please open the console configuration resource to inspect or update this rules.",
"Access review rules": "Access review rules",
"Incompatible file type": "Incompatible file type",
"{{fileName}} cannot be uploaded. Only {{fileExtensions}} files are supported currently. Try another file.": "{{fileName}} cannot be uploaded. Only {{fileExtensions}} files are supported currently. Try another file.",
"Clone": "Clone",
Expand Down Expand Up @@ -457,8 +477,8 @@
"{helpText}": "{helpText}",
"Create PodDiscruptionBudget": "Create PodDiscruptionBudget",
"No PodDisruptionBudgets": "No PodDisruptionBudgets",
"Quick Starts": "Quick Starts",
"Learn how to create, import, and run applications on OpenShift with step-by-step instructions and tasks.": "Learn how to create, import, and run applications on OpenShift with step-by-step instructions and tasks.",
"Quick starts": "Quick starts",
"No results found": "No results found",
"No results match the filter criteria. Remove filters or clear all filters to show results.": "No results match the filter criteria. Remove filters or clear all filters to show results.",
"Clear all filters": "Clear all filters",
Expand Down Expand Up @@ -519,6 +539,7 @@
"Select a perspective": "Select a perspective",
"Select an option": "Select an option",
"User Preferences": "User Preferences",
"Set your individual preferences for the console experience. Any changes will be autosaved.": "Set your individual preferences for the console experience. Any changes will be autosaved.",
"Only {{volumeMode}} volume mode is available for {{storageClass}} with {{accessMode}} access mode": "Only {{volumeMode}} volume mode is available for {{storageClass}} with {{accessMode}} access mode",
"VolumeSnapshotClass with same provisioner as claim": "VolumeSnapshotClass with same provisioner as claim",
"Select volume snapshot class": "Select volume snapshot class",
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/console-app/locales/ja/console-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@
"Select a perspective": "パースペクティブの選択",
"Select an option": "オプションの選択",
"User Preferences": "ユーザー設定",
"Set your individual preferences for the console experience. Any changes will be autosaved.": "コンソールエクスペリエンスに個別の設定を行います。変更は自動保存されます。",
"Only {{volumeMode}} volume mode is available for {{storageClass}} with {{accessMode}} access mode": "{{accessMode}} アクセスモードの {{storageClass}} には {{volumeMode}} ボリュームモードのみを使用できます",
"VolumeSnapshotClass with same provisioner as claim": "要求と同じプロビジョナーの VolumeSnapshotClass",
"Select volume snapshot class": "ボリュームスナップショットクラスの選択",
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/console-app/locales/ko/console-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@
"Select a perspective": "화면 선택",
"Select an option": "옵션 선택",
"User Preferences": "사용자 기본 설정",
"Set your individual preferences for the console experience. Any changes will be autosaved.": "콘솔 환경에 대한 개별 기본 설정을 지정합니다. 모든 변경 사항은 자동 저장됩니다.",
"Only {{volumeMode}} volume mode is available for {{storageClass}} with {{accessMode}} access mode": "{{accessMode}} 액세스 모드가 있는 {{storageClass}}에서는 {{volumeMode}} 볼륨 모드만 사용할 수 있습니다.",
"VolumeSnapshotClass with same provisioner as claim": "클레임과 동일한 프로비저너를 사용하는 볼륨 스냅샷 클래스",
"Select volume snapshot class": "볼륨 스냅 샷 클래스 선택",
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/console-app/locales/zh/console-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@
"Select a perspective": "选择一个视角",
"Select an option": "选择一个选项",
"User Preferences": "用户首选项",
"Set your individual preferences for the console experience. Any changes will be autosaved.": "为增强控制台体验设置您的个人首选项。任何更改都将自动保存。",
"Only {{volumeMode}} volume mode is available for {{storageClass}} with {{accessMode}} access mode": "使用 {{accessMode}} 访问模式的 {{storageClass}} 只有 {{volumeMode}} 卷模式可用",
"VolumeSnapshotClass with same provisioner as claim": "带有与声明相同的置备程序的卷快照类",
"Select volume snapshot class": "选择卷快照类",
Expand Down
3 changes: 3 additions & 0 deletions frontend/packages/console-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@
"exposedModules": {
"tourContext": "src/components/tour/tour-context.ts",
"quickStartContext": "src/components/quick-starts/utils/quick-start-context.tsx",
"quickStartConfiguration": "src/components/quick-starts/QuickStartConfiguration.tsx",
"fileUploadContext": "src/components/file-upload/file-upload-context.ts",
"reduxReducer": "src/redux/reducer.ts",
"actions": "src/actions",
"clusterConfiguration": "src/components/cluster-configuration",
"userPreferences": "src/components/user-preferences",
"perspective": "src/utils/perspective",
"perspectiveConfiguration": "src/components/detect-perspective/PerspectiveConfiguration.tsx",
"dynamicPluginsHealthResource": "src/components/dashboards-page/dynamic-plugins-health-resource",
"storageProvisioners": "src/components/storage/StorageClassProviders",
"storageProvisionerDocs": "src/components/storage/Documentation"
Expand Down
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);
};
Comment on lines +16 to +19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this?

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;
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;
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) => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we add check on options?

<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;
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;
Loading