-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new policy view with login/add config CTA
This will show a prompt to login or add a local configuration if none is present. If a configuration is present and/or the user is logged in, it will show the applied configuration.
- Loading branch information
Showing
5 changed files
with
75 additions
and
6 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
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,43 @@ | ||
import * as vscode from "vscode"; | ||
import type { Environment } from "../env"; | ||
|
||
export class SemgrepPolicyViewProvider | ||
implements vscode.TreeDataProvider<PolicyItem> | ||
{ | ||
public static readonly viewType = "semgrep.view.policy"; | ||
|
||
// [ + add more? ] | ||
// root | ||
// \ connect to org (log in) OR <ORG NAME>'s policy | ||
constructor( | ||
private readonly extensionUri: vscode.Uri, | ||
private readonly env: Environment, | ||
) { | ||
env.loginEvent = this._onDidChangeTreeData; | ||
} | ||
|
||
getTreeItem(element: PolicyItem): PolicyItem { | ||
return element; | ||
} | ||
|
||
getChildren( | ||
element?: PolicyItem | undefined, | ||
): vscode.ProviderResult<PolicyItem[]> { | ||
if (!element) { | ||
if (this.env.loggedIn) { | ||
const login_status = new PolicyItem("Using your organization's policy"); | ||
login_status.iconPath = new vscode.ThemeIcon("cloud-download"); | ||
return [login_status]; | ||
} | ||
return []; | ||
} | ||
return []; | ||
} | ||
|
||
private _onDidChangeTreeData: vscode.EventEmitter<void> = | ||
new vscode.EventEmitter<void>(); | ||
readonly onDidChangeTreeData: vscode.Event<void> = | ||
this._onDidChangeTreeData.event; | ||
} | ||
|
||
class PolicyItem extends vscode.TreeItem {} |