Skip to content

Commit

Permalink
move to own component
Browse files Browse the repository at this point in the history
  • Loading branch information
thewahome committed Feb 16, 2024
1 parent b8a95eb commit 734f529
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
30 changes: 30 additions & 0 deletions src/app/views/main-header/BannerNotification.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { MessageBar } from '@fluentui/react';
import { useState } from 'react';

import { BANNERMESSAGE } from '../../services/variant-constants';
import variantService from '../../services/variant-service';

const BannerNotification = () => {
const [bannerMessage, setBannerMessage] = useState('');

setTimeout(() => {
variantService.getFeatureVariables('default', BANNERMESSAGE).then((value) => {
if (value && value !== ' ') {
setBannerMessage(value as string);
}
});
}, 1000);

if (!!!bannerMessage) {
return null;
}

return (
<MessageBar>
{bannerMessage}
</MessageBar>
);

}

export default BannerNotification
18 changes: 2 additions & 16 deletions src/app/views/main-header/MainHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import {
FontIcon, getId, getTheme, IconButton, IStackTokens, Label,
MessageBar,
registerIcons, Stack, TooltipHost
} from '@fluentui/react';
import { useState } from 'react';

import { useAppSelector } from '../../../store';
import { Mode } from '../../../types/enums';
import { BANNERMESSAGE } from '../../services/variant-constants';
import variantService from '../../services/variant-service';
import { translateMessage } from '../../utils/translate-messages';
import { Authentication } from '../authentication';
import { FeedbackButton } from './FeedbackButton';
import { Help } from './Help';
import { mainHeaderStyles } from './MainHeader.styles';
import { Settings } from './settings/Settings';
import TenantIcon from './tenantIcon';
import BannerNotification from './BannerNotification';

interface MainHeaderProps {
toggleSidebar: Function;
Expand All @@ -36,7 +33,6 @@ export const MainHeader: React.FunctionComponent<MainHeaderProps> = (props: Main
const { profile, graphExplorerMode, sidebarProperties } = useAppSelector(
(state) => state
);
const [bannerMessage, setBannerMessage] = useState('');

const mobileScreen = !!sidebarProperties.mobileScreen;
const showSidebar = !!sidebarProperties.showSidebar;
Expand All @@ -47,14 +43,6 @@ export const MainHeader: React.FunctionComponent<MainHeaderProps> = (props: Main
feedbackIconAdjustmentStyles, tenantIconStyles, moreInformationStyles,
tenantLabelStyle, tenantContainerStyle } = mainHeaderStyles(currentTheme, mobileScreen);

setTimeout(() => {
variantService.getFeatureVariables('default', BANNERMESSAGE).then((value) => {
if (value && value !== ' ') {
setBannerMessage(value as string);
}
});
}, 1000);

return (
<Stack tokens={sectionStackTokens}>
<Stack
Expand Down Expand Up @@ -127,9 +115,7 @@ export const MainHeader: React.FunctionComponent<MainHeaderProps> = (props: Main
<Authentication />
</Stack>
</Stack>
{!!bannerMessage && <MessageBar>
{bannerMessage}
</MessageBar>}
<BannerNotification />
</Stack>
);
};
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { initializeIcons } from '@fluentui/react';
import '@ms-ofb/officebrowserfeedbacknpm/styles/officebrowserfeedback.css';
import 'bootstrap/dist/css/bootstrap-grid.min.css';
import ReactDOM from 'react-dom/client';

import { Provider } from 'react-redux';

import { getAuthTokenSuccess, getConsentedScopesSuccess } from './app/services/actions/auth-action-creators';
import { createCollection } from './app/services/actions/collections-action-creators';
import { setDevxApiUrl } from './app/services/actions/devxApi-action-creators';
Expand Down

0 comments on commit 734f529

Please sign in to comment.