Skip to content

Commit

Permalink
fix(web): add database policy add modal back (labring#1939)
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk authored Apr 7, 2024
1 parent 5bc23e3 commit ab11ad5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
22 changes: 20 additions & 2 deletions web/src/pages/app/database/PolicyDataList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState } from "react";
import { Center, Input, Spinner, Text, useColorMode } from "@chakra-ui/react";
import { AddIcon } from "@chakra-ui/icons";
import { Button, Center, Input, Spinner, Text, useColorMode } from "@chakra-ui/react";
import clsx from "clsx";
import { t } from "i18next";

Expand All @@ -13,6 +14,7 @@ import Panel from "@/components/Panel";
import { COLOR_MODE } from "@/constants";

import AddPolicyModal from "../mods/AddPolicyModal";
import AddRulesModal from "../mods/AddRulesModal";
import policyTemplate from "../mods/AddRulesModal/policyTemplate";
import RightPanelEditBox from "../RightComponent/EditBox";
import RightPanelList from "../RightComponent/List";
Expand Down Expand Up @@ -85,7 +87,23 @@ export default function PolicyDataList() {
return (
<>
<Panel.Header className="h-[60px] w-full flex-shrink-0 pr-2">
<span className="flex w-full justify-end">
<AddRulesModal
onSuccessSubmit={(data) => {
setCurrentData(data);
setRecord(JSON.stringify(data?.value, null, 2));
rulesListQuery.refetch();
}}
>
<Button
disabled={store.currentPolicy === undefined}
leftIcon={<AddIcon fontSize={10} className="text-grayModern-500" />}
variant="textGhost"
size="xs"
>
{t("CollectionPanel.AddRules")}
</Button>
</AddRulesModal>
<span>
{t("CollectionPanel.RulesNum")} : {rulesListQuery?.data?.data?.length || 0}
</span>
</Panel.Header>
Expand Down
14 changes: 13 additions & 1 deletion web/src/pages/app/database/PolicyListPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* cloud functions list sidebar
***************************/
import { useTranslation } from "react-i18next";
import { AddIcon } from "@chakra-ui/icons";
import { useColorMode } from "@chakra-ui/react";
import clsx from "clsx";

Expand All @@ -10,10 +11,12 @@ import ConfirmButton from "@/components/ConfirmButton";
import EmptyBox from "@/components/EmptyBox";
import FileTypeIcon from "@/components/FileTypeIcon";
import IconText from "@/components/IconText";
import IconWrap from "@/components/IconWrap";
import MoreButton from "@/components/MoreButton";
import Panel from "@/components/Panel";
import SectionList from "@/components/SectionList";

import AddPolicyModal from "../mods/AddPolicyModal";
import { useDeletePolicyMutation } from "../service";
import useDBMStore from "../store";
export default function PolicyListPanel(props: { policyList: any }) {
Expand All @@ -30,7 +33,16 @@ export default function PolicyListPanel(props: { policyList: any }) {
store.setCurrentShow("Policy");
}}
>
<Panel.Header title={t("CollectionPanel.Policy").toString()} actions={[<></>]} />
<Panel.Header
title={t("CollectionPanel.Policy").toString()}
actions={[
<AddPolicyModal key="AddPolicyModal">
<IconWrap tooltip={t("CollectionPanel.AddPolicy").toString()} size={20}>
<AddIcon fontSize={10} />
</IconWrap>
</AddPolicyModal>,
]}
/>
<div style={{ flexGrow: 1, overflowY: "auto", overflowX: "hidden" }}>
{policyList?.data?.length ? (
<SectionList>
Expand Down

0 comments on commit ab11ad5

Please sign in to comment.