-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
TikouWeb
committed
Aug 1, 2024
1 parent
663e62b
commit 312b37b
Showing
6 changed files
with
107 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import vscode from "vscode"; | ||
import { OPEN_DASHBOARD_WEBVIEW_PANEL_COMMAND } from "./constants"; | ||
|
||
type State = { | ||
configName?: string; | ||
}; | ||
|
||
type GcpConfigurationStatusBar = { | ||
create: ({ configName }?: State) => vscode.StatusBarItem; | ||
update: ({ configName }?: State) => void; | ||
show: () => void; | ||
hide: () => void; | ||
setPending: (pending?: boolean) => void; | ||
}; | ||
|
||
const gcpConfigurationStatusBarManager = () => { | ||
let statusBarItem: vscode.StatusBarItem; | ||
const state: State = { | ||
configName: "", | ||
}; | ||
|
||
const text = () => `$(cloud) | $(check)${state.configName}`.slice(0, 15); | ||
const tooltip = () => `Open GCP Config Switch \n Active: ${state.configName}`; | ||
const pendingText = () => `$(cloud) | $(sync~spin) Switching...`; | ||
|
||
const gcpConfigurationStatusBarItem: GcpConfigurationStatusBar = { | ||
create: ({ configName } = {}) => { | ||
state.configName = configName; | ||
|
||
statusBarItem = vscode.window.createStatusBarItem( | ||
vscode.StatusBarAlignment.Left, | ||
0 | ||
); | ||
statusBarItem.command = OPEN_DASHBOARD_WEBVIEW_PANEL_COMMAND; | ||
statusBarItem.text = text(); | ||
statusBarItem.tooltip = tooltip(); | ||
gcpConfigurationStatusBarItem.show(); | ||
return statusBarItem; | ||
}, | ||
show: () => { | ||
statusBarItem.show(); | ||
}, | ||
update: ({ configName } = {}) => { | ||
state.configName = configName; | ||
|
||
statusBarItem.text = text(); | ||
statusBarItem.tooltip = tooltip(); | ||
}, | ||
hide: () => { | ||
statusBarItem.hide(); | ||
}, | ||
setPending: (pending = true) => { | ||
if (pending) { | ||
statusBarItem.text = pendingText(); | ||
return; | ||
} | ||
|
||
statusBarItem.text = text(); | ||
}, | ||
}; | ||
|
||
return gcpConfigurationStatusBarItem; | ||
}; | ||
|
||
export const gcpConfigurationStatusBarItem = gcpConfigurationStatusBarManager(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters