-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from yannick-beot-sp/feature/read-only
⭐ Lock tenant as read-only to prevent any change (cf. #75)
- Loading branch information
Showing
24 changed files
with
168 additions
and
35 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
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
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
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 { TenantTreeItem } from "../../models/ISCTreeItem"; | ||
import * as vscode from 'vscode'; | ||
import * as commands from '../constants'; | ||
import { TenantService } from "../../services/TenantService"; | ||
|
||
export class TenantReadOnlyConfigCommand { | ||
|
||
constructor(private readonly tenantService: TenantService) { | ||
|
||
} | ||
|
||
public async setReadOnly(node: TenantTreeItem): Promise<void> { | ||
console.log("> TenantReadOnlyConfigCommand.setReadOnly", node); | ||
await this.updateReadonly(node, true) | ||
} | ||
|
||
public async setWritable(node: TenantTreeItem): Promise<void> { | ||
console.log("> TenantReadOnlyConfigCommand.setWritable", node); | ||
await this.updateReadonly(node, false) | ||
} | ||
|
||
private async updateReadonly(node: TenantTreeItem, readOnly: boolean): Promise<void> { | ||
const tenantInfo = this.tenantService.getTenant(node.tenantId) | ||
tenantInfo.readOnly = readOnly | ||
this.tenantService.setTenant(tenantInfo) | ||
|
||
// force refresh to update icon | ||
await vscode.commands.executeCommand(commands.REFRESH_FORCED); | ||
|
||
const uris = vscode.window.tabGroups?.all?. | ||
flatMap(tabGroup => tabGroup.tabs)?. | ||
map(tab => tab.input). | ||
map(input => typeof input === 'object' && input !== null && 'uri' in input ? input.uri : undefined) | ||
.filter(Boolean) | ||
.filter((uri: vscode.Uri) => uri.authority === tenantInfo.tenantName) | ||
console.log(uris); | ||
|
||
if (uris && uris.length > 0) { | ||
await vscode.commands.executeCommand(commands.MODIFIED_RESOURCE, uris); | ||
} | ||
|
||
} | ||
} |
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
Oops, something went wrong.