Skip to content

Commit

Permalink
Refactors to ensure types for settings. Closes #317 (#320)
Browse files Browse the repository at this point in the history
## 🎯 Aim

The aim is to do a bit of refactor to ensure correct types when
retrieving extension settings

## 📷 Result

![image](https://github.com/user-attachments/assets/c5407994-d234-43ec-8da3-fd4fc0ef2287)

## ✅ What was done

- [X] added typing

## 🔗 Related issue

Closes: #317
  • Loading branch information
Adam-it authored Oct 7, 2024
1 parent b1f8ab1 commit 367ffc8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
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);
};

0 comments on commit 367ffc8

Please sign in to comment.