Skip to content

Commit 7f59150

Browse files
authored
feat(connection-form): show a banner on the connection form explaining why you can't edit the connection COMPASS-8264 (#6344)
* show a banner on the connection form explaining why you can't edit the connection * edge case
1 parent cbed839 commit 7f59150

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

packages/connection-form/src/components/connection-form.spec.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,22 @@ describe('ConnectionForm Component', function () {
280280
);
281281
});
282282

283+
context('protectConnectionStrings', function () {
284+
it('should not render the banner by default', function () {
285+
renderForm();
286+
expect(
287+
screen.queryByTestId('protect-connection-strings-banner')
288+
).to.be.null;
289+
});
290+
291+
it('renders a banner if protectConnectionStrings === true', function () {
292+
renderForm({
293+
protectConnectionStrings: true,
294+
});
295+
expect(screen.getByTestId('protect-connection-strings-banner')).to.exist;
296+
});
297+
});
298+
283299
// TODO(COMPASS-7762)
284300
context.skip('when preferences.showFavoriteActions === false', function () {
285301
it('should not render the favorite button', function () {

packages/connection-form/src/components/connection-form.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const headingWithHiddenButtonStyles = css({
129129
},
130130
});
131131

132-
const disabledConnectedConnectionBannerStyles = css({
132+
const bannerStyles = css({
133133
marginTop: spacing[400],
134134
paddingRight: 0,
135135
});
@@ -500,7 +500,7 @@ function ConnectionForm({
500500
{disableEditingConnectedConnection && onDisconnectClicked && (
501501
<Banner
502502
data-testid="disabled-connected-connection-banner"
503-
className={disabledConnectedConnectionBannerStyles}
503+
className={bannerStyles}
504504
>
505505
<div className={disabledConnectedConnectionContentStyles}>
506506
<div>
@@ -521,6 +521,17 @@ function ConnectionForm({
521521
</div>
522522
</Banner>
523523
)}
524+
{protectConnectionStrings && !disableEditingConnectedConnection && (
525+
<Banner
526+
data-testid="protect-connection-strings-banner"
527+
className={bannerStyles}
528+
>
529+
Advanced Connection Options are hidden while the &quot;Protect
530+
Connection String Secrets&quot; setting is enabled. Disable the
531+
setting to configure Advanced Connection Options or edit your
532+
connection string.
533+
</Banner>
534+
)}
524535
<ConnectionStringInput
525536
connectionString={connectionOptions.connectionString}
526537
enableEditingConnectionString={enableEditingConnectionString}

0 commit comments

Comments
 (0)