-
Notifications
You must be signed in to change notification settings - Fork 391
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
Add preference clear output channel #4318
Conversation
@@ -37,6 +38,9 @@ export class ChannelService { | |||
} | |||
|
|||
public streamCommandStartStop(execution: CommandExecution) { | |||
if (SfdxSettingsService.getEnableClearOutputBeforeEachCommand()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The channel service is my first choice to attempt to handle this preference in one central location. Unfortunately, the way the channel service is used throughout the app is very inconsistent. This "streamCommandStartStop()" is used by some of the abstract executors ( SfdxCommandletExecutor, LibraryExectutor ) that are exported from salesforcedx-utils-vscode.
@@ -161,6 +162,9 @@ export abstract class LibraryCommandletExecutor<T> | |||
const startTime = process.hrtime(); | |||
const channelService = new ChannelService(this.outputChannel); | |||
const telemetryService = TelemetryService.getInstance(); | |||
if (SfdxSettingsService.getEnableClearOutputBeforeEachCommand()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LibraryCommandletExecutor is exported from salesforcedx-utils-vscode
and is another place that I found to check and clear the output log.
@@ -0,0 +1,3 @@ | |||
export const SETTING_CLEAR_OUTPUT_TAB = 'clearOutputTab'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are now all exported by salesforcedx-utils-vscode
and consumed in other modules so that the string 'salesforcedx-vscode-core'
is not in 20 places in various modules of the mono-repo.
@@ -165,6 +166,9 @@ export class SfdxCommandlet<T> { | |||
} | |||
|
|||
public async run(): Promise<void> { | |||
if (sfdxCoreSettings.getEnableClearOutputBeforeEachCommand()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this to the run() method here basically adds this feature to all the commands that extend SfdxCommandlet
in the salesforcedx-vscode-core
extension. I wish there was an elegant single cut-point elsewhere in the salesforcedx-utils-vscode
module like this, but there was not.
…ithub.com/forcedotcom/salesforcedx-vscode into dehru/add-preference-clear-output-channel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great, and look at those lovely unit tests! 😍 Just a few quick qs. Good for me otherwise pending QA
packages/salesforcedx-utils-vscode/src/commands/channelService.ts
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,3 @@ | |||
export const SETTING_CLEAR_OUTPUT_TAB = 'clearOutputTab'; | |||
export const SFDX_CORE_CONFIGURATION_NAME = 'salesforcedx-vscode-core'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's your thought here having these two identical strings with different names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided that since they represent 2 different things, that we should have 2 constants, even though they are the same string.
I wanted anyone changing these in the future to be more aware of what this constant represents.
@@ -5,6 +5,7 @@ | |||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | |||
*/ | |||
import * as vscode from 'vscode'; | |||
import { SfdxSettingsService } from '../settings'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be imported
@@ -112,7 +113,7 @@ export class NotificationService { | |||
executionName | |||
); | |||
const showCLISuccessMsg = vscode.workspace | |||
.getConfiguration('salesforcedx-vscode-core') | |||
.getConfiguration(SFDX_CORE_CONFIGURATION_NAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
vscode.workspace
.getConfiguration(SFDX_CORE_CONFIGURATION_NAME)
is called twice, how about changing to:
const coreConfigurationName = vscode.workspace.getConfiguration(SFDX_CORE_CONFIGURATION_NAME);
const showCLISuccessMsg = coreConfigurationName.get<boolean>('show-cli-success-msg', true);
..and then using coreConfigurationName
on line 132 & 133.
@@ -41,3 +41,4 @@ export { | |||
getRootWorkspacePath, | |||
getRootWorkspaceSfdxPath | |||
} from './workspaces'; | |||
export { SETTING_CLEAR_OUTPUT_TAB, SFDX_CORE_CONFIGURATION_NAME, SFDX_CORE_EXTENSION_NAME } from './constants'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the imports need to be alphabetized. I'm surprised the linter didn't catch this.
Since this is being imported from ./constants
, it should be moved to line 25, before the import from ./context/...
@@ -12,6 +12,7 @@ import { MockTestOrgData, testSetup } from '@salesforce/core/lib/testSetup'; | |||
import { notificationService } from '@salesforce/salesforcedx-utils-vscode/out/src/commands'; | |||
import { TraceFlags } from '@salesforce/salesforcedx-utils-vscode/out/src/helpers'; | |||
import * as utils from '@salesforce/salesforcedx-utils-vscode/out/src/index'; | |||
import { SFDX_CORE_CONFIGURATION_NAME } from '@salesforce/salesforcedx-utils-vscode/out/src/index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since @salesforce/salesforcedx-utils-vscode/out/src/index
is already being imported, can line 15 be removed and on line 54, use utils.SFDX_CORE_CONFIGURATION_NAME
?
@@ -75,6 +74,9 @@ export class SfdxCoreSettings { | |||
return this.getConfigValue(CONFLICT_DETECTION_ENABLED, false); | |||
} | |||
|
|||
public getEnableClearOutputBeforeEachCommand(): boolean { | |||
return this.getConfigValue(SETTING_CLEAR_OUTPUT_TAB, false); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick: please add an extra carriage return after the closing curly brace.
QA Notes: Notes:
|
What does this PR do?
This PR adds a user/workspace preference and changes the preference category they display under in the preferences UI. When set, the output channel is cleared between each common command. There are a few commands that do not output to the channel ( Like Create Soql Query ) and those do not clear the channel.
What issues does this PR fix or reference?
#941, @W-10288504@
Functionality Before
Old and New Preference Shown Below
Functionality After
Screen.Recording.2022-07-25.at.4.30.25.PM.mov