Skip to content

In product changelog #381

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

Merged
merged 1 commit into from
Jul 21, 2022
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
4 changes: 3 additions & 1 deletion extensions/gitpod-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"prepare": "node scripts/inflate.js"
},
"devDependencies": {
"@types/js-yaml": "^4.0.5",
"@types/node": "16.x",
"@types/uuid": "^8.3.1",
"@types/ws": "^7.2.6"
Expand All @@ -20,8 +21,9 @@
"@gitpod/gitpod-protocol": "main",
"@gitpod/supervisor-api-grpc": "main",
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2",
"js-yaml": "^4.1.0",
"reconnecting-websocket": "^4.4.0",
"utf-8-validate": "^5.0.2",
"uuid": "^8.3.1",
"vscode-nls": "^5.0.0",
"ws": "^7.4.6",
Expand Down
11 changes: 11 additions & 0 deletions extensions/gitpod-shared/scripts/inflate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const nls = {
'openSettings': 'Gitpod: Open Settings',
'openContext': 'Gitpod: Open Context',
'openDocumentation': 'Gitpod: Documentation',
'showReleaseNotes': 'Gitpod: Show Release Notes',
'openDiscord': 'Gitpod: Open Community Chat',
'openTwitter': 'Gitpod: Follow us on Twitter',
'reportIssue': 'Gitpod: Report Issue',
Expand Down Expand Up @@ -72,6 +73,11 @@ const commands = [
'title': '%reportIssue%',
'enablement': 'gitpod.inWorkspace == true'
},
{
'command': 'gitpod.showReleaseNotes',
'title': '%showReleaseNotes%',
'enablement': 'gitpod.inWorkspace == true'
},
{
'command': 'gitpod.upgradeSubscription',
'title': '%upgradeSubscription%',
Expand Down Expand Up @@ -160,6 +166,11 @@ const remoteMenus = [
'group': 'remote_00_gitpod_navigation@90',
'when': 'gitpod.inWorkspace == true'
},
{
'command': 'gitpod.showReleaseNotes',
'group': 'remote_00_gitpod_navigation@70',
'when': 'gitpod.inWorkspace == true'
},
{
'command': 'gitpod.upgradeSubscription',
'group': 'remote_00_gitpod_navigation@100',
Expand Down
52 changes: 52 additions & 0 deletions extensions/gitpod-shared/src/common/cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Gitpod. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';

const CACHE_KEY = 'gitpod.cache';

interface CacheObject {
value: any;
expiration?: number;
}

interface CacheMap { [key: string]: CacheObject }

export class CacheHelper {
constructor(private readonly context: vscode.ExtensionContext) { }

set(key: string, value: any, expiration?: number) {
let obj = this.context.globalState.get<CacheMap>(CACHE_KEY);
if (!obj) {
obj = {};
}
const exp = expiration ? (Date.now() / 1000 + expiration) : undefined;
obj[key] = { value, expiration: exp };
return this.context.globalState.update(CACHE_KEY, obj);
}

get<T>(key: string): T | undefined {
const value = this.context.globalState.get<CacheMap>(CACHE_KEY);
if (!value || !value[key]) {
return undefined;
}
const data = value[key];
if (!data.expiration) {
return data.value;
}
const now = Date.now() / 1000;
return now > data.expiration ? undefined : data.value;
}

async getOrRefresh<T>(key: string, refreshCallback: () => Thenable<{ value: T; ttl?: number }>): Promise<T> {
let value = this.get<T>(key);
if (value === undefined) {
const result = await refreshCallback();
await this.set(key, result.value, result.ttl);
value = result.value;
}
return value;
}
}
1 change: 1 addition & 0 deletions extensions/gitpod-shared/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as vscode from 'vscode';
import { registerActiveLanguageAnalytics, registerUsageAnalytics } from './analytics';
import { createGitpodExtensionContext, GitpodExtensionContext, registerDefaultLayout, registerNotifications, registerWorkspaceCommands, registerWorkspaceSharing, registerWorkspaceTimeout } from './features';

export { registerReleaseNotesView } from './releaseNote';
export { GitpodExtensionContext, registerTasks, SupervisorConnection, registerIpcHookCli } from './features';
export * from './gitpod-plugin-model';

Expand Down
Loading