|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +import * as vscode from 'vscode'; |
| 7 | + |
| 8 | +/** |
| 9 | + * Opens a webview panel to display a message for an empty commit. |
| 10 | + * The message is centered and styled similar to GitHub.com. |
| 11 | + */ |
| 12 | +export function showEmptyCommitWebview(extensionUri: vscode.Uri, commitSha: string): void { |
| 13 | + const panel = vscode.window.createWebviewPanel( |
| 14 | + 'emptyCommit', |
| 15 | + vscode.l10n.t('Commit {0}', commitSha.substring(0, 7)), |
| 16 | + vscode.ViewColumn.Active, |
| 17 | + { |
| 18 | + enableScripts: false, |
| 19 | + localResourceRoots: [] |
| 20 | + } |
| 21 | + ); |
| 22 | + |
| 23 | + panel.iconPath = { |
| 24 | + light: vscode.Uri.joinPath(extensionUri, 'resources', 'icons', 'codicons', 'git-commit.svg'), |
| 25 | + dark: vscode.Uri.joinPath(extensionUri, 'resources', 'icons', 'codicons', 'git-commit.svg') |
| 26 | + }; |
| 27 | + |
| 28 | + panel.webview.html = getEmptyCommitHtml(); |
| 29 | +} |
| 30 | + |
| 31 | +function getEmptyCommitHtml(): string { |
| 32 | + return `<!DOCTYPE html> |
| 33 | +<html lang="en"> |
| 34 | +<head> |
| 35 | + <meta charset="UTF-8"> |
| 36 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 37 | + <title>Empty Commit</title> |
| 38 | + <style> |
| 39 | + body { |
| 40 | + margin: 0; |
| 41 | + padding: 0; |
| 42 | + height: 100vh; |
| 43 | + display: flex; |
| 44 | + align-items: center; |
| 45 | + justify-content: center; |
| 46 | + } |
| 47 | + .container { |
| 48 | + text-align: center; |
| 49 | + padding: 2rem; |
| 50 | + max-width: 600px; |
| 51 | + } |
| 52 | + .icon { |
| 53 | + margin-bottom: 1.5rem; |
| 54 | + opacity: 0.6; |
| 55 | + } |
| 56 | + .icon svg { |
| 57 | + width: 64px; |
| 58 | + height: 64px; |
| 59 | + fill: currentColor; |
| 60 | + } |
| 61 | + .title { |
| 62 | + font-size: 1.25rem; |
| 63 | + font-weight: 400; |
| 64 | + margin-bottom: 0.5rem; |
| 65 | + color: var(--vscode-foreground); |
| 66 | + } |
| 67 | + .subtitle { |
| 68 | + font-size: 0.95rem; |
| 69 | + color: var(--vscode-descriptionForeground); |
| 70 | + } |
| 71 | + </style> |
| 72 | +</head> |
| 73 | +<body> |
| 74 | + <div class="container"> |
| 75 | + <div class="icon"> |
| 76 | + <svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M9.99994 11.999H4.99994V10.999H9.99994V11.999Z"/><path d="M7.99994 5.99902H9.99994V6.99902H7.99994V9H6.99994V6.99902H4.99994V5.99902H6.99994V4H7.99994V5.99902Z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M10.7099 1.28906L13.7099 4.28906L13.9999 4.99902V13.999L12.9999 14.999H2.99994L1.99994 13.999V1.99902L2.99994 0.999023H9.99994L10.7099 1.28906ZM2.99994 13.999H12.9999V4.99902L9.99994 1.99902H2.99994V13.999Z"/></svg> |
| 77 | + </div> |
| 78 | + <div class="title">No changes to show.</div> |
| 79 | + <div class="subtitle">This commit has no content.</div> |
| 80 | + </div> |
| 81 | +</body> |
| 82 | +</html>`; |
| 83 | +} |
0 commit comments