Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/lib/policies/booleanPolicy.ts
4772 views
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 { BasePolicy } from './basePolicy.ts';
7
import type { CategoryDto, PolicyDto } from './policyDto.ts';
8
import { renderProfileString } from './render.ts';
9
import { type Category, type NlsString, PolicyType, type LanguageTranslations } from './types.ts';
10
11
export class BooleanPolicy extends BasePolicy {
12
13
static from(category: CategoryDto, policy: PolicyDto): BooleanPolicy | undefined {
14
const { name, minimumVersion, localization, type } = policy;
15
16
if (type !== 'boolean') {
17
return undefined;
18
}
19
20
return new BooleanPolicy(name, { moduleName: '', name: { nlsKey: category.name.key, value: category.name.value } }, minimumVersion, { nlsKey: localization.description.key, value: localization.description.value }, '');
21
}
22
23
private constructor(
24
name: string,
25
category: Category,
26
minimumVersion: string,
27
description: NlsString,
28
moduleName: string,
29
) {
30
super(PolicyType.Boolean, name, category, minimumVersion, description, moduleName);
31
}
32
33
protected renderADMXElements(): string[] {
34
return [
35
`<boolean id="${this.name}" valueName="${this.name}">`,
36
` <trueValue><decimal value="1" /></trueValue><falseValue><decimal value="0" /></falseValue>`,
37
`</boolean>`
38
];
39
}
40
41
renderADMLPresentationContents() {
42
return `<checkBox refId="${this.name}">${this.name}</checkBox>`;
43
}
44
45
renderJsonValue() {
46
return false;
47
}
48
49
renderProfileValue(): string {
50
return `<false/>`;
51
}
52
53
renderProfileManifestValue(translations?: LanguageTranslations): string {
54
return `<key>pfm_default</key>
55
<false/>
56
<key>pfm_description</key>
57
<string>${renderProfileString(this.name, this.moduleName, this.description, translations)}</string>
58
<key>pfm_name</key>
59
<string>${this.name}</string>
60
<key>pfm_title</key>
61
<string>${this.name}</string>
62
<key>pfm_type</key>
63
<string>boolean</string>`;
64
}
65
}
66
67