-
Notifications
You must be signed in to change notification settings - Fork 1
allow user customize workspace timeout #2
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,7 +239,7 @@ export async function registerWorkspaceCommands(context: GitpodExtensionContext) | |
return context.gitpod.server.stopWorkspace(context.info.workspaceId); | ||
})); | ||
context.subscriptions.push(vscode.commands.registerCommand('gitpod.upgradeSubscription', () => { | ||
const url = new GitpodHostUrl(context.info.gitpodHost).asUpgradeSubscription().toString(); | ||
const url = new GitpodHostUrl(context.info.gitpodHost).asBilling().toString(); | ||
context.fireAnalyticsEvent({ | ||
eventName: 'vscode_execute_command_gitpod_open_link', | ||
properties: { url } | ||
|
@@ -387,36 +387,57 @@ export async function registerWorkspaceTimeout(context: GitpodExtensionContext): | |
} | ||
}); | ||
try { | ||
const result = await context.gitpod.server.setWorkspaceTimeout(context.info.workspaceId, '180m'); | ||
if (result.resetTimeoutOnWorkspaces?.length > 0) { | ||
vscode.window.showWarningMessage('Workspace timeout has been extended to three hours. This reset the workspace timeout for other workspaces.'); | ||
} else { | ||
vscode.window.showInformationMessage('Workspace timeout has been extended to three hours.'); | ||
} | ||
await context.gitpod.server.setWorkspaceTimeout(context.info.workspaceId, '180m'); | ||
vscode.window.showWarningMessage(`Workspace timeout has been extended to 180m.`); | ||
} catch (err) { | ||
vscode.window.showErrorMessage(`Cannot extend workspace timeout: ${err.toString()}`); | ||
} | ||
})); | ||
|
||
|
||
context.subscriptions.push(vscode.commands.registerCommand('gitpod.setWorkspaceTimeout', async () => { | ||
const timeout = await vscode.window.showInputBox({ | ||
value: '180m', | ||
prompt: 'Please input the timeout time, such as 30m, 1h, 2h, 3h', | ||
}); | ||
if (!timeout) { | ||
return; | ||
} | ||
context.fireAnalyticsEvent({ | ||
eventName: 'vscode_execute_command_gitpod_workspace', | ||
properties: { | ||
action: 'configure-timeout' | ||
} | ||
}); | ||
try { | ||
const { humanReadableDuration } = await context.gitpod.server.setWorkspaceTimeout(context.info.workspaceId, timeout); | ||
vscode.window.showWarningMessage(`Workspace timeout has been changed to ${humanReadableDuration ?? timeout}.`); | ||
} catch (err) { | ||
vscode.window.showErrorMessage(`Cannot configure workspace timeout: ${err.toString()}`); | ||
} | ||
})); | ||
|
||
const workspaceTimeout = await context.gitpod.server.getWorkspaceTimeout(context.info.workspaceId); | ||
if (!workspaceTimeout.canChange) { | ||
return; | ||
} | ||
|
||
const listener = await context.instanceListener; | ||
const extendTimeoutStatusBarItem = vscode.window.createStatusBarItem('gitpod.extendTimeout', vscode.StatusBarAlignment.Right, -100); | ||
extendTimeoutStatusBarItem.name = 'Click to extend the workspace timeout.'; | ||
extendTimeoutStatusBarItem.name = 'Extend the workspace timeout.'; | ||
context.subscriptions.push(extendTimeoutStatusBarItem); | ||
extendTimeoutStatusBarItem.text = '$(watch)'; | ||
extendTimeoutStatusBarItem.command = 'gitpod.ExtendTimeout'; | ||
extendTimeoutStatusBarItem.command = 'gitpod.setWorkspaceTimeout'; | ||
const update = () => { | ||
const instance = listener.info.latestInstance; | ||
if (!instance) { | ||
extendTimeoutStatusBarItem.hide(); | ||
return; | ||
} | ||
extendTimeoutStatusBarItem.tooltip = `Workspace Timeout: ${instance.status.timeout}. Click to extend.`; | ||
extendTimeoutStatusBarItem.color = instance.status.timeout === '180m' ? new vscode.ThemeColor('notificationsWarningIcon.foreground') : undefined; | ||
|
||
// TODO: query default timeout, currently all paid plan default timeout is 60m. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously this icon was highlighted if the workspace timeout was extended to 180 minutes, but now that this condition has been changed with the ability to customize the timeout, how should we handle this highlighting logic? And in the feature if the user already customizes workspace timeout time, it will also disable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Interesting question. We can document this, but I don't think there's much we can do help the user in the product? Could we add it to the copy from the confirmation toast modal? 💭 |
||
extendTimeoutStatusBarItem.color = instance.status.timeout !== '60m' ? new vscode.ThemeColor('notificationsWarningIcon.foreground') : undefined; | ||
extendTimeoutStatusBarItem.show(); | ||
}; | ||
update(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,9 @@ | |
|
||
|
||
"@gitpod/gitpod-protocol@main": | ||
version "0.1.5-main.6379" | ||
resolved "https://registry.yarnpkg.com/@gitpod/gitpod-protocol/-/gitpod-protocol-0.1.5-main.6379.tgz#8c654e9d1658a62648ec4a1bc837f3d5756f8a14" | ||
integrity sha512-QLScSNODhMle/w23HSr3RihIh7S+ZE46JRbOqbFgR9+a0FBoxPtHi6kqUmeNgqvt+hfyjgdPG5/yddU7j0uznA== | ||
version "0.1.5-main.6559" | ||
resolved "https://registry.yarnpkg.com/@gitpod/gitpod-protocol/-/gitpod-protocol-0.1.5-main.6559.tgz#e771beee25447b12dce79fea4abad4caed8db9fc" | ||
integrity sha512-v6E5AnpiTkWEBhyuBT8/gXVYzSKHUK1IUoa9CCr3q5jsdgG0egGzotcsu1OTmDZ68R1UKCvu4RddQZgU5ZGTjg== | ||
dependencies: | ||
"@types/react" "17.0.32" | ||
abort-controller-x "^0.4.0" | ||
|
@@ -589,9 +589,9 @@ [email protected]: | |
safe-buffer "5.2.1" | ||
|
||
content-type@~1.0.4: | ||
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" | ||
integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== | ||
version "1.0.5" | ||
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918" | ||
integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA== | ||
|
||
[email protected]: | ||
version "1.0.6" | ||
|
@@ -1222,7 +1222,12 @@ minimatch@^3.0.4, minimatch@^3.1.1: | |
dependencies: | ||
brace-expansion "^1.1.7" | ||
|
||
minimist@^1.1.0, minimist@^1.2.0, minimist@^1.2.6: | ||
minimist@^1.1.0: | ||
version "1.2.8" | ||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" | ||
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== | ||
|
||
minimist@^1.2.0, minimist@^1.2.6: | ||
version "1.2.7" | ||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18" | ||
integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g== | ||
|
Uh oh!
There was an error while loading. Please reload this page.