Skip to content

Commit

Permalink
fix: solve can not delete queries in sql editor
Browse files Browse the repository at this point in the history
  • Loading branch information
jingsam committed Aug 4, 2024
1 parent 5deee93 commit 8958686
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 12 deletions.
2 changes: 1 addition & 1 deletion apps/studio/components/grid/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ const RowHeader = ({ table, sorts, filters }: RowHeaderProps) => {
].join(' ')}
>
<span className="text-xs text-foreground">
模拟角色不支持清空表操作
切换角色不支持清空表操作
</span>
</div>
</Tooltip.Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const UserImpersonationSelector = () => {
impersonatingUser.id ??
'未知用户'
)}`
: '模拟用户'}
: '切换用户'}
</h2>
<p className="text-sm text-foreground-light max-w-md">
{!impersonatingUser
Expand Down Expand Up @@ -111,7 +111,7 @@ const UserImpersonationSelector = () => {
<CollapsibleTrigger_Shadcn_ className="group font-normal p-0 [&[data-state=open]>div>svg]:!-rotate-180">
<div className="flex items-center gap-x-1 w-full">
<p className="text-xs text-foreground-light group-hover:text-foreground transition">
Advanced options
高级选项
</p>
<ChevronDown
className="transition-transform duration-200"
Expand All @@ -122,21 +122,20 @@ const UserImpersonationSelector = () => {
</CollapsibleTrigger_Shadcn_>
<CollapsibleContent_Shadcn_ className="mt-1 flex flex-row items-center gap-x-4 text-sm text-foreground-light">
<div className="flex items-center gap-x-1">
<h3>MFA assurance level</h3>
<h3>MFA 认证级别</h3>
<InfoTooltip side="top" className="flex flex-col gap-1 max-w-96">
<p>
AAL1 verifies users via standard login methods, while AAL2 adds a second
authentication factor.
AAL1 通过标准登录方法验证用户,而 AAL2 添加了第二身份验证因素。
<br />
If you're not using MFA, you can leave this on AAL1.
如果您不使用 MFA,您可以将此设置为 AAL1
</p>
<a
href="/docs/guides/auth/auth-mfa"
target="_blank"
rel="noreferrer"
className="flex items-center gap-x-1 opacity-50 hover:opacity-100 transition"
>
Learn more about MFA <ExternalLink size={14} strokeWidth={2} />
了解更多有关 MFA 的信息 <ExternalLink size={14} strokeWidth={2} />
</a>
</InfoTooltip>
</div>
Expand Down Expand Up @@ -231,7 +230,7 @@ const UserImpersonatingRow = ({
onClick(user)
}}
>
{isImpersonating ? '停止模拟' : '模拟'}
{isImpersonating ? '停止切换' : '切换'}
</Button>
</div>
)
Expand Down Expand Up @@ -269,7 +268,7 @@ const UserRow = ({ user, onClick, isImpersonating = false }: UserRowProps) => {
onClick(user)
}}
>
{isImpersonating ? '停止模拟' : '模拟'}
{isImpersonating ? '停止切换' : '切换'}
</Button>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const DeleteConfirmationDialogs = ({
if (filters.length === 0) {
if (getImpersonatedRole() !== undefined) {
snap.closeConfirmationDialog()
return toast.error('当处于模拟角色时不支持表清空操作')
return toast.error('当处于切换角色时不支持表清空操作')
}

truncateRows({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const SQLEditorNavV1 = ({

{isError && (
<div className="px-4">
<AlertError error={error as ResponseError} subject="Failed to load SQL snippets" />
<AlertError error={error as ResponseError} subject="载入 SQL 代码片段失败" />
</div>
)}

Expand Down
5 changes: 5 additions & 0 deletions apps/studio/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ loader.config({
? 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.37.0/min/vs'
: `${BASE_PATH}/monaco-editor`,
},
'vs/nls': {
availableLanguages: {
'*': 'zh-cn',
},
},
})

// [Joshen TODO] Once we settle on the new nav layout - we'll need a lot of clean up in terms of our layout components
Expand Down
9 changes: 9 additions & 0 deletions apps/studio/pages/api/projects/[ref]/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
return handlePatch(req, res)
case 'PUT':
return handlePut(req, res)
case 'DELETE':
return handleDelete(req, res)
default:
res.setHeader('Allow', ['GET', 'POST', 'PATCH', 'PUT'])
res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
Expand Down Expand Up @@ -60,3 +62,10 @@ const handlePut = async (req: NextApiRequest, res: NextApiResponse) => {
const snippet: UserContent = req.body
return res.status(200).json({ data: snippet })
}

const handleDelete = async (req: NextApiRequest, res: NextApiResponse) => {
// Platform specific endpoint
const { ids } = req.query
const idsArray = typeof ids ==='string'? ids.split(',') : ids
return res.status(200).json(idsArray?.map(id => ({ id })))
}
31 changes: 31 additions & 0 deletions apps/studio/public/monaco-editor/editor/editor.main.nls.zh-cn.js

Large diffs are not rendered by default.

0 comments on commit 8958686

Please sign in to comment.