功能: 右键新增属性弹窗与获取特定版本(FE-019),服务端新增 /api/items/info
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import type {
|
||||
FolderDiffItem,
|
||||
GetLatestResult,
|
||||
HistoryEntry,
|
||||
ItemInfo,
|
||||
MappingInfo,
|
||||
OperationLogEntry,
|
||||
PendingChange,
|
||||
@@ -173,6 +174,13 @@ export function checkin(body: { paths?: string[]; comment: string }) {
|
||||
return apiClient.post<{ checkin: CheckinResult }>("/api/checkin", { body })
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取服务端对象(文件或目录)的属性信息,供属性弹窗展示。
|
||||
*/
|
||||
export function getItemInfo(params: { serverPath: string }) {
|
||||
return apiClient.get<{ item: ItemInfo }>("/api/items/info", { query: params })
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取服务器内容(latest 或指定 changeset),或读取本地映射文件内容。
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,7 @@ export type {
|
||||
FolderDiffItem,
|
||||
GetLatestResult,
|
||||
HistoryEntry,
|
||||
ItemInfo,
|
||||
MappingConfig,
|
||||
MappingInfo,
|
||||
OperationLogEntry,
|
||||
|
||||
@@ -159,6 +159,20 @@ export interface HistoryEntry {
|
||||
comment: string
|
||||
}
|
||||
|
||||
// 服务端对象属性信息,对应 core TfsItemInfo(属性弹窗用)。
|
||||
export interface ItemInfo {
|
||||
serverPath: string
|
||||
folder: boolean
|
||||
changeset: number
|
||||
checkinDate: number | null
|
||||
author: string
|
||||
comment: string
|
||||
/** 文件大小(字节),目录为 null。 */
|
||||
size: number | null
|
||||
/** 文件编码名称,目录为 null。 */
|
||||
encoding: string | null
|
||||
}
|
||||
|
||||
// 文件内容,对应 core TfsFileContent,binary / tooLarge 时 content 为空串。
|
||||
export interface FileContent {
|
||||
serverPath: string
|
||||
|
||||
@@ -32,6 +32,7 @@ export type FileActionId =
|
||||
| "unmap"
|
||||
| "getLatest"
|
||||
| "forceGetLatest"
|
||||
| "getSpecificVersion"
|
||||
| "checkout"
|
||||
| "delete"
|
||||
| "undo"
|
||||
@@ -40,6 +41,7 @@ export type FileActionId =
|
||||
| "history"
|
||||
| "viewFile"
|
||||
| "diffLocalLatest"
|
||||
| "properties"
|
||||
|
||||
// 单个菜单项:是否可用与置灰原因。
|
||||
export interface FileMenuItem {
|
||||
@@ -175,9 +177,27 @@ function buildFolderMenu(target: FileTarget): FileMenuItem[][] {
|
||||
{ id: "history", label: "查看历史", enabled: true },
|
||||
])
|
||||
|
||||
sections.push(buildAdvancedSection(target))
|
||||
|
||||
return sections
|
||||
}
|
||||
|
||||
/**
|
||||
* 高级动作分组:获取特定版本(按 changeset 覆盖本地)与属性弹窗。
|
||||
*/
|
||||
function buildAdvancedSection(target: FileTarget): FileMenuItem[] {
|
||||
return [
|
||||
{
|
||||
id: "getSpecificVersion",
|
||||
label: "获取特定版本…",
|
||||
enabled: target.mapped,
|
||||
danger: true,
|
||||
reason: target.mapped ? undefined : NOT_MAPPED_REASON,
|
||||
},
|
||||
{ id: "properties", label: "属性…", enabled: true },
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件菜单:查看 / 比较 / 历史 + 本地工作区动作,按挂起状态控制可用性。
|
||||
* pendingAdd 文件不展示服务器比较与历史入口;pendingEdit 禁止直接 Get Latest 覆盖。
|
||||
@@ -206,6 +226,10 @@ function buildFileItemMenu(target: FileTarget): FileMenuItem[][] {
|
||||
sections.push([
|
||||
{ id: "undo", label: "撤销更改", enabled: true, danger: true },
|
||||
])
|
||||
// pendingAdd 项服务端尚不存在,属性查询无意义。
|
||||
if (!isPendingAdd) {
|
||||
sections.push([{ id: "properties", label: "属性…", enabled: true }])
|
||||
}
|
||||
return sections
|
||||
}
|
||||
|
||||
@@ -256,5 +280,10 @@ function buildFileItemMenu(target: FileTarget): FileMenuItem[][] {
|
||||
]
|
||||
sections.push(workspaceActions)
|
||||
|
||||
// pendingAdd 文件服务端尚不存在,不提供属性与获取特定版本。
|
||||
if (!isPendingAdd) {
|
||||
sections.push(buildAdvancedSection(target))
|
||||
}
|
||||
|
||||
return sections
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user