Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors to ensure types for settings. Closes #317 #320

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@
"spfx-toolkit.showServiceIncidentList": {
"title": "Show service health incidents",
"type": "boolean",
"default": "true",
"default": true,
"description": "Show the service health incidents in the account view."
},
"spfx-toolkit.showTenantWideExtensions": {
"title": "Show tenant-wide extensions",
"type": "boolean",
"default": "true",
"default": true,
"description": "Show the tenant-wide extensions in the account view."
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/panels/CommandPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class CommandPanel {
new ActionTreeItem(webApiPermissionManagementUrl.replace(`${adminOriginUrl}/_layouts/15/online/AdminHome.aspx#/`, '...'), '', { name: 'globe', custom: false }, undefined, 'vscode.open', Uri.parse(webApiPermissionManagementUrl), 'sp-admin-api-url')
]));

const showServiceIncidentList = getExtensionSettings('showServiceIncidentList', true);
const showServiceIncidentList: boolean = getExtensionSettings<boolean>('showServiceIncidentList', true);
if (showServiceIncidentList === true) {
const healthInfoList = await CliActions.getTenantHealthInfo();
if (healthInfoList?.some)
Expand Down Expand Up @@ -177,7 +177,7 @@ export class CommandPanel {
]),
);

const showTenantWideExtensions = getExtensionSettings('showTenantWideExtensions', true);
const showTenantWideExtensions: boolean = getExtensionSettings<boolean>('showTenantWideExtensions', true);

if (showTenantWideExtensions === true) {
const tenantWideExtensions = await CliActions.getTenantWideExtensions(tenantAppCatalogUrl);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getExtensionSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import { EXTENSION_NAME } from '../constants';
* @param defaultValue - The default value to return if the setting is not found.
* @returns The value of the setting, or the default value if the setting is not found.
*/
export const getExtensionSettings = <T>(setting: any, defaultValue: any) =>{
export const getExtensionSettings = <T>(setting: string, defaultValue: T) => {
return workspace.getConfiguration(EXTENSION_NAME).get<T>(setting, defaultValue);
};