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

Add preference clear output channel #4318

Merged
merged 17 commits into from
Aug 1, 2022

Conversation

dehru
Copy link
Contributor

@dehru dehru commented Jul 25, 2022

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

Screen Shot 2022-07-21 at 3 31 36 PM

Functionality After

Screen.Recording.2022-07-25.at.4.30.25.PM.mov

@dehru dehru marked this pull request as ready for review July 25, 2022 22:32
@dehru dehru requested a review from a team as a code owner July 25, 2022 22:32
@dehru dehru requested a review from klewis-sfdc July 25, 2022 22:32
@dehru dehru changed the title [DRAFT] add preference clear output channel Add preference clear output channel Jul 25, 2022
@@ -37,6 +38,9 @@ export class ChannelService {
}

public streamCommandStartStop(execution: CommandExecution) {
if (SfdxSettingsService.getEnableClearOutputBeforeEachCommand()) {
Copy link
Contributor Author

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()) {
Copy link
Contributor Author

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';
Copy link
Contributor Author

@dehru dehru Jul 25, 2022

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()) {
Copy link
Contributor Author

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.

Copy link
Contributor

@randi274 randi274 left a 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

@@ -0,0 +1,3 @@
export const SETTING_CLEAR_OUTPUT_TAB = 'clearOutputTab';
export const SFDX_CORE_CONFIGURATION_NAME = 'salesforcedx-vscode-core';
Copy link
Contributor

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?

Copy link
Contributor Author

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';
Copy link
Contributor

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)
Copy link
Contributor

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';
Copy link
Contributor

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';
Copy link
Contributor

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);
}
Copy link
Contributor

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.

@randi274
Copy link
Contributor

randi274 commented Aug 1, 2022

QA Notes:
✅ Salesforce Feature Previews renamed to Salesforce Core Configuration
✅ New setting "Clear Output Tab" added to top of Core Config
✅ When setting is enabled for the user, commands are cleared between each output
✅ When setting is disabled for the user, commands remain logged
✅ When setting is enabled for the workspace, commands are cleared between each output
✅ When setting is disabled for the workspace, commands remain logged
✅ Commands that don't output to the channel, like Create SOQL Query, do not clear the channel

Notes:

  • Like all settings, if the VS Code Setting for Workspace is modified but then set to false, the setting will be overridden as false even if it is set to true for the user. It's best to limit to one setting file or the other.
  • It's also very sensitive, and will clear the output at the start of any command (like Create Apex Class)

@randi274 randi274 merged commit 5dd7843 into develop Aug 1, 2022
@randi274 randi274 deleted the dehru/add-preference-clear-output-channel branch August 1, 2022 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants