From 362fa9e02c8ce1dc4390e6ad2f8ce9b92a73a417 Mon Sep 17 00:00:00 2001 From: John Kim Date: Mon, 14 Oct 2024 18:51:19 -0400 Subject: [PATCH 1/5] add Link --- webui/react/src/components/ConfigPolicies.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/webui/react/src/components/ConfigPolicies.tsx b/webui/react/src/components/ConfigPolicies.tsx index 6b0c0004f51..c6c8254e370 100644 --- a/webui/react/src/components/ConfigPolicies.tsx +++ b/webui/react/src/components/ConfigPolicies.tsx @@ -13,8 +13,10 @@ import yaml from 'js-yaml'; import { isEmpty } from 'lodash'; import { useState } from 'react'; +import Link from 'components/Link'; import { useAsync } from 'hooks/useAsync'; import usePermissions from 'hooks/usePermissions'; +import { paths } from 'routes/utils'; import { deleteGlobalConfigPolicies, deleteWorkspaceConfigPolicies, @@ -161,6 +163,12 @@ const ConfigPoliciesTab: React.FC = ({ workspaceId, global, type }: Ta setDisabled(hasErrors(form) || form.getFieldValue(YAML_FORM_ITEM_NAME) === initialYAML); }; + const docsLink = ( + + Learn more + + ); + if (rbacLoading) return ; return ( @@ -174,11 +182,16 @@ const ConfigPoliciesTab: React.FC = ({ workspaceId, global, type }: Ta Apply } + description={docsLink} message={applyMessage} showIcon /> ) : ( - + )} From 33b8a527348c3ff6886d59e4b8cd521653aef947 Mon Sep 17 00:00:00 2001 From: John Kim Date: Tue, 15 Oct 2024 10:26:58 -0400 Subject: [PATCH 2/5] use PageNotFound --- webui/react/src/pages/ConfigPoliciesPage.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/webui/react/src/pages/ConfigPoliciesPage.tsx b/webui/react/src/pages/ConfigPoliciesPage.tsx index 201fe883101..32d1390a0dc 100644 --- a/webui/react/src/pages/ConfigPoliciesPage.tsx +++ b/webui/react/src/pages/ConfigPoliciesPage.tsx @@ -1,11 +1,27 @@ +import Spinner from 'hew/Spinner'; import React, { useRef } from 'react'; import ConfigPolicies from 'components/ConfigPolicies'; import Page from 'components/Page'; +import PageNotFound from 'components/PageNotFound'; +import usePermissions from 'hooks/usePermissions'; import { paths } from 'routes/utils'; +import determinedStore, { BrandingType } from 'stores/determinedInfo'; +import { useObservable } from 'utils/observable'; const TemplatesPage: React.FC = () => { const pageRef = useRef(null); + const info = useObservable(determinedStore.info); + const { + canViewGlobalConfigPolicies, + loading: rbacLoading, + } = usePermissions(); + + const canView = info.branding === BrandingType.HPE && canViewGlobalConfigPolicies; + + if (rbacLoading) return ; + + if (!canView) return ; return ( Date: Tue, 15 Oct 2024 10:33:50 -0400 Subject: [PATCH 3/5] fix copy --- webui/react/src/components/ConfigPolicies.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webui/react/src/components/ConfigPolicies.tsx b/webui/react/src/components/ConfigPolicies.tsx index c6c8254e370..5e267b032cb 100644 --- a/webui/react/src/components/ConfigPolicies.tsx +++ b/webui/react/src/components/ConfigPolicies.tsx @@ -92,8 +92,8 @@ const ConfigPoliciesTab: React.FC = ({ workspaceId, global, type }: Ta ? "You're about to apply these configuration policies to the cluster." : "You're about to apply these configuration policies to the workspace."; const viewMessage = global - ? 'Global configuration policies are being applied to the cluster.' - : 'Global configuration policies are being applied to the workspace.'; + ? 'Configuration policies are being applied to the cluster.' + : 'Configuration policies are being applied to the workspace.'; const confirmMessageEnding = global ? 'underlying workspaces, projects, and submitted experiments in the cluster.' : 'underlying projects and their experiments in this workspace.'; From c7170bd2ad7f2237b6b860587a4945885218f27b Mon Sep 17 00:00:00 2001 From: John Kim Date: Tue, 15 Oct 2024 10:41:16 -0400 Subject: [PATCH 4/5] fmt --- webui/react/src/components/ConfigPolicies.tsx | 6 +----- webui/react/src/pages/ConfigPoliciesPage.tsx | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/webui/react/src/components/ConfigPolicies.tsx b/webui/react/src/components/ConfigPolicies.tsx index 5e267b032cb..91eb307e904 100644 --- a/webui/react/src/components/ConfigPolicies.tsx +++ b/webui/react/src/components/ConfigPolicies.tsx @@ -187,11 +187,7 @@ const ConfigPoliciesTab: React.FC = ({ workspaceId, global, type }: Ta showIcon /> ) : ( - + )} diff --git a/webui/react/src/pages/ConfigPoliciesPage.tsx b/webui/react/src/pages/ConfigPoliciesPage.tsx index 32d1390a0dc..96c5ea84fe9 100644 --- a/webui/react/src/pages/ConfigPoliciesPage.tsx +++ b/webui/react/src/pages/ConfigPoliciesPage.tsx @@ -12,10 +12,7 @@ import { useObservable } from 'utils/observable'; const TemplatesPage: React.FC = () => { const pageRef = useRef(null); const info = useObservable(determinedStore.info); - const { - canViewGlobalConfigPolicies, - loading: rbacLoading, - } = usePermissions(); + const { canViewGlobalConfigPolicies, loading: rbacLoading } = usePermissions(); const canView = info.branding === BrandingType.HPE && canViewGlobalConfigPolicies; From 3b317fc6ade67a639bde9833359e28127a5f9957 Mon Sep 17 00:00:00 2001 From: John Kim Date: Wed, 16 Oct 2024 16:08:15 -0400 Subject: [PATCH 5/5] disable on successful submit --- webui/react/src/components/ConfigPolicies.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/webui/react/src/components/ConfigPolicies.tsx b/webui/react/src/components/ConfigPolicies.tsx index 91eb307e904..2899a24175e 100644 --- a/webui/react/src/components/ConfigPolicies.tsx +++ b/webui/react/src/components/ConfigPolicies.tsx @@ -11,7 +11,7 @@ import useConfirm from 'hew/useConfirm'; import { Loadable, NotLoaded } from 'hew/utils/loadable'; import yaml from 'js-yaml'; import { isEmpty } from 'lodash'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import Link from 'components/Link'; import { useAsync } from 'hooks/useAsync'; @@ -87,6 +87,7 @@ const ConfigPoliciesTab: React.FC = ({ workspaceId, global, type }: Ta const [form] = Form.useForm(); const [disabled, setDisabled] = useState(true); + const [updatedYAML, setUpdatedYAML] = useState(); const applyMessage = global ? "You're about to apply these configuration policies to the cluster." @@ -112,6 +113,7 @@ const ConfigPoliciesTab: React.FC = ({ workspaceId, global, type }: Ta ? await updateWorkspaceConfigPolicies({ configPolicies, workloadType, workspaceId }) : await deleteWorkspaceConfigPolicies({ workloadType, workspaceId }); } + setUpdatedYAML(configPolicies); openToast({ title: SUCCESS_MESSAGE }); } catch (error) { handleError(error); @@ -159,8 +161,17 @@ const ConfigPoliciesTab: React.FC = ({ workspaceId, global, type }: Ta const canModify = global ? canModifyGlobalConfigPolicies : canModifyWorkspaceConfigPolicies; + useEffect(() => { + if (updatedYAML) setDisabled(form.getFieldValue(YAML_FORM_ITEM_NAME) === updatedYAML); + }, [updatedYAML, form]); + const handleChange = () => { - setDisabled(hasErrors(form) || form.getFieldValue(YAML_FORM_ITEM_NAME) === initialYAML); + setDisabled( + hasErrors(form) || + (updatedYAML + ? form.getFieldValue(YAML_FORM_ITEM_NAME) === updatedYAML + : form.getFieldValue(YAML_FORM_ITEM_NAME) === initialYAML), + ); }; const docsLink = (