Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkim-det committed Oct 4, 2024
1 parent d5a1a4e commit b6afe12
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions webui/react/src/components/ConfigPolicies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ import {
import { XOR } from 'types';
import handleError from 'utils/error';

type Props = XOR<
{ workspaceId: number },
{ global: true }
>;
type Props = XOR<{ workspaceId: number }, { global: true }>;

type ConfigPoliciesType = 'experiments' | 'tasks';

Expand All @@ -51,7 +48,7 @@ const ConfigPoliciesValues: Record<ConfigPoliciesType, ConfigPoliciesValues> = {

type TabProps = Props & {
type: ConfigPoliciesType;
}
};

type FormInputs = {
[YAML_FORM_ITEM_NAME]: string;
Expand Down Expand Up @@ -96,14 +93,24 @@ const ConfigPolicies: React.FC<Props> = ({ workspaceId, global }: Props) => {
const ConfigPoliciesTab: React.FC<TabProps> = ({ workspaceId, global, type }: TabProps) => {
const confirm = useConfirm();
const { openToast } = useToast();
const { canModifyWorkspaceConfigPolicies, canModifyGlobalConfigPolicies, loading: rbacLoading } = usePermissions();
const {
canModifyWorkspaceConfigPolicies,
canModifyGlobalConfigPolicies,
loading: rbacLoading,
} = usePermissions();
const [form] = Form.useForm<FormInputs>();

const [disabled, setDisabled] = useState(true);

const applyMessage = global ? "You're about to apply these config policies to this cluster." : "You're about to apply these config policies to this workspace.";
const viewMessage = global ? 'These global config policies are being applied to this cluster.' : 'These global config policies are being applied to this workspace.';
const confirmMessageEnding = global ? 'underlying workspaces, projects, and submitted experiments in this cluster.' : 'underlying projects and their experiments in this workspace.';
const applyMessage = global
? "You're about to apply these config policies to this cluster."
: "You're about to apply these config policies to this workspace.";
const viewMessage = global
? 'These global config policies are being applied to this cluster.'
: 'These global config policies are being applied to this workspace.';
const confirmMessageEnding = global
? 'underlying workspaces, projects, and submitted experiments in this cluster.'
: 'underlying projects and their experiments in this workspace.';

const updatePolicies = async () => {
const configPolicies = form.getFieldValue(YAML_FORM_ITEM_NAME);
Expand Down Expand Up @@ -196,9 +203,7 @@ const ConfigPoliciesTab: React.FC<TabProps> = ({ workspaceId, global, type }: Ta
const canModify = global ? canModifyGlobalConfigPolicies : canModifyWorkspaceConfigPolicies;

const handleChange = () => {
setDisabled(
hasErrors(form) || form.getFieldValue(YAML_FORM_ITEM_NAME) === initialYAML,
);
setDisabled(hasErrors(form) || form.getFieldValue(YAML_FORM_ITEM_NAME) === initialYAML);
};

if (rbacLoading) return <Spinner spinning />;
Expand Down

0 comments on commit b6afe12

Please sign in to comment.