Skip to content

Commit c6b7ef4

Browse files
committed
[dashboard] pop up directly goes to examples
... when there are no recent projects
1 parent 9865982 commit c6b7ef4

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

components/dashboard/src/workspaces/StartWorkspaceModal.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See License-AGPL.txt in the project root for license information.
55
*/
66

7-
import { useState } from "react";
7+
import { useEffect, useState } from "react";
88
import Modal from "../components/Modal";
99

1010
export interface WsStartEntry {
@@ -30,7 +30,9 @@ function Tab(p: { name: Mode, selection: Mode, setSelection: (selection: Mode) =
3030
}
3131

3232
export function StartWorkspaceModal(p: StartWorkspaceModalProps) {
33-
const [selection, setSelection] = useState(p.selected || 'Recent');
33+
const computeSelection = () => p.selected || (p.recent.length > 0 ? 'Recent' : 'Examples');
34+
const [selection, setSelection] = useState(computeSelection());
35+
useEffect(() => setSelection(computeSelection()), [p.recent, p.selected]);
3436

3537
const list = (selection === 'Recent' ? p.recent : p.examples).map(e =>
3638
<a key={e.title} href={e.startUrl} className="rounded-xl group hover:bg-gray-100 flex p-4 my-1">
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
7+
import {MigrationInterface, QueryRunner} from "typeorm";
8+
9+
export class UpdateExamples1616920059049 implements MigrationInterface {
10+
11+
public async up(queryRunner: QueryRunner): Promise<any> {
12+
const newEntries = [
13+
{ url: 'https://github.com/gitpod-io/sveltejs-template', description: 'A project template for Svelte applications', priority: 90 },
14+
{ url: 'https://github.com/gitpod-io/spring-petclinic', description: 'A Spring sample web application', priority: 70 },
15+
{ url: 'https://github.com/breatheco-de/python-flask-api-tutorial', description: 'An interactive tutorial about Python Flask', priority: 40 },
16+
{ url: 'https://github.com/gitpod-io/ruby-on-rails', description: 'A Rails example with PostgreSQL database', priority: 30 },
17+
{ url: 'https://github.com/gitpod-io/dotnetcore', description: 'A simple .NET Core application example', priority: 20 },
18+
{ url: 'https://github.com/symfony/demo', description: 'A Symfony demo application', priority: 10 },
19+
]
20+
// delete old entries
21+
await queryRunner.query("DELETE FROM d_b_repository_white_list");
22+
const insert = `INSERT IGNORE INTO d_b_repository_white_list (url, description, priority) VALUES ${newEntries.map(e=>'(?, ?, ?)').join(', ')}`;
23+
const values: any[] = [];
24+
for (const e of newEntries) {
25+
values.push(e.url, e.description, e.priority);
26+
}
27+
await queryRunner.query(insert, values);
28+
}
29+
30+
public async down(queryRunner: QueryRunner): Promise<any> {
31+
}
32+
33+
}

0 commit comments

Comments
 (0)