Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dashboard] Add more actions to workspace ready page #6847

Merged
merged 2 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions components/dashboard/src/components/Arrow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/

function Arrow(props: { up: boolean }) {
return <span className="mx-2 border-gray-400 dark:border-gray-600 group-hover:border-gray-600 dark:group-hover:border-gray-400" style={{ marginTop: 2, marginBottom: 2, padding: 3, borderWidth: '0 2px 2px 0', display: 'inline-block', transform: `rotate(${props.up ? '-135deg' : '45deg'})` }}></span>
}

export default Arrow;
7 changes: 4 additions & 3 deletions components/dashboard/src/components/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See License-AGPL.txt in the project root for license information.
*/

import React from 'react';
import React, { HTMLAttributeAnchorTarget } from 'react';
import { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';

Expand All @@ -26,6 +26,7 @@ export interface ContextMenuEntry {
onClick?: (event: React.MouseEvent) => void;
href?: string;
link?: string;
target?: HTMLAttributeAnchorTarget;
}

function ContextMenu(props: ContextMenuProps) {
Expand Down Expand Up @@ -91,11 +92,11 @@ function ContextMenu(props: ContextMenuProps) {
</div>
const key = `entry-${menuId}-${index}-${e.title}`;
if (e.link) {
return <Link key={key} to={e.link} onClick={e.onClick}>
return <Link key={key} to={e.link} onClick={e.onClick} target={e.target}>
{entry}
</Link>;
} else if (e.href) {
return <a key={key} href={e.href} onClick={e.onClick}>
return <a key={key} href={e.href} onClick={e.onClick} target={e.target}>
{entry}
</a>;
} else {
Expand Down
5 changes: 1 addition & 4 deletions components/dashboard/src/components/DropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { useEffect, useState } from 'react';
import Arrow from './Arrow';
import ContextMenu from './ContextMenu';

export interface DropDownProps {
Expand All @@ -19,10 +20,6 @@ export interface DropDownEntry {
onClick: ()=>void
}

function Arrow(props: {up: boolean}) {
return <span className="mx-2 border-gray-400 dark:border-gray-600 group-hover:border-gray-600 dark:group-hover:border-gray-400" style={{ marginTop: 2, marginBottom: 2, padding: 3, borderWidth: '0 2px 2px 0', display: 'inline-block', transform: `rotate(${props.up ? '-135deg' : '45deg'})`}}></span>
}

function DropDown(props: DropDownProps) {
const [current, setCurrent] = useState(props.activeEntry || props.entries[0].title);
useEffect(() => {
Expand Down
31 changes: 25 additions & 6 deletions components/dashboard/src/start/StartWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
* See License-AGPL.txt in the project root for license information.
*/

import EventEmitter from "events";
import React, { useEffect, Suspense } from "react";
import { DisposableCollection, WorkspaceInstance, WorkspaceImageBuild, Workspace, WithPrebuild, ContextURL } from "@gitpod/gitpod-protocol";
import { ContextURL, DisposableCollection, WithPrebuild, Workspace, WorkspaceImageBuild, WorkspaceInstance } from "@gitpod/gitpod-protocol";
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
import EventEmitter from "events";
import React, { Suspense, useEffect } from "react";
import { v4 } from 'uuid';
import Arrow from "../components/Arrow";
import ContextMenu from "../components/ContextMenu";
import PendingChangesDropdown from "../components/PendingChangesDropdown";
import { watchHeadlessLogs } from "../components/PrebuildLogs";
import { getGitpodService, gitpodHostUrl } from "../service/service";
import { StartPage, StartPhase, StartWorkspaceError } from "./StartPage";
import { watchHeadlessLogs } from "../components/PrebuildLogs";
import { v4 } from 'uuid';
const sessionId = v4();

const WorkspaceLogs = React.lazy(() => import('../components/WorkspaceLogs'));
Expand Down Expand Up @@ -291,9 +293,26 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
</div>
</div>
<div className="mt-10 justify-center flex space-x-2">
<button className="secondary" onClick={() => window.parent.postMessage({ type: 'openBrowserIde' }, '*')}>Open VS Code in Browser</button>
<ContextMenu menuEntries={[
{
title: 'Open in Browser',
onClick: () => window.parent.postMessage({ type: 'openBrowserIde' }, '*'),
},
{
title: 'Stop Workspace',
onClick: () => getGitpodService().server.stopWorkspace(this.props.workspaceId),
},
{
title: 'Go to Dashboard',
href: gitpodHostUrl.asDashboard().toString(),
target: "_parent",
},
]} >
<button className="secondary">More Actions...<Arrow up={false} /></button>
</ContextMenu>
<a target="_blank" href={this.state.desktopIde.link}><button>{this.state.desktopIde.label}</button></a>
</div>
<div className="text-sm text-gray-400 dark:text-gray-500 mt-5">These IDE options are based on <a className="gp-link" href={gitpodHostUrl.asPreferences().toString()} target="_parent">your user preferences</a>.</div>
</div>;
}

Expand Down
4 changes: 4 additions & 0 deletions components/gitpod-protocol/src/util/gitpod-host-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export class GitpodHostUrl {
return this.with(url => ({ pathname: '/settings' }));
}

asPreferences(): GitpodHostUrl {
return this.with(url => ({ pathname: '/preferences' }));
}

asGraphQLApi(): GitpodHostUrl {
return this.with(url => ({ pathname: '/graphql/' }));
}
Expand Down