Skip to content

Commit

Permalink
Added conditional rendering to the release notes button in LWC logger…
Browse files Browse the repository at this point in the history
…HomeHeader to only show if Logger's version number has been loaded
  • Loading branch information
jongpie committed Jun 12, 2023
1 parent f3328a2 commit 612add2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
4 changes: 3 additions & 1 deletion config/linters/lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module.exports = {
},
'*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}': filenames => filenames.map(filename => `prettier --write '${filename}'`),
'**/lwc/**': filenames => {
return [`eslint --config ./config/linters/.eslintrc.json ${filenames.join(' ')} --fix`, `npm run test:lwc`];
return [`eslint --config ./config/linters/.eslintrc.json ${filenames.join(' ')} --fix`];
// FIXME this command should only run tests for the changed LWCs (instead of running tests for all LWCs)
// return [`eslint --config ./config/linters/.eslintrc.json ${filenames.join(' ')} --fix`, `npm run test:lwc`];
}
// FIXME this command should only scan the changed Apex files (instead of scanning all Apex files)
// '*.{cls,trigger}': () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ describe('c-logger-home-header', () => {
expect(modalElement).toBeFalsy();
});

it('hides the "View Release Notes" button when version number is not available', async () => {
const element = createElement('c-logger-home-header', {
is: LoggerHomeHeader
});
document.body.appendChild(element);
getEnvironmentDetails.emit({ ...MOCK_ENVIRONMENT_DETAILS, ...{ loggerVersionNumber: null } });
await Promise.resolve('Resolve getEnvironmentDetails()');
const navigationHandler = jest.fn();
element.addEventListener('navigate', navigationHandler);

const button = element.shadowRoot.querySelector('lightning-button[data-id="release-notes-button"]');
expect(button).toBeFalsy();
});

it('displays github release notes url when "View Release Notes" button is clicked', async () => {
const element = createElement('c-logger-home-header', {
is: LoggerHomeHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ <h1>
label={environmentDetailsButtonLabel}
onclick={handleViewEnvironmentDetails}
></lightning-button>
<lightning-button
data-id="release-notes-button"
icon-name="utility:announcement"
label={releaseNotesButtonLabel}
onclick={handleViewReleaseNotes}
></lightning-button>
<template if:true={showReleaseNotesButton}>
<lightning-button
data-id="release-notes-button"
icon-name="utility:announcement"
label={releaseNotesButtonLabel}
onclick={handleViewReleaseNotes}
></lightning-button>
</template>
</lightning-button-group>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default class LoggerHomeHeader extends NavigationMixin(LightningElement)
return `View Environment Details`;
}

get showReleaseNotesButton() {
return !!this.environment?.loggerVersionNumber;
}

get releaseNotesButtonLabel() {
return `View ${this.environment.loggerVersionNumber} Release Notes`;
}
Expand Down

0 comments on commit 612add2

Please sign in to comment.