Skip to content

Commit 92bfb6c

Browse files
authored
feat: Use togglebutton instead of the shellbar item for an ai assistant button (#3898)
1 parent e137adf commit 92bfb6c

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/header/Header.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { useRef, useState } from 'react';
2-
import { useRecoilValue, useSetRecoilState } from 'recoil';
2+
import { useRecoilState, useRecoilValue } from 'recoil';
33
import {
44
Avatar,
55
ShellBar,
66
ShellBarItem,
77
ListItemStandard,
8+
ToggleButton,
89
} from '@ui5/webcomponents-react';
910

1011
import { useTranslation } from 'react-i18next';
@@ -45,7 +46,9 @@ export function Header() {
4546
const clusters = useRecoilValue(clustersState);
4647

4748
const { isEnabled: isKymaCompanionEnabled } = useFeature('KYMA_COMPANION');
48-
const setShowCompanion = useSetRecoilState(showKymaCompanionState);
49+
const [showCompanion, setShowCompanion] = useRecoilState(
50+
showKymaCompanionState,
51+
);
4952
const shellbarRef = useRef(null);
5053

5154
const inactiveClusterNames = Object.keys(clusters || {}).filter(
@@ -148,16 +151,18 @@ export function Header() {
148151
{isKymaCompanionEnabled &&
149152
isSAPUser &&
150153
window.location.pathname !== '/clusters' && (
151-
<ShellBarItem
152-
onClick={() =>
154+
<ToggleButton
155+
accessibleName="Kyma Companion"
156+
icon={showCompanion.show ? 'da-2' : 'da'}
157+
onClick={e => {
158+
e.preventDefault();
153159
setShowCompanion({
154160
show: true,
155161
fullScreen: false,
156-
})
157-
}
158-
icon="da"
159-
text={t('kyma-companion.name')}
160-
title={t('kyma-companion.name')}
162+
});
163+
}}
164+
pressed={showCompanion.show}
165+
slot="assistant"
161166
/>
162167
)}
163168
</ShellBar>

tests/integration/support/companion-commands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Cypress.Commands.add('openCompanion', () => {
22
cy.get('ui5-shellbar')
3-
.find('ui5-button[icon="da"]')
3+
.find('ui5-toggle-button[icon="da"]')
44
.should('be.visible')
55
.click();
66
});

tests/integration/tests/companion/test-companion-ui.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ context('Test Companion UI', () => {
6767
cy.wait(1000);
6868

6969
cy.get('@shellbar')
70-
.find('ui5-button[icon="da"]')
70+
.find('ui5-toggle-button[icon="da"]')
7171
.should('not.exist');
7272
});
7373
});

0 commit comments

Comments
 (0)