Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Add template icon to the workspaces page#3612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kylecarbs merged 1 commit intomainfromtemplatewspage
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionscoderd/workspaces.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -891,6 +891,7 @@ func convertWorkspace(
TemplateID: workspace.TemplateID,
LatestBuild: convertWorkspaceBuild(owner, initiator, workspace, workspaceBuild, job),
TemplateName: template.Name,
TemplateIcon: template.Icon,
Outdated: workspaceBuild.TemplateVersionID.String() != template.ActiveVersionID.String(),
Name: workspace.Name,
AutostartSchedule: autostartSchedule,
Expand Down
1 change: 1 addition & 0 deletionscodersdk/workspaces.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@ type Workspace struct {
OwnerName string `json:"owner_name"`
TemplateID uuid.UUID `json:"template_id"`
TemplateName string `json:"template_name"`
TemplateIcon string `json:"template_icon"`
LatestBuild WorkspaceBuild `json:"latest_build"`
Outdated bool `json:"outdated"`
Name string `json:"name"`
Expand Down
1 change: 1 addition & 0 deletionssite/src/api/typesGenerated.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -426,6 +426,7 @@ export interface Workspace {
readonly owner_name: string
readonly template_id: string
readonly template_name: string
readonly template_icon: string
readonly latest_build: WorkspaceBuild
readonly outdated: boolean
readonly name: string
Expand Down
6 changes: 3 additions & 3 deletionssite/src/components/AvatarData/AvatarData.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@ import {

export interface AvatarDataProps {
title: string
subtitle: string
subtitle?: string
highlightTitle?: boolean
link?: string
avatar?: React.ReactNode
Expand All@@ -39,13 +39,13 @@ export const AvatarData: FC<AvatarDataProps> = ({
<Link to={link} underline="none" component={RouterLink}>
<TableCellData>
<TableCellDataPrimary highlight={highlightTitle}>{title}</TableCellDataPrimary>
<TableCellDataSecondary>{subtitle}</TableCellDataSecondary>
{subtitle &&<TableCellDataSecondary>{subtitle}</TableCellDataSecondary>}
</TableCellData>
</Link>
) : (
<TableCellData>
<TableCellDataPrimary highlight={highlightTitle}>{title}</TableCellDataPrimary>
<TableCellDataSecondary>{subtitle}</TableCellDataSecondary>
{subtitle &&<TableCellDataSecondary>{subtitle}</TableCellDataSecondary>}
</TableCellData>
)}
</div>
Expand Down
26 changes: 20 additions & 6 deletionssite/src/components/WorkspacesTable/WorkspacesRow.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,8 +6,6 @@ import { useActor } from "@xstate/react"
import { WorkspaceStatusBadge } from "components/WorkspaceStatusBadge/WorkspaceStatusBadge"
import { FC } from "react"
import { useNavigate } from "react-router-dom"
import { createDayString } from "util/createDayString"
import { getDisplayWorkspaceBuildInitiatedBy } from "util/workspace"
import { WorkspaceItemMachineRef } from "../../xServices/workspaces/workspacesXService"
import { AvatarData } from "../AvatarData/AvatarData"
import {
Expand All@@ -29,8 +27,8 @@ export const WorkspacesRow: FC<{ workspaceRef: WorkspaceItemMachineRef }> = ({ w
const theme: Theme = useTheme()
const [workspaceState, send] = useActor(workspaceRef)
const { data: workspace } = workspaceState.context
const initiatedBy = getDisplayWorkspaceBuildInitiatedBy(workspace.latest_build)
const workspacePageLink = `/@${workspace.owner_name}/${workspace.name}`
const hasTemplateIcon = workspace.template_icon && workspace.template_icon !== ""

return (
<TableRow
Expand All@@ -51,11 +49,17 @@ export const WorkspacesRow: FC<{ workspaceRef: WorkspaceItemMachineRef }> = ({ w
</TableCellData>
</TableCellLink>

<TableCellLink to={workspacePageLink}>{workspace.template_name}</TableCellLink>
<TableCellLink to={workspacePageLink}>
<AvatarData
title={initiatedBy}
subtitle={createDayString(workspace.latest_build.created_at)}
title={workspace.template_name}
highlightTitle={false}
avatar={
hasTemplateIcon ? (
<div className={styles.templateIconWrapper}>
<img alt="" src={workspace.template_icon} />
</div>
) : undefined
}
/>
</TableCellLink>
<TableCellLink to={workspacePageLink}>
Expand DownExpand Up@@ -117,4 +121,14 @@ const useStyles = makeStyles((theme) => ({
color: theme.palette.text.secondary,
fontSize: 12,
},
templateIconWrapper: {
// Same size then the avatar component
width: 36,
height: 36,
padding: 2,

"& img": {
width: "100%",
},
},
}))
7 changes: 3 additions & 4 deletionssite/src/components/WorkspacesTable/WorkspacesTable.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,10 +29,9 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({ isLoading, workspace
<TableHead>
<TableRow>
<TableCell width="25%">{Language.name}</TableCell>
<TableCell width="20%">{Language.template}</TableCell>
<TableCell width="25%">{Language.lastBuiltBy}</TableCell>
<TableCell width="15%">{Language.version}</TableCell>
<TableCell width="15%">{Language.status}</TableCell>
<TableCell width="35%">{Language.template}</TableCell>
<TableCell width="20%">{Language.version}</TableCell>
<TableCell width="20%">{Language.status}</TableCell>
<TableCell width="1%"></TableCell>
</TableRow>
</TableHead>
Expand Down
1 change: 1 addition & 0 deletionssite/src/testHelpers/entities.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,6 +208,7 @@ export const MockWorkspace: TypesGen.Workspace = {
updated_at: "",
template_id: MockTemplate.id,
template_name: MockTemplate.name,
template_icon: MockTemplate.icon,
outdated: false,
owner_id: MockUser.id,
owner_name: MockUser.username,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp