Skip to content

Commit

Permalink
feat(web): support functions recycle bin (#1398)
Browse files Browse the repository at this point in the history
* feat(web): add functions recycle bin

* feat(web): add function recycle bin

* fix(web):

* fix(web): fix i18n & ts type

---------

Co-authored-by: 0fatal <72899968+0fatal@users.noreply.github.com>
  • Loading branch information
newfish-cmyk and 0fatal authored Jul 14, 2023
1 parent 1ee6def commit 1d22b6e
Show file tree
Hide file tree
Showing 19 changed files with 668 additions and 40 deletions.
11 changes: 10 additions & 1 deletion web/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,15 @@
"Core": "Core",
"No History": "No History",
"MyIncomeAndExpenses": "My Income And Expenses",
"RecycleBin": "Recycle Bin",
"Restore": "Restore",
"CheckAll": "Check All",
"Select": "Select",
"ClearRecycleBin": "Clear Recycle Bin",
"RestoreSuccess": "successfully restored",
"EmptySuccess": "successfully empty",
"RecycleBinEmpty": "Recycle Bin Empty",
"SelectOne": "At least select one",
"Apply": "apply",
"Developing": "Developing"
}
}
11 changes: 10 additions & 1 deletion web/public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,15 @@
"Core": "",
"No History": "暂无记录",
"MyIncomeAndExpenses": "我的收支",
"RecycleBin": "回收站",
"Restore": "还原",
"CheckAll": "全选",
"Select": "选择",
"ClearRecycleBin": "清空回收站",
"RestoreSuccess": "还原成功",
"EmptySuccess": "清空成功",
"RecycleBinEmpty": "回收站已清空",
"SelectOne": "请至少选择一个",
"Apply": "使用",
"Developing": "开发中"
}
}
9 changes: 9 additions & 0 deletions web/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,15 @@
"Hour": "小时",
"Core": "",
"No History": "暂无记录",
"RecycleBin": "回收站",
"Restore": "还原",
"CheckAll": "全选",
"Select": "选择",
"ClearRecycleBin": "清空回收站",
"RestoreSuccess": "还原成功",
"EmptySuccess": "清空成功",
"RecycleBinEmpty": "回收站已清空",
"SelectOne": "请至少选择一个",
"Apply": "使用",
"Developing": "开发中"
}
7 changes: 7 additions & 0 deletions web/src/apis/typing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ export type TFunction = {
params: any;
};

export type TFunctionList = {
list: TFunction[];
total: number;
page: number;
pageSize: number;
};

export type TMethod = "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS" | "PATCH";

export type Source = {
Expand Down
6 changes: 3 additions & 3 deletions web/src/apis/v1/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ export async function AccountControllerGetChargeOrder(
/**
* get all charge order
*/
export async function AccountControllerChargeRecord(
params: Paths.AccountControllerChargeRecord.BodyParameters,
export async function AccountControllerGetChargeRecords(
params: Paths.AccountControllerGetChargeRecords.BodyParameters,
): Promise<{
error: string;
data: Paths.AccountControllerChargeRecord.Responses;
data: Paths.AccountControllerGetChargeRecords.Responses;
}> {
// /v1/accounts/charge-orders
let _params: { [key: string]: any } = {
Expand Down
45 changes: 43 additions & 2 deletions web/src/apis/v1/api-auto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,14 @@ declare namespace Definitions {
items?: Definitions.FunctionTemplateItemDto[] /* items of the function template */;
};

export type DeleteRecycleBinItemsDto = {
ids?: string[] /* The list of item ids */;
};

export type RestoreRecycleBinItemsDto = {
ids?: string[] /* The list of item ids */;
};

export type CreateAutoscalingDto = {
enable?: boolean;
minReplicas?: number;
Expand Down Expand Up @@ -458,10 +466,11 @@ declare namespace Paths {
namespace AppControllerGetRuntimes {
export type QueryParameters = any;

export type BodyParameters = Definitions.CreateFunctionDto;
export type BodyParameters = any;

export type Responses = any;
}

namespace FunctionControllerCreate {
export type QueryParameters = any;

Expand Down Expand Up @@ -814,7 +823,7 @@ declare namespace Paths {
export type Responses = any;
}

namespace AccountControllerChargeRecord {
namespace AccountControllerGetChargeRecords {
export type QueryParameters = any;

export type BodyParameters = any;
Expand Down Expand Up @@ -1277,4 +1286,36 @@ declare namespace Paths {

export type Responses = any;
}

namespace FunctionRecycleBinControllerDeleteRecycleBinItems {
export type QueryParameters = any;

export type BodyParameters = Definitions.DeleteRecycleBinItemsDto;

export type Responses = any;
}

namespace FunctionRecycleBinControllerEmptyRecycleBin {
export type QueryParameters = any;

export type BodyParameters = any;

export type Responses = any;
}

namespace FunctionRecycleBinControllerGetRecycleBin {
export type QueryParameters = any;

export type BodyParameters = any;

export type Responses = any;
}

namespace FunctionRecycleBinControllerRestoreRecycleBinItems {
export type QueryParameters = any;

export type BodyParameters = Definitions.RestoreRecycleBinItemsDto;

export type Responses = any;
}
}
2 changes: 1 addition & 1 deletion web/src/apis/v1/billings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function BillingControllerGetExpenseByDay(
params: Paths.BillingControllerGetExpenseByDay.BodyParameters,
): Promise<{
error: string;
data: Definitions.Number;
data: Paths.BillingControllerGetExpenseByDay.Responses;
}> {
// /v1/billings/amounts
let _params: { [key: string]: any } = {
Expand Down
91 changes: 91 additions & 0 deletions web/src/apis/v1/recycle-bin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// @ts-ignore
/* eslint-disable */
///////////////////////////////////////////////////////////////////////
// //
// this file is autogenerated by service-generate //
// do not edit this file manually //
// //
///////////////////////////////////////////////////////////////////////
/// <reference path = "api-auto.d.ts" />
import request from "@/utils/request";
import useGlobalStore from "@/pages/globalStore";

/**
* Delete function Recycle bin items
*/
export async function FunctionRecycleBinControllerDeleteRecycleBinItems(
params: Definitions.DeleteRecycleBinItemsDto,
): Promise<{
error: string;
data: Definitions.Number;
}> {
// /v1/recycle-bin/{appid}/functions/delete
let _params: { [key: string]: any } = {
appid: useGlobalStore.getState().currentApp?.appid || "",
...params,
};
return request(`/v1/recycle-bin/${_params.appid}/functions/delete`, {
method: "POST",
data: params,
});
}

/**
* Empty function Recycle bin items
*/
export async function FunctionRecycleBinControllerEmptyRecycleBin(
params: Paths.FunctionRecycleBinControllerEmptyRecycleBin.BodyParameters,
): Promise<{
error: string;
data: Definitions.Number;
}> {
// /v1/recycle-bin/{appid}/functions
let _params: { [key: string]: any } = {
appid: useGlobalStore.getState().currentApp?.appid || "",
...params,
};
return request(`/v1/recycle-bin/${_params.appid}/functions`, {
method: "DELETE",
data: params,
});
}

/**
* Get cloud function recycle bin
*/
export async function FunctionRecycleBinControllerGetRecycleBin(
params: Paths.FunctionRecycleBinControllerGetRecycleBin.BodyParameters,
): Promise<{
error: string;
data: Paths.FunctionRecycleBinControllerGetRecycleBin.Responses;
}> {
// /v1/recycle-bin/{appid}/functions
let _params: { [key: string]: any } = {
appid: useGlobalStore.getState().currentApp?.appid || "",
...params,
};
return request(`/v1/recycle-bin/${_params.appid}/functions`, {
method: "GET",
params: params,
});
}

/**
* restore function Recycle bin items
*/
export async function FunctionRecycleBinControllerRestoreRecycleBinItems(
params: Definitions.RestoreRecycleBinItemsDto,
): Promise<{
error: string;
data: Definitions.Number;
}> {
// /v1/recycle-bin/{appid}/functions/restore
let _params: { [key: string]: any } = {
appid: useGlobalStore.getState().currentApp?.appid || "",
...params,
};
return request(`/v1/recycle-bin/${_params.appid}/functions/restore`, {
method: "POST",
data: params,
});
}
26 changes: 26 additions & 0 deletions web/src/components/CommonIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,29 @@ export const GroupIcon = createIcon({
viewBox: "0 0 20 20",
d: "M10.4688 16.2621C10.0508 16.3374 9.62449 16.3792 9.18977 16.3792C7.89397 16.3792 6.61489 16.0281 5.50301 15.3593L5.20205 15.1837L3.50497 15.6435C3.03681 15.7689 2.61045 15.3425 2.73585 14.8744L3.19565 13.1773C3.02009 12.8847 2.91141 12.6841 2.85289 12.5754C2.28441 11.5388 1.99181 10.3767 2.00017 9.18959C2.00017 5.2186 5.21877 2 9.18977 2C12.8096 2 15.8109 4.68356 16.3041 8.16967C17.7755 9.08091 18.67 10.686 18.67 12.4166C18.67 13.2526 18.461 14.0551 18.0764 14.7741C18.043 14.8409 17.9761 14.9496 17.8842 15.1085L18.1684 16.1535C18.2938 16.6216 17.8674 17.048 17.3993 16.9226L16.3543 16.6383L16.2289 16.7136C15.4514 17.1817 14.5652 17.4242 13.6624 17.4242C12.492 17.4158 11.3634 17.0145 10.4688 16.2621ZM12.0238 15.794C12.5338 16.0448 13.0939 16.1702 13.6624 16.1702C14.3395 16.1702 15.0083 15.9863 15.5852 15.6351C15.627 15.6101 15.744 15.5432 15.9446 15.4261C16.0868 15.3425 16.2623 15.3175 16.4212 15.3676L16.6636 15.4345L16.5967 15.1921C16.5549 15.0249 16.5716 14.8577 16.6636 14.7072C16.7639 14.54 16.8642 14.3644 16.9646 14.1972C17.2572 13.6538 17.4076 13.0436 17.4076 12.4249C17.4076 11.4468 17.0231 10.5021 16.3376 9.80823C16.1202 12.4918 14.4064 14.7657 12.0238 15.794ZM4.46637 13.2526L4.22393 14.1471L5.11845 13.9046C5.27729 13.8628 5.45285 13.8796 5.59497 13.9715C5.89593 14.1471 6.07149 14.2474 6.13001 14.2892C7.04961 14.8409 8.10297 15.1335 9.18141 15.1335C12.4585 15.1335 15.117 12.4751 15.117 9.19795C15.117 5.92084 12.4585 3.26236 9.18141 3.26236C5.90429 3.26236 3.24581 5.92084 3.24581 9.19795C3.24581 10.1928 3.48825 11.1458 3.94805 11.9986C4.00657 12.1156 4.16541 12.3748 4.39949 12.776C4.49145 12.9182 4.50817 13.0937 4.46637 13.2526ZM11.7897 6.99928C12.1325 6.99928 12.4167 7.27516 12.4167 7.62628C12.4167 7.96903 12.1408 8.25327 11.7897 8.25327H6.58145C6.23869 8.25327 5.95445 7.97739 5.95445 7.62628C5.95445 7.28352 6.23033 6.99928 6.58145 6.99928H11.7897ZM9.29009 10.1259C9.63285 10.1259 9.91709 10.4018 9.91709 10.7529C9.91709 11.0957 9.64121 11.3799 9.29009 11.3799H6.58145C6.23869 11.3799 5.95445 11.104 5.95445 10.7529C5.95445 10.4102 6.23033 10.1259 6.58145 10.1259H9.29009Z",
});

export const DeleteIcon = createIcon({
displayName: "DeleteIcon",
viewBox: "0 0 15 14",
d: "M4.01687 11.0833C4.01687 11.3928 4.13978 11.6895 4.35857 11.9083C4.57737 12.1271 4.87411 12.25 5.18353 12.25H9.8502C10.1596 12.25 10.4564 12.1271 10.6752 11.9083C10.894 11.6895 11.0169 11.3928 11.0169 11.0833V4.08333H4.01687V11.0833ZM5.18353 5.25H9.8502V11.0833H5.18353V5.25ZM9.55853 2.33333L8.9752 1.75H6.05853L5.4752 2.33333H3.43353V3.5H11.6002V2.33333H9.55853Z",
});

export const RestoreIcon = createIcon({
displayName: "RestoreIcon",
viewBox: "0 0 16 17",
d: "M8 2.5C6.4087 2.5 4.88258 3.13214 3.75736 4.25736C2.63214 5.38258 2 6.9087 2 8.5H0L2.66667 11.1667L5.33333 8.5H3.33333C3.33333 7.26232 3.825 6.07534 4.70017 5.20017C5.57534 4.325 6.76232 3.83333 8 3.83333C9.23768 3.83333 10.4247 4.325 11.2998 5.20017C12.175 6.07534 12.6667 7.26232 12.6667 8.5C12.6667 9.73768 12.175 10.9247 11.2998 11.7998C10.4247 12.675 9.23768 13.1667 8 13.1667C7 13.1667 6.06 12.8333 5.29333 12.3L4.33333 13.26C5.38772 14.062 6.67529 14.4974 8 14.5C9.5913 14.5 11.1174 13.8679 12.2426 12.7426C13.3679 11.6174 14 10.0913 14 8.5C14 6.9087 13.3679 5.38258 12.2426 4.25736C11.1174 3.13214 9.5913 2.5 8 2.5ZM9.33333 8.5C9.33333 8.14638 9.19286 7.80724 8.94281 7.55719C8.69276 7.30714 8.35362 7.16667 8 7.16667C7.64638 7.16667 7.30724 7.30714 7.05719 7.55719C6.80714 7.80724 6.66667 8.14638 6.66667 8.5C6.66667 8.85362 6.80714 9.19276 7.05719 9.44281C7.30724 9.69286 7.64638 9.83333 8 9.83333C8.35362 9.83333 8.69276 9.69286 8.94281 9.44281C9.19286 9.19276 9.33333 8.85362 9.33333 8.5Z",
});

export const GoSelectIcon = () => {
return (
<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M2.66667 11.8333H7.33334M13.3333 9.83329L10.6667 12.5L9.33334 11.1666M2.66667 8.49996H10M2.66667 5.16663H10"
stroke="#5A646E"
strokeWidth="1.4"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
};
1 change: 0 additions & 1 deletion web/src/components/SectionList/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
justify-content: space-between;
padding: 0px 12px;
margin-bottom: 2px;
color: var(--chakra-colors-grayModern-600);

span {
vertical-align: middle;
Expand Down
Loading

0 comments on commit 1d22b6e

Please sign in to comment.