mirror of
https://github.com/langgenius/dify.git
synced 2026-07-21 10:38:32 +08:00
fix(workspace): expose last opened in contract (#38323)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
3f92e38616
commit
ff56fb7e23
@ -102,6 +102,7 @@ class TenantListItemResponse(ResponseModel):
|
||||
plan: str | None = None
|
||||
status: str | None = None
|
||||
created_at: int | None = None
|
||||
last_opened_at: int | None = None
|
||||
current: bool
|
||||
|
||||
@field_validator("plan", "status", mode="before")
|
||||
@ -113,9 +114,9 @@ class TenantListItemResponse(ResponseModel):
|
||||
return value
|
||||
return str(getattr(value, "value", value))
|
||||
|
||||
@field_validator("created_at", mode="before")
|
||||
@field_validator("created_at", "last_opened_at", mode="before")
|
||||
@classmethod
|
||||
def _normalize_created_at(cls, value: datetime | int | None):
|
||||
def _normalize_timestamp(cls, value: datetime | int | None):
|
||||
return to_timestamp(value)
|
||||
|
||||
|
||||
|
||||
@ -21199,6 +21199,7 @@ Tag type
|
||||
| created_at | integer | | No |
|
||||
| current | boolean | | Yes |
|
||||
| id | string | | Yes |
|
||||
| last_opened_at | integer | | No |
|
||||
| name | string | | No |
|
||||
| plan | string | | No |
|
||||
| status | string | | No |
|
||||
|
||||
@ -939,6 +939,7 @@ export type TenantListItemResponse = {
|
||||
created_at?: number | null
|
||||
current: boolean
|
||||
id: string
|
||||
last_opened_at?: number | null
|
||||
name?: string | null
|
||||
plan?: string | null
|
||||
status?: string | null
|
||||
|
||||
@ -684,6 +684,7 @@ export const zTenantListItemResponse = z.object({
|
||||
created_at: z.int().nullish(),
|
||||
current: z.boolean(),
|
||||
id: z.string(),
|
||||
last_opened_at: z.int().nullish(),
|
||||
name: z.string().nullish(),
|
||||
plan: z.string().nullish(),
|
||||
status: z.string().nullish(),
|
||||
|
||||
@ -21,13 +21,10 @@ const workspaceSwitchActionIconClassName = 'size-3.5 shrink-0'
|
||||
const workspaceSwitchListClassName = 'max-h-[240px] overflow-y-auto overscroll-contain scroll-py-1'
|
||||
const workspaceSwitchI18nKey = (key: string) => key as 'mainNav.workspace.settings'
|
||||
type WorkspaceSort = 'lastOpened' | 'createdAt'
|
||||
type WorkspaceListItem = TenantListItemResponse & {
|
||||
last_opened_at?: number | null
|
||||
}
|
||||
|
||||
const getWorkspaceName = (workspace: WorkspaceListItem) => workspace.name || workspace.id
|
||||
const getWorkspaceCreatedAt = (workspace: WorkspaceListItem) => workspace.created_at ?? 0
|
||||
const getWorkspaceLastOpenedAt = (workspace: WorkspaceListItem) => workspace.last_opened_at ?? 0
|
||||
const getWorkspaceName = (workspace: TenantListItemResponse) => workspace.name || workspace.id
|
||||
const getWorkspaceCreatedAt = (workspace: TenantListItemResponse) => workspace.created_at ?? 0
|
||||
const getWorkspaceLastOpenedAt = (workspace: TenantListItemResponse) => workspace.last_opened_at ?? 0
|
||||
|
||||
function WorkspaceSwitchControls({
|
||||
searchText,
|
||||
@ -123,7 +120,7 @@ function WorkspaceSwitchControls({
|
||||
}
|
||||
|
||||
type WorkspaceSwitcherProps = {
|
||||
workspaces: WorkspaceListItem[]
|
||||
workspaces: TenantListItemResponse[]
|
||||
onSwitchWorkspace: (workspaceId: string) => void
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user