File tree Expand file tree Collapse file tree 2 files changed +34
-13
lines changed
Expand file tree Collapse file tree 2 files changed +34
-13
lines changed Original file line number Diff line number Diff line change @@ -34,11 +34,13 @@ import { handleActionIfFormOpen } from 'shared/components/UnsavedMessageBox/help
3434import { showKymaCompanionState } from 'state/companion/showKymaCompanionAtom' ;
3535import { configFeaturesNames } from 'state/types' ;
3636import { themeState } from 'state/preferences/themeAtom' ;
37+ import { useCheckSAPUser } from 'hooks/useCheckSAPUser' ;
3738
3839const SNOW_STORAGE_KEY = 'snow-animation' ;
3940
4041export function Header ( ) {
4142 useAvailableNamespaces ( ) ;
43+ const isSAPUser = useCheckSAPUser ( ) ;
4244 const localStorageSnowEnabled = ( ) => {
4345 const snowStorage = localStorage . getItem ( SNOW_STORAGE_KEY ) ;
4446 if ( snowStorage && typeof JSON . parse ( snowStorage ) === 'boolean' ) {
@@ -223,19 +225,21 @@ export function Header() {
223225 title = { t ( 'navigation.feedback' ) }
224226 />
225227 ) }
226- { isKymaCompanionEnabled && window . location . pathname !== '/clusters' && (
227- < ShellBarItem
228- onClick = { ( ) =>
229- setShowCompanion ( {
230- show : true ,
231- fullScreen : false ,
232- } )
233- }
234- icon = "da"
235- text = { t ( 'kyma-companion.name' ) }
236- title = { t ( 'kyma-companion.name' ) }
237- />
238- ) }
228+ { isKymaCompanionEnabled &&
229+ isSAPUser &&
230+ window . location . pathname !== '/clusters' && (
231+ < ShellBarItem
232+ onClick = { ( ) =>
233+ setShowCompanion ( {
234+ show : true ,
235+ fullScreen : false ,
236+ } )
237+ }
238+ icon = "da"
239+ text = { t ( 'kyma-companion.name' ) }
240+ title = { t ( 'kyma-companion.name' ) }
241+ />
242+ ) }
239243 </ ShellBar >
240244 < Menu
241245 open = { isMenuOpen }
Original file line number Diff line number Diff line change 1+ import { jwtDecode } from 'jwt-decode' ;
2+ import { useRecoilValue } from 'recoil' ;
3+ import { AuthDataState , authDataState } from 'state/authDataAtom' ;
4+
5+ export function useCheckSAPUser ( ) {
6+ const authData : AuthDataState = useRecoilValue ( authDataState ) ;
7+ try {
8+ if ( authData && 'token' in authData ) {
9+ const decoded = jwtDecode ( authData ?. token ) ;
10+ return decoded ?. sub ?. includes ( '@sap.com' ) ;
11+ }
12+ } catch ( error ) {
13+ console . error ( 'Error while checking if user is SAP user' , error ) ;
14+ return false ;
15+ }
16+ return false ;
17+ }
You can’t perform that action at this time.
0 commit comments