( settingKey: string, selectedScope: SettingScope, settings: LoadedSettings, )
| 35 | * Generate scope message for a specific setting |
| 36 | */ |
| 37 | export function getScopeMessageForSetting( |
| 38 | settingKey: string, |
| 39 | selectedScope: SettingScope, |
| 40 | settings: LoadedSettings, |
| 41 | ): string { |
| 42 | const otherScopes = Object.values(SettingScope).filter( |
| 43 | (scope) => scope !== selectedScope, |
| 44 | ); |
| 45 | |
| 46 | const modifiedInOtherScopes = otherScopes.filter((scope) => { |
| 47 | const scopeSettings = settings.forScope(scope).settings; |
| 48 | return settingExistsInScope(settingKey, scopeSettings); |
| 49 | }); |
| 50 | |
| 51 | if (modifiedInOtherScopes.length === 0) { |
| 52 | return ''; |
| 53 | } |
| 54 | |
| 55 | const modifiedScopesStr = modifiedInOtherScopes.join(', '); |
| 56 | const currentScopeSettings = settings.forScope(selectedScope).settings; |
| 57 | const existsInCurrentScope = settingExistsInScope( |
| 58 | settingKey, |
| 59 | currentScopeSettings, |
| 60 | ); |
| 61 | |
| 62 | return existsInCurrentScope |
| 63 | ? `(Also modified in ${modifiedScopesStr})` |
| 64 | : `(Modified in ${modifiedScopesStr})`; |
| 65 | } |
no test coverage detected