Skip to content
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

feat: update ConfigPolicies with docs link [CM-558] #10055

Merged
merged 5 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 16 additions & 3 deletions webui/react/src/components/ConfigPolicies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -90,8 +92,8 @@ const ConfigPoliciesTab: React.FC<TabProps> = ({ 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.';
Comment on lines +96 to +97
Copy link
Contributor Author

@johnkim-det johnkim-det Oct 15, 2024

Choose a reason for hiding this comment

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

Removed "Global" because it's incorrect for workspaces, and seemed unnecessary for cluster, @tara-det-ai lmk if that's a problem

const confirmMessageEnding = global
? 'underlying workspaces, projects, and submitted experiments in the cluster.'
: 'underlying projects and their experiments in this workspace.';
Expand Down Expand Up @@ -161,6 +163,12 @@ const ConfigPoliciesTab: React.FC<TabProps> = ({ workspaceId, global, type }: Ta
setDisabled(hasErrors(form) || form.getFieldValue(YAML_FORM_ITEM_NAME) === initialYAML);
};

const docsLink = (
<Link external path={paths.docs('/manage/config-policies.html')} popout>
Learn more
</Link>
);

Comment on lines +177 to +182
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this PR is merge blocked on #9969, which will add this page to the docs

Copy link
Contributor

Choose a reason for hiding this comment

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

if (rbacLoading) return <Spinner spinning />;

return (
Expand All @@ -174,11 +182,16 @@ const ConfigPoliciesTab: React.FC<TabProps> = ({ workspaceId, global, type }: Ta
Apply
</Button>
}
description={docsLink}
message={applyMessage}
showIcon
/>
) : (
<Alert message={viewMessage} showIcon />
<Alert
description={docsLink}
message={viewMessage}
showIcon
/>
)}
</div>
</Row>
Expand Down
16 changes: 16 additions & 0 deletions webui/react/src/pages/ConfigPoliciesPage.tsx
Original file line number Diff line number Diff line change
@@ -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<HTMLElement>(null);
const info = useObservable(determinedStore.info);
const {
canViewGlobalConfigPolicies,
loading: rbacLoading,
} = usePermissions();

const canView = info.branding === BrandingType.HPE && canViewGlobalConfigPolicies;

if (rbacLoading) return <Spinner spinning />;

if (!canView) return <PageNotFound />;

return (
<Page
Expand Down
Loading