mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { BasePolicy } from './basePolicy';
|
|
import { CategoryDto, PolicyDto } from './policyDto';
|
|
import { renderProfileString } from './render';
|
|
import { Category, NlsString, PolicyType, LanguageTranslations } from './types';
|
|
|
|
export class StringPolicy extends BasePolicy {
|
|
|
|
static from(category: CategoryDto, policy: PolicyDto): StringPolicy | undefined {
|
|
const { type, name, minimumVersion, localization } = policy;
|
|
|
|
if (type !== 'string') {
|
|
return undefined;
|
|
}
|
|
|
|
return new StringPolicy(name, { moduleName: '', name: { nlsKey: category.name.key, value: category.name.value } }, minimumVersion, { nlsKey: localization.description.key, value: localization.description.value }, '');
|
|
}
|
|
|
|
private constructor(
|
|
name: string,
|
|
category: Category,
|
|
minimumVersion: string,
|
|
description: NlsString,
|
|
moduleName: string,
|
|
) {
|
|
super(PolicyType.String, name, category, minimumVersion, description, moduleName);
|
|
}
|
|
|
|
protected renderADMXElements(): string[] {
|
|
return [`<text id="${this.name}" valueName="${this.name}" required="true" />`];
|
|
}
|
|
|
|
renderJsonValue() {
|
|
return '';
|
|
}
|
|
|
|
renderADMLPresentationContents() {
|
|
return `<textBox refId="${this.name}"><label>${this.name}:</label></textBox>`;
|
|
}
|
|
|
|
renderProfileValue(): string {
|
|
return `<string></string>`;
|
|
}
|
|
|
|
renderProfileManifestValue(translations?: LanguageTranslations): string {
|
|
return `<key>pfm_default</key>
|
|
<string></string>
|
|
<key>pfm_description</key>
|
|
<string>${renderProfileString(this.name, this.moduleName, this.description, translations)}</string>
|
|
<key>pfm_name</key>
|
|
<string>${this.name}</string>
|
|
<key>pfm_title</key>
|
|
<string>${this.name}</string>
|
|
<key>pfm_type</key>
|
|
<string>string</string>`;
|
|
}
|
|
}
|