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: display user apps in the workspaces table#17744

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
BrunoQuaresma merged 3 commits intomainfrombq/display-user-apps
May 9, 2025
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
37 changes: 37 additions & 0 deletionssite/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,7 @@ import {
MockTemplate,
MockUserOwner,
MockWorkspace,
MockWorkspaceAgent,
MockWorkspaceAppStatus,
mockApiError,
} from "testHelpers/entities";
Expand DownExpand Up@@ -299,6 +300,42 @@ export const InvalidPageNumber: Story = {
},
};

export const MultipleApps: Story = {
args: {
workspaces: [
{
...MockWorkspace,
latest_build: {
...MockWorkspace.latest_build,
resources: [
{
...MockWorkspace.latest_build.resources[0],
agents: [
{
...MockWorkspaceAgent,
apps: [
{
...MockWorkspaceAgent.apps[0],
display_name: "App 1",
id: "app-1",
},
{
...MockWorkspaceAgent.apps[0],
display_name: "App 2",
id: "app-2",
},
],
},
],
},
],
},
},
],
count: allWorkspaces.length,
},
};

export const ShowOrganizations: Story = {
args: {
workspaces: [{ ...MockWorkspace, organization_name: "limbus-co" }],
Expand Down
69 changes: 58 additions & 11 deletionssite/src/pages/WorkspacesPage/WorkspacesTable.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ import { Avatar } from "components/Avatar/Avatar";
import { AvatarData } from "components/Avatar/AvatarData";
import { AvatarDataSkeleton } from "components/Avatar/AvatarDataSkeleton";
import { Button } from "components/Button/Button";
import { ExternalImage } from "components/ExternalImage/ExternalImage";
import { VSCodeIcon } from "components/Icons/VSCodeIcon";
import { VSCodeInsidersIcon } from "components/Icons/VSCodeInsidersIcon";
import { InfoTooltip } from "components/InfoTooltip/InfoTooltip";
Expand DownExpand Up@@ -63,6 +64,7 @@ import {
getVSCodeHref,
openAppInNewWindow,
} from "modules/apps/apps";
import { useAppLink } from "modules/apps/useAppLink";
import { useDashboard } from "modules/dashboard/useDashboard";
import { WorkspaceAppStatus } from "modules/workspaces/WorkspaceAppStatus/WorkspaceAppStatus";
import { WorkspaceDormantBadge } from "modules/workspaces/WorkspaceDormantBadge/WorkspaceDormantBadge";
Expand DownExpand Up@@ -622,6 +624,9 @@ const PrimaryAction: FC<PrimaryActionProps> = ({
);
};

// The total number of apps that can be displayed in the workspace row
const WORKSPACE_APPS_SLOTS = 4;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

perhaps create a storybook to express this use case?


type WorkspaceAppsProps = {
workspace: Workspace;
};
Expand All@@ -647,11 +652,18 @@ const WorkspaceApps: FC<WorkspaceAppsProps> = ({ workspace }) => {
return null;
}

const builtinApps = new Set(agent.display_apps);
builtinApps.delete("port_forwarding_helper");
builtinApps.delete("ssh_helper");

const remainingSlots = WORKSPACE_APPS_SLOTS - builtinApps.size;
const userApps = agent.apps.slice(0, remainingSlots);

const buttons: ReactNode[] = [];

if (agent.display_apps.includes("vscode")) {
if (builtinApps.has("vscode")) {
buttons.push(
<AppLink
<BaseIconLink
key="vscode"
isLoading={!token}
label="Open VSCode"
Expand All@@ -664,13 +676,13 @@ const WorkspaceApps: FC<WorkspaceAppsProps> = ({ workspace }) => {
})}
>
<VSCodeIcon />
</AppLink>,
</BaseIconLink>,
);
}

if (agent.display_apps.includes("vscode_insiders")) {
if (builtinApps.has("vscode_insiders")) {
buttons.push(
<AppLink
<BaseIconLink
key="vscode-insiders"
label="Open VSCode Insiders"
isLoading={!token}
Expand All@@ -683,18 +695,29 @@ const WorkspaceApps: FC<WorkspaceAppsProps> = ({ workspace }) => {
})}
>
<VSCodeInsidersIcon />
</AppLink>,
</BaseIconLink>,
);
}

if (agent.display_apps.includes("web_terminal")) {
for (const app of userApps) {
buttons.push(
<IconAppLink
key={app.id}
app={app}
workspace={workspace}
agent={agent}
/>,
);
}

if (builtinApps.has("web_terminal")) {
const href = getTerminalHref({
username: workspace.owner_name,
workspace: workspace.name,
agent: agent.name,
});
buttons.push(
<AppLink
<BaseIconLink
key="terminal"
href={href}
onClick={(e) => {
Expand All@@ -704,21 +727,45 @@ const WorkspaceApps: FC<WorkspaceAppsProps> = ({ workspace }) => {
label="Open Terminal"
>
<SquareTerminalIcon />
</AppLink>,
</BaseIconLink>,
);
}

return buttons;
};

type AppLinkProps = PropsWithChildren<{
type IconAppLinkProps = {
app: WorkspaceApp;
workspace: Workspace;
agent: WorkspaceAgent;
};

const IconAppLink: FC<IconAppLinkProps> = ({ app, workspace, agent }) => {
const link = useAppLink(app, {
workspace,
agent,
});

return (
<BaseIconLink
key={app.id}
label={`Open ${link.label}`}
href={link.href}
onClick={link.onClick}
>
<ExternalImage src={app.icon ?? "/icon/widgets.svg"} />
</BaseIconLink>
);
};

type BaseIconLinkProps = PropsWithChildren<{
label: string;
href: string;
isLoading?: boolean;
onClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void;
}>;

constAppLink: FC<AppLinkProps> = ({
constBaseIconLink: FC<BaseIconLinkProps> = ({
href,
isLoading,
label,
Expand Down
7 changes: 0 additions & 7 deletionssite/src/testHelpers/entities.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -896,17 +896,10 @@ export const MockWorkspaceApp: TypesGen.WorkspaceApp = {
id: "test-app",
slug: "test-app",
display_name: "Test App",
icon: "",
subdomain: false,
health: "disabled",
external: false,
url: "",
sharing_level: "owner",
healthcheck: {
url: "",
interval: 0,
threshold: 0,
},
hidden: false,
open_in: "slim-window",
statuses: [],
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp