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(web): fix function layout & more button #655

Merged
merged 1 commit into from
Jan 19, 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
6 changes: 3 additions & 3 deletions web/src/chakraTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ const Button = defineStyleConfig({
},

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

Expand Down
7 changes: 4 additions & 3 deletions web/src/components/Editor/FunctionEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ const updateModel = (path: string, value: string, editorRef: any) => {

function FunctionEditor(props: {
value: string;
className?: string;
onChange: (value: string | undefined) => void;
path: string;
height: string;
height?: string;
}) {
const { value, onChange, path, height = "100%" } = props;
const { value, onChange, path, height = "100%", className } = props;

const editorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>();
const subscriptionRef = useRef<monaco.IDisposable | undefined>(undefined);
Expand Down Expand Up @@ -101,7 +102,7 @@ function FunctionEditor(props: {
return () => {};
}, [path, value]);

return <div style={{ height: height }} ref={monacoEl}></div>;
return <div style={{ height: height }} className={className} ref={monacoEl}></div>;
}

export default FunctionEditor;
3 changes: 1 addition & 2 deletions web/src/components/Pagination/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ export default function Pagination(props: {
>
{(options || [10, 20, 30]).map((data: any) => (
<option key={data} value={data}>
{data}
<Text> / {t("Page")}</Text>
{data} / {t("Page").toString()}
</option>
))}
</Select>
Expand Down
24 changes: 9 additions & 15 deletions web/src/pages/app/database/CollectionListPanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { AddIcon, Search2Icon } from "@chakra-ui/icons";
import { AddIcon, CopyIcon, Search2Icon } from "@chakra-ui/icons";
import { Input, InputGroup, InputLeftElement } from "@chakra-ui/react";

import CopyText from "@/components/CopyText";
Expand Down Expand Up @@ -86,21 +86,15 @@ export default function CollectionListPanel() {
isHidden={db.name !== store.currentDB?.name || store.currentShow !== "DB"}
>
<>
<div className="text-grayIron-600">
<div className="text-grayModern-900 w-[20px] h-[20px] text-center">
<CopyText
hideToolTip
text={db.name}
className="w-[28px]"
tip="名称复制成功"
/>
<CopyText hideToolTip text={db.name} tip="名称复制成功">
<div>
<div className="text-grayModern-900 w-[20px] h-[20px] text-center">
<CopyIcon />
</div>
<div className="text-grayIron-600">{t("Copy")}</div>
</div>
{t("Copy")}
</div>
<div className="text-grayIron-600">
<DeleteCollectionModal database={db} />
{t("Delete")}
</div>
</CopyText>
<DeleteCollectionModal database={db} />
</>
</MoreButton>
</div>
Expand Down
38 changes: 19 additions & 19 deletions web/src/pages/app/database/PolicyListPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,28 @@ export default function PolicyListPanel() {
}
>
<>
<div className="text-grayIron-600">
<div className="text-grayModern-900 w-[20px] h-[20px] text-center">
<AddPolicyModal key="AddPolicyModal" isEdit defaultData={item}>
<EditIcon fontSize={10} />
</AddPolicyModal>
<AddPolicyModal key="AddPolicyModal" isEdit defaultData={item}>
<div className="text-grayIron-600">
<div className="text-grayModern-900 w-[20px] h-[20px] text-center">
<EditIcon />
</div>
{t("Edit")}
</div>
{t("Edit")}
</div>
<div className="text-grayIron-600">
<ConfirmButton
onSuccessAction={async () => {
await deletePolicyMutation.mutateAsync(item.name);
}}
headerText={String(t("Delete"))}
bodyText={t("CollectionPanel.ConformDelete")}
>
</AddPolicyModal>
<ConfirmButton
onSuccessAction={async () => {
await deletePolicyMutation.mutateAsync(item.name);
}}
headerText={String(t("Delete"))}
bodyText={t("CollectionPanel.ConformDelete")}
>
<div className="text-grayIron-600">
<div className="text-grayModern-900 w-[20px] h-[20px] text-center">
<DeleteIcon fontSize={14} />
<DeleteIcon />
</div>
</ConfirmButton>
{t("Delete")}
</div>
{t("Delete")}
</div>
</ConfirmButton>
</>
</MoreButton>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function DeleteCollectionModal(props: { database: any }) {
return (
<>
<div
className="text-grayModern-900 w-[20px] h-[20px] text-center"
onClick={() => {
reset();
onOpen();
Expand All @@ -51,7 +50,10 @@ function DeleteCollectionModal(props: { database: any }) {
}, 0);
}}
>
<DeleteIcon fontSize={12} />
<div className="text-grayModern-900 w-[20px] h-[20px] text-center">
<DeleteIcon fontSize={12} />
</div>
<div className="text-grayIron-600">{t("Delete")}</div>
</div>

<Modal isOpen={isOpen} onClose={onClose}>
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/app/functions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function FunctionPage() {
</Row>
</Col>
<Col className="overflow-hidden">
<Row>
<Row className="overflow-hidden">
<EditorPanel />
</Row>
<Row {...functionPageConfig.ConsolePanel}>
Expand Down
12 changes: 7 additions & 5 deletions web/src/pages/app/functions/mods/DependencePanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,22 @@ export default function DependenceList() {
onClick={() => {}}
className="group"
>
<div>
<div className="w-[200px] overflow-hidden">
<Tooltip
label={packageItem?.builtin ? "内置依赖,不可更改" : null}
placement="top"
>
<span className="w-40 inline-block whitespace-nowrap overflow-hidden overflow-ellipsis">
<span className="w-full inline-block whitespace-nowrap overflow-hidden overflow-ellipsis">
{packageItem?.name}
</span>
</Tooltip>
</div>
<div className=" w-20 inline-block whitespace-nowrap overflow-hidden overflow-ellipsis">
<span>{packageItem?.spec}</span>
<div className=" w-[100px] flex">
<span className="flex-grow inline-block whitespace-nowrap overflow-hidden overflow-ellipsis">
{packageItem?.spec}
</span>
{!packageItem?.builtin ? (
<span className="ml-2 hidden group-hover:inline-block">
<span className=" w-[10px] ml-2 hidden group-hover:inline-block">
<Tooltip label={t("Delete").toString()} placement="top">
<CloseIcon
fontSize={10}
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/app/functions/mods/EditorPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function EditorPanel() {
<FunctionDetailPopOver />
{currentFunction?.id &&
functionCache.getCache(currentFunction?.id) !== currentFunction?.source?.code && (
<span className="flex-none inline-block w-2 h-2 rounded-full bg-yellow-600"></span>
<span className="flex-none inline-block w-2 h-2 rounded-full bg-warn-700"></span>
)}
{currentFunction?.desc ? (
<span className="text-slate-400 font-normal whitespace-nowrap overflow-hidden">
Expand All @@ -49,7 +49,7 @@ function EditorPanel() {

{currentFunction?.name ? (
<FunctionEditor
height="calc(100vh - 300px)"
className="flex-grow"
path={currentFunction?.name || ""}
value={functionCache.getCache(currentFunction!.id)}
onChange={(value) => {
Expand Down
107 changes: 52 additions & 55 deletions web/src/pages/app/functions/mods/FunctionPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function FunctionList() {
const deleteFunctionMutation = useDeleteFunctionMutation();

return (
<Panel className="flex-grow">
<Panel className="flex-grow overflow-hidden">
<Panel.Header
title={t`FunctionPanel.FunctionList`}
actions={[
Expand All @@ -77,67 +77,64 @@ export default function FunctionList() {
</CreateModal>,
]}
/>
<div>
<div className="flex items-center mb-3">
<Input
size="sm"
rounded={"full"}
placeholder={String(t("FunctionPanel.SearchPlaceholder"))}
onChange={(event) => {
setKeywords(event.target.value);
}}
/>
</div>

<SectionList style={{ height: "calc(100vh - 420px)", overflowY: "auto" }}>
{(allFunctionList || [])
.filter((item: TFunction) => item?.name.includes(keywords))
.map((func: any) => {
return (
<SectionList.Item
isActive={func?.name === currentFunction?.name}
key={func?.name || ""}
className="group"
onClick={() => {
setCurrentFunction(func);
navigate(`/app/${currentApp?.appid}/${Pages.function}/${func?.name}`);
}}
>
<div>
<FileTypeIcon type={FileType.ts} />
<span className="ml-2 font-medium text-black">{func?.name}</span>
</div>
<MoreButton isHidden={func.name !== currentFunction?.name}>
<>
<div className="flex items-center mb-3">
<Input
size="sm"
rounded={"full"}
placeholder={String(t("FunctionPanel.SearchPlaceholder"))}
onChange={(event) => {
setKeywords(event.target.value);
}}
/>
</div>
<SectionList className="flex-grow" style={{ overflowY: "auto" }}>
{(allFunctionList || [])
.filter((item: TFunction) => item?.name.includes(keywords))
.map((func: any) => {
return (
<SectionList.Item
isActive={func?.name === currentFunction?.name}
key={func?.name || ""}
className="group"
onClick={() => {
setCurrentFunction(func);
navigate(`/app/${currentApp?.appid}/${Pages.function}/${func?.name}`);
}}
>
<div>
<FileTypeIcon type={FileType.ts} />
<span className="ml-2 font-medium text-black">{func?.name}</span>
</div>
<MoreButton isHidden={func.name !== currentFunction?.name}>
<>
<CreateModal functionItem={func}>
<div className="text-grayIron-600">
<div className="text-grayModern-900 w-[30px] h-[20px] text-center">
<CreateModal functionItem={func}>
<EditIcon fontSize={13} />
</CreateModal>
<div className="text-grayModern-900 w-[20px] h-[20px] text-center pl-1">
<EditIcon />
</div>
{t("Edit")}
</div>
</CreateModal>
<ConfirmButton
onSuccessAction={async () => {
await deleteFunctionMutation.mutateAsync(func);
}}
headerText={String(t("Delete"))}
bodyText={String(t("FunctionPanel.DeleteConfirm"))}
>
<div className="text-grayIron-600">
<ConfirmButton
onSuccessAction={async () => {
await deleteFunctionMutation.mutateAsync(func);
}}
headerText={String(t("Delete"))}
bodyText={String(t("FunctionPanel.DeleteConfirm"))}
>
<div className="text-grayModern-900 w-[20px] h-[20px] text-center">
<DeleteIcon fontSize={14} />
</div>
</ConfirmButton>
<div className="text-grayModern-900 w-[20px] h-[20px] text-center">
<DeleteIcon />
</div>
{t("Delete")}
</div>
</>
</MoreButton>
</SectionList.Item>
);
})}
</SectionList>
</div>
</ConfirmButton>
</>
</MoreButton>
</SectionList.Item>
);
})}
</SectionList>
</Panel>
);
}
8 changes: 6 additions & 2 deletions web/src/pages/app/storages/mods/DeleteBucketModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ function DeleteBucketModal(props: { storage: TBucket; onSuccessAction?: () => vo
return (
<>
<div
className="text-grayModern-900 w-[20px] h-[20px] text-center"
onClick={() => {
reset();
onOpen();
Expand All @@ -47,7 +46,12 @@ function DeleteBucketModal(props: { storage: TBucket; onSuccessAction?: () => vo
}, 0);
}}
>
<DeleteIcon fontSize={12} />
<div className="text-grayIron-600">
<div className="text-grayModern-900 w-[20px] h-[20px] text-center">
<DeleteIcon fontSize={12} />
</div>
{t("Delete")}
</div>
</div>

<Modal isOpen={isOpen} onClose={onClose}>
Expand Down
31 changes: 14 additions & 17 deletions web/src/pages/app/storages/mods/StorageListPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,22 @@ export default function StorageListPanel() {
</Tag>
<MoreButton isHidden={storage?.name !== store.currentStorage?.name}>
<>
<div className="text-grayIron-600">
<div className="text-grayModern-900 w-[20px] h-[20px] text-center">
<CreateBucketModal storage={storage}>
<CreateBucketModal storage={storage}>
<div className="text-grayIron-600">
<div className="text-grayModern-900 w-[20px] h-[20px] text-center">
<EditIcon fontSize={10} />
</CreateBucketModal>
</div>
{t("Edit")}
</div>
{t("Edit")}
</div>
<div className="text-grayIron-600">
<DeleteBucketModal
storage={storage}
onSuccessAction={() => {
if (storage.name === store.currentStorage?.name) {
store.setCurrentStorage(bucketListQuery?.data?.data[0]);
}
}}
/>
{t("Delete")}
</div>
</CreateBucketModal>
<DeleteBucketModal
storage={storage}
onSuccessAction={() => {
if (storage.name === store.currentStorage?.name) {
store.setCurrentStorage(bucketListQuery?.data?.data[0]);
}
}}
/>
</>
</MoreButton>
</div>
Expand Down
Loading