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

fix: encode function debug header & button theme #646

Merged
merged 1 commit into from
Jan 18, 2023
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
5 changes: 3 additions & 2 deletions web/public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,6 @@
"Total": "总数",
"Page": "页",
"NoData": "当前无数据",
"Logout": "退出登录"
}
"Logout": "退出登录",
"SaveAndRestart": "保存并重启"
}
Binary file modified web/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions web/src/apis/typing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,25 @@ export interface TLogItem {
data: string;
created_at: string;
}

// user data
export interface TUserInfo {
id: string;
username: string;
email: any;
phone: any;
createdAt: string;
updatedAt: string;
profile: TProfile;
}

export interface TProfile {
id: string;
uid: string;
openid: string;
from: string;
avatar: string;
name: string;
createdAt: string;
updatedAt: string;
}
35 changes: 18 additions & 17 deletions web/src/chakraTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,40 +63,41 @@ const Button = defineStyleConfig({
},

variants: {
plain: {
bg: "gray.200",
color: "gray.500",
_hover: {
bg: "gray.300",
},
},

solid: {
primary: {
bg: "primary.500",
color: "white",
_hover: {
bg: "primary.700",
},
},

ghost: {
secondary: {
color: "primary.500",
borderRadius: 2,
bg: "primary.100",
_hover: {
bg: "primary.200",
},
},

plain: {
bg: "gray.200",
color: "gray.500",
_hover: {
bg: "primary.500",
color: "white",
borderRadius: 2,
bg: "gray.300",
},
},

grayGhost: {
color: "#000",
text: {
color: "primary.500",
_hover: {
bg: "primary.100",
},
},
},
// The default size and variant values
defaultProps: {
size: "md",
variant: "solid",
variant: "primary",
},
});

Expand Down
1 change: 0 additions & 1 deletion web/src/components/EditableTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ const EditableTable = function (props: {
<Button
leftIcon={<AddIcon />}
style={{ borderTopLeftRadius: 0, borderTopRightRadius: 0 }}
size="m"
px="6"
className="h-10"
onClick={handleAdd}
Expand Down
9 changes: 4 additions & 5 deletions web/src/components/Panel/index.module.scss
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
.sectionHeader {
min-height: 36px;
min-height: 50px;
display: flex;
align-items: center;

h4 {
padding-left: 16px;
padding-left: 14px;
font-weight: 500;
font-size: 14px;
position: relative;

&::before {
content: " ";
height: 10px;
height: 15px;
position: absolute;
left: 0;
top: 2px;
top: 3px;
width: 3px;
height: 16px;
background: #00a99d;
border-radius: 24px;
}
Expand Down
15 changes: 11 additions & 4 deletions web/src/layouts/Header/UserSetting/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { Menu, MenuButton, MenuItem, MenuList } from "@chakra-ui/react";
import { Avatar, Menu, MenuButton, MenuItem, MenuList } from "@chakra-ui/react";
import { t } from "i18next";

import SettingModal from "@/pages/app/setting";
import PATList from "@/pages/app/setting/PATList";
export default function UserSetting(props: { avatar: string; width: number }) {
export default function UserSetting(props: { name: string; avatar?: string; width: string }) {
return (
<Menu>
<MenuButton>
<img src={props.avatar} className="rounded-full" width={props.width} alt="avatar" />
<Avatar
size="sm"
name={props.name}
bgColor="green.500"
color="white"
boxShadow="base"
boxSize={props.width}
/>
</MenuButton>
<MenuList minW={24}>
<MenuList minW={"150px"}>
<SettingModal
headerTitle={t("SettingPanel.UserSetting")}
tabMatch={[
Expand Down
15 changes: 9 additions & 6 deletions web/src/layouts/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* laf website header nav
***************************/

import { RiCodeBoxFill } from "react-icons/ri";

import UserSetting from "./UserSetting";

import useGlobalStore from "@/pages/globalStore";
Expand All @@ -12,14 +10,19 @@ export default function Header(props: { size: "sm" | "lg" }) {
const { userInfo } = useGlobalStore((state) => state);

return (
<div className="flex justify-between px-10 py-4">
<div className="flex justify-between px-10 py-4 h-[60px]">
<div className="flex items-center">
<RiCodeBoxFill size={32} className="mr-2" color="green" />
<span className="text-2xl font-semibold">LaF</span>
<img src="/logo.png" alt="logo" width={30} />
</div>

<div>
{userInfo.profile ? <UserSetting avatar={userInfo.profile?.avatar} width={30} /> : null}
{userInfo?.profile ? (
<UserSetting
name={userInfo?.profile?.name}
avatar={userInfo?.profile?.avatar}
width={"30px"}
/>
) : null}
</div>
</div>
);
Expand Down
31 changes: 0 additions & 31 deletions web/src/pages/app/database/CollectionDataList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,6 @@ export default function CollectionDataList() {
) : (
<DataPanel />
)}
{/* <Tabs className="h-full">
<TabList>
<Tab>数据管理</Tab>
<Tab>索引管理</Tab>
<Tab>集合结构</Tab>
</TabList>
<TabPanels className="h-full">
<TabPanel
className="overflow-hidden relative !pt-1"
style={{ height: "calc(100% - 55px)" }}
>
{store.currentDB === undefined ? (
<div className="h-full flex items-center justify-center">
<CreateCollectionModal>
<Button size="lg" variant="ghost" leftIcon={<AddIcon />}>
{t("CollectionPanel.AddCollection")}
</Button>
</CreateCollectionModal>
</div>
) : (
<DataPanel />
)}
</TabPanel>
<TabPanel>
<IndexPanel />
</TabPanel>
<TabPanel className="overflow-hidden relative" style={{ height: "calc(100% - 35px)" }}>
<ColPanel />
</TabPanel>
</TabPanels>
</Tabs > */}
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function AddIndexModal() {
</FormControl>
</ModalBody>
<ModalFooter className="mt-20">
<Button colorScheme="blue" mr={3} onClick={onClose}>
<Button mr={3} onClick={onClose}>
{t("Cancel")}
</Button>
<Button variant="ghost">{t("Confirm")}</Button>
Expand Down
28 changes: 15 additions & 13 deletions web/src/pages/app/functions/mods/DebugPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TabPanel,
TabPanels,
Tabs,
Tooltip,
} from "@chakra-ui/react";
import axios from "axios";
import { t } from "i18next";
Expand Down Expand Up @@ -51,7 +52,7 @@ export default function DebugPanel() {
const [bodyParams, setBodyParams] = useState({});
const [headerParams, setHeaderParams] = useState([]);

useHotKey(
const { displayName } = useHotKey(
DEFAULT_SHORTCUTS.send_request,
() => {
runningCode();
Expand Down Expand Up @@ -85,7 +86,7 @@ export default function DebugPanel() {
data: bodyParams,
headers: Object.assign(mapValues(keyBy(headerParams, "name"), "value"), {
"x-laf-debug-token": `${globalStore.currentApp?.function_debug_token}`,
"x-laf-func-data": _funcData,
"x-laf-func-data": encodeURIComponent(_funcData),
}),
});

Expand All @@ -105,7 +106,7 @@ export default function DebugPanel() {
<Row>
<Panel className="flex-1">
<Tabs width="100%" colorScheme={"green"} display="flex" flexDirection={"column"} h="full">
<TabList>
<TabList h={"50px"}>
<Tab px="0">
<span className="text-black font-semibold">
{t("FunctionPanel.InterfaceDebug")}
Expand Down Expand Up @@ -136,16 +137,17 @@ export default function DebugPanel() {
);
})}
</Select>
<Button
disabled={getFunctionUrl() === ""}
className="ml-2"
onClick={() => runningCode()}
bg="#E0F6F4"
color="primary.500"
isLoading={isLoading}
>
{t("FunctionPanel.Debug")}
</Button>
<Tooltip label={`快捷键: ${displayName.toUpperCase()}`}>
<Button
variant={"secondary"}
disabled={getFunctionUrl() === ""}
className="ml-2"
onClick={() => runningCode()}
isLoading={isLoading}
>
{t("FunctionPanel.Debug")}
</Button>
</Tooltip>
</div>
<div>
<Tabs p="0" variant="soft-rounded" colorScheme={"gray"} size={"sm"}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,11 @@ const AddDependenceModal = () => {
)}

<Button
colorScheme="blue"
onClick={() => {
submitDependence();
}}
>
{t("Confirm")}
{t("SaveAndRestart")}
</Button>
</ModalFooter>
</ModalContent>
Expand Down
13 changes: 6 additions & 7 deletions web/src/pages/app/functions/mods/DeployButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function DeployButton() {

const updateFunctionMutation = useUpdateFunctionMutation();

const { displayName } = useHotKey(
useHotKey(
DEFAULT_SHORTCUTS.deploy,
async () => {
onOpen();
Expand Down Expand Up @@ -61,14 +61,13 @@ export default function DeployButton() {
return (
<>
<Button
px={8}
variant="text"
disabled={store.getFunctionUrl() === ""}
colorScheme="blue"
onClick={() => {
onOpen();
}}
>
{t("FunctionPanel.Deploy")} ({displayName.toUpperCase()})
{t("FunctionPanel.Deploy")}
</Button>

{isOpen ? (
Expand All @@ -85,11 +84,11 @@ export default function DeployButton() {
</ModalBody>

<ModalFooter>
<Button mr={3} onClick={onClose}>
{t(" Cancel")}
<Button variant="ghost" mr={3} onClick={onClose}>
{t("Cancel")}
</Button>
<Button
colorScheme={"blue"}
variant="primary"
onClick={() => {
deploy();
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { BiMessageSquareDetail } from "react-icons/bi";
import { Popover, PopoverBody, PopoverContent, PopoverTrigger, Portal } from "@chakra-ui/react";

import FileTypeIcon from "@/components/FileTypeIcon";
import IconWrap from "@/components/IconWrap";
import { formatDate } from "@/utils/format";

import useFunctionStore from "../../store";

const FunctionDetailPopOver = () => {
const { currentFunction } = useFunctionStore();
return (
<Popover trigger="hover" placement="bottom-start" isLazy>
<IconWrap>
<PopoverTrigger>
<span>
<BiMessageSquareDetail />
</span>
</PopoverTrigger>
</IconWrap>
<Portal>
<PopoverContent width={"400px"}>
<PopoverBody px="6" py="4">
<h2 className="text-2xl mb-1">
<span className="align-middle">{currentFunction.name}</span>{" "}
<FileTypeIcon type="ts" />
</h2>
<div className="text-second">
<span>更新于 {formatDate(currentFunction.updatedAt)}</span>
<p className="mt-2">{currentFunction.desc}</p>
</div>
</PopoverBody>
</PopoverContent>
</Portal>
</Popover>
);
};

export default FunctionDetailPopOver;
Loading