Skip to content

Commit

Permalink
refactor(desktop): refactor delete
Browse files Browse the repository at this point in the history
  • Loading branch information
xudaotutou committed Sep 10, 2024
1 parent 4fabfc9 commit dc49a4b
Show file tree
Hide file tree
Showing 53 changed files with 1,203 additions and 397 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- CreateEnum
CREATE TYPE "UserStatus" AS ENUM ('NORMAL_USER', 'LOCK_USER', 'DELETE_USER');

-- AlterTable
ALTER TABLE "User" ADD COLUMN "status" "UserStatus" NOT NULL DEFAULT 'NORMAL_USER';
7 changes: 7 additions & 0 deletions frontend/desktop/prisma/global/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ model User {
id String @unique
name String @unique
oauthProvider OauthProvider[]
status UserStatus @default(NORMAL_USER)
oldMergeUserTransactionInfo MergeUserTransactionInfo[] @relation("oldUser")
newMergeUserTransactionInfo MergeUserTransactionInfo[] @relation("newUser")
DeleteUserTransactionInfo DeleteUserTransactionInfo?
Expand Down Expand Up @@ -316,3 +317,9 @@ enum AuditAction {
DELETE
CREATE
}

enum UserStatus {
NORMAL_USER
LOCK_USER
DELETE_USER
}
12 changes: 12 additions & 0 deletions frontend/desktop/public/locales/en/applist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"terminal": "terminal",
"job": "job",
"other": "other",
"object-storage": "object-storage",
"cloud-vm": "cloud-vm",
"db": "database",
"app": "app",
"app-store": "app-store",
"db-backup": "db-backup",
"app_type": "app type"
}
11 changes: 10 additions & 1 deletion frontend/desktop/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"click_on_any_shadow_to_skip": "Click on any shadow to skip",
"completed_the_deployment_of_an_nginx_for_the_first_time": "Completed the deployment of an nginx for the first time",
"confirm": "Confirm",
"confirm_again": "confirm again",
"confirmnewpassword": "Confirm New Password",
"core": "Core",
"cost_center": "Cost Center",
Expand All @@ -44,8 +45,10 @@
"delete_account": "Delete account",
"delete_account_button": "Delete",
"delete_account_caution": "Once a resource is deleted, it cannot be recovered. \nTherefore, before performing the above operations, please be sure to back up your data.",
"delete_account_force_button": "Delete Directly",
"delete_account_remain_resources": "The following resources in your account have not been deleted. Please manually delete all the resources listed below, ensuring nothing is overlooked.",
"delete_account_tips": "Permanently delete this account and all its content.",
"delete_account_title": "Logout prompt",
"delete_account_title": "Delete Account",
"deleteaccounttitle": "Sealos will permanently delete this account.",
"deletemyaccount": "DeleteMyAccount",
"deploy_an_application": "Let’s deploy an application~",
Expand All @@ -62,6 +65,8 @@
"expected_used": "Expected used",
"failed_to_generate_invitation_link": "Failed to generate invitation link",
"flow": "Traffic",
"force_delete_keywords": "All resources cannot be recovered after account deletion.",
"force_delete_tips": "There are still undeleted resources in your account. Once deleted, all resources will be unrecoverable. Please ensure you have backed up or transferred all important data.",
"from": "From",
"generate_invitation_link": "Generate invitation link",
"get_code": "verification",
Expand All @@ -79,6 +84,7 @@
"idCard_invalid": "INVAILD ID CARD FORMAT",
"in_payment": "In Payment ...",
"in_time": "In Time",
"insufficient_balance": "Your account currently has outstanding payments",
"insufficient_balance_tips": "There is currently an outstanding balance in your account. In order to successfully complete the account cancellation process, please settle the outstanding balance first.",
"invaild_context": "You need switch to other workspace for handling",
"invaild_name_of_team": "Invaild Name of Workspace",
Expand All @@ -97,6 +103,7 @@
"language": "Language",
"launch_various_third-party_applications_with_one_click": "Launch various third-party applications with one click",
"license_buy": "License Buy",
"link": "link",
"loading": "Loading",
"log_in": "Log In",
"log_out": "Log Out",
Expand Down Expand Up @@ -147,6 +154,8 @@
"placeholders_name": "Please enter your name",
"placeholders_phone": "Please enter your phone number",
"placeholders_verifycode": "please enter verification code",
"please_enter": "Please enter",
"please_enter_username": "Please enter your username",
"please_read_and_agree_to_the_agreement": "Please read and agree to the agreement",
"privacy_policy": "Privacy Policy",
"private_team_id_of_user": "User's ID",
Expand Down
12 changes: 12 additions & 0 deletions frontend/desktop/public/locales/zh/applist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"terminal": "终端",
"job": "任务",
"other": "其他",
"object-storage": "对象存储",
"cloud-vm": "云主机",
"db": "数据库",
"app": "应用",
"app-store": "应用商店",
"db-backup": "数据库备份",
"app_type": "应用类型"
}
11 changes: 10 additions & 1 deletion frontend/desktop/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"click_on_any_shadow_to_skip": "点击任意阴影跳过",
"completed_the_deployment_of_an_nginx_for_the_first_time": "部署一个 nginx ,首次完成 将",
"confirm": "确认",
"confirm_again": "再次确认",
"confirmnewpassword": "确认新密码",
"core": "",
"create_team": "创建工作空间",
Expand All @@ -41,8 +42,10 @@
"delete_account": "注销账号",
"delete_account_button": "注销",
"delete_account_caution": "资源一旦删除,将不可恢复。因此,在执行以上操作前,请务必做好数据备份工作",
"delete_account_force_button": "直接注销",
"delete_account_remain_resources": "账号中仍有以下资源未删除,请您手动删除下列所有资源,确保无遗漏。",
"delete_account_tips": "将永久删除此账户及其所有内容",
"delete_account_title": "注销提示",
"delete_account_title": "注销账户",
"deleteaccounttitle": "Sealos 将永久删除此账户。",
"deletemyaccount": "删除我的账号",
"deploy_an_application": "来部署一个应用吧~",
Expand All @@ -59,6 +62,8 @@
"expected_used": "预计还能使用",
"failed_to_generate_invitation_link": "生成邀请链接失败",
"flow": "流量",
"force_delete_keywords": "注销后所有资源无法恢复",
"force_delete_tips": "您的账号中仍有未删除的资源。一旦注销,所有资源将无法恢复。请确保已经备份或转移了所有重要数据。",
"from": "来自",
"generate_invitation_link": "生成邀请链接",
"get_code": "获取验证码",
Expand All @@ -76,6 +81,7 @@
"idCard_invalid": "身份证格式不对",
"in_payment": "支付中 ...",
"in_time": "加入时间",
"insufficient_balance": "您的账户目前存在未结清的款项",
"insufficient_balance_tips": "您的账户目前存在未结清的款项,为了顺利完成账户注销流程,请先结清欠款。",
"invaild_context": "你需要切换到其他工作空间操作",
"invaild_name_of_team": "不合法的工作空间名称",
Expand All @@ -93,6 +99,7 @@
"language": "语言",
"launch_various_third-party_applications_with_one_click": "一键启动各种第三方应用",
"license_buy": "License 购买",
"link": "链接",
"loading": "加载中",
"log_in": "登录",
"log_out": "登出",
Expand Down Expand Up @@ -143,6 +150,8 @@
"placeholders_name": "请输入您的姓名",
"placeholders_phone": "请输入您的电话号码",
"placeholders_verifycode": "请输入验证码",
"please_enter": "请输入",
"please_enter_username": "请输入您的用户名",
"please_read_and_agree_to_the_agreement": "请阅读并同意协议",
"privacy_policy": "隐私政策",
"private_team_id_of_user": "用户ID",
Expand Down
33 changes: 25 additions & 8 deletions frontend/desktop/src/api/auth.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { SmsType } from '@/services/backend/db/verifyCode';
import { RegionResourceType } from '@/services/backend/svc/checkResource';
import request from '@/services/request';
import { OauthProvider, TUserExist } from '@/types/user';
import { ApiResp, Region } from '@/types';
import { AxiosHeaders, AxiosHeaderValue, type AxiosInstance } from 'axios';
import useSessionStore from '@/stores/session';
import { ProviderType } from 'prisma/global/generated/client';
import { ValueOf } from '@/types/tools';
import { SmsType } from '@/services/backend/db/verifyCode';
import { USER_MERGE_STATUS } from '@/types/response/merge';
import { ApiResp, Region } from '@/types';
import { BIND_STATUS } from '@/types/response/bind';
import { UNBIND_STATUS } from '@/types/response/unbind';
import { RESOURCE_STATUS } from '@/types/response/checkResource';
import { DELETE_USER_STATUS } from '@/types/response/deleteUser';
import { USER_MERGE_STATUS } from '@/types/response/merge';
import { UNBIND_STATUS } from '@/types/response/unbind';
import { SemData } from '@/types/sem';
import { ValueOf } from '@/types/tools';
import { TUserExist } from '@/types/user';
import { type AxiosInstance } from 'axios';
import { ProviderType } from 'prisma/global/generated/client';

export const _getRegionToken = (request: AxiosInstance) => () =>
request.post<any, ApiResp<{ token: string; kubeconfig: string; appToken: string }>>(
Expand Down Expand Up @@ -147,11 +149,22 @@ export const _mergeUser =

export const _deleteUser = (request: AxiosInstance) => () =>
request<never, ApiResp<RESOURCE_STATUS>>('/api/auth/delete');
export const _checkRemainResource = (request: AxiosInstance) => () =>
request<
never,
ApiResp<{ regionResourceList: RegionResourceType[]; code: string }>,
RESOURCE_STATUS
>('/api/auth/delete/checkAllResource');

export const _forceDeleteUser = (request: AxiosInstance) => (data: { code: string }) =>
request.post<never, ApiResp<DELETE_USER_STATUS>>('/api/auth/delete/force', data);
export const _realNameAuthRequest =
(request: AxiosInstance) => (data: { name: string; phone?: string; idCard: string }) =>
request.post<any, ApiResp<{ name: string }>>('/api/account/realNameAuth', data);

export const _getAmount = (request: AxiosInstance) => () =>
request<never, ApiResp<{ balance: number; deductionBalance: number }>>('/api/account/getAmount');

export const passwordExistRequest = _passwordExistRequest(request);
export const passwordLoginRequest = _passwordLoginRequest(request, (token) => {
useSessionStore.setState({ token });
Expand All @@ -173,5 +186,9 @@ export const unBindRequest = _oauthProviderUnbind(request);
export const signInRequest = _oauthProviderSignIn(request);
export const mergeUserRequest = _mergeUser(request);
export const deleteUserRequest = _deleteUser(request);
export const checkRemainResource = _checkRemainResource(request);
export const forceDeleteUser = _forceDeleteUser(request);

export const realNameAuthRequest = _realNameAuthRequest(request);

export const getAmount = _getAmount(request);
1 change: 0 additions & 1 deletion frontend/desktop/src/api/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ApiResp } from '@/types';
import { NamespaceDto, UserRole, teamMessageDto } from '@/types/team';
import { TeamUserDto } from '@/types/user';
import { AxiosInstance } from 'axios';
import { Session } from 'sealos-desktop-sdk/*';

export const _abdicateRequest =
(request: AxiosInstance) => (data: { ns_uid: string; targetUserCrUid: string }) =>
Expand Down
Loading

0 comments on commit dc49a4b

Please sign in to comment.