Skip to content

Commit

Permalink
feat: re-order message banners (#4995)
Browse files Browse the repository at this point in the history
https://linear.app/unleash/issue/2-1494/re-order-message-banners

- Re-orders message banners to fit into this logic:

>1. Maintenance banner
>2. External message banner(s) - Most likely coming from Unleash
>3. Internal message banner(s)

- Renames the feature flag to better reflect the feature behavior;
- Lays a basic skeleton structure for this new feature;
  • Loading branch information
nunogois authored Oct 11, 2023
1 parent bc96216 commit 65f4241
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 8 deletions.
4 changes: 4 additions & 0 deletions frontend/src/component/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import MaintenanceBanner from './maintenance/MaintenanceBanner';
import { styled } from '@mui/material';
import { InitialRedirect } from './InitialRedirect';
import { InternalMessageBanners } from './messageBanners/internalMessageBanners/InternalMessageBanners';
import { ExternalMessageBanners } from './messageBanners/externalMessageBanners/ExternalMessageBanners';

const StyledContainer = styled('div')(() => ({
'& ul': {
Expand Down Expand Up @@ -63,6 +65,8 @@ export const App = () => {
)}
show={<MaintenanceBanner />}
/>
<ExternalMessageBanners />
<InternalMessageBanners />
<StyledContainer>
<ToastRenderer />
<Routes>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { MessageBanner } from 'component/common/MessageBanner/MessageBanner';

export const ExternalMessageBanners = () => {
// TODO: Implement. If we allow multiple internal message banners, then perhaps we should allow the same for external message banners.

return <MessageBanner />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { MessageBanner } from 'component/common/MessageBanner/MessageBanner';
import { useUiFlag } from 'hooks/useUiFlag';

export const InternalMessageBanners = () => {
const internalMessageBanners = useUiFlag('internalMessageBanners');

if (!internalMessageBanners) return null;

// TODO: Implement. `messageBanners` should come from a `useMessageBanners()` hook.

const mockMessageBanners = [
{
message: 'Test 1',
},
{
message: 'Test 2',
},
{
message: 'Test 3',
},
];

return (
<>
{mockMessageBanners.map((messageBanner) => (
<MessageBanner key={messageBanner.message} />
))}
</>
);
};
2 changes: 0 additions & 2 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { FeedbackCESProvider } from 'component/feedback/FeedbackCESContext/Feedb
import { AnnouncerProvider } from 'component/common/Announcer/AnnouncerProvider/AnnouncerProvider';
import { InstanceStatus } from 'component/common/InstanceStatus/InstanceStatus';
import { UIProviderContainer } from 'component/providers/UIProvider/UIProviderContainer';
import { MessageBanner } from 'component/common/MessageBanner/MessageBanner';

window.global ||= window;

Expand All @@ -25,7 +24,6 @@ ReactDOM.render(
<AnnouncerProvider>
<FeedbackCESProvider>
<InstanceStatus>
<MessageBanner />
<ScrollTop />
<App />
</InstanceStatus>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/interfaces/uiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type UiFlags = {
privateProjects?: boolean;
accessOverview?: boolean;
dependentFeatures?: boolean;
internalMessageBanner?: boolean;
internalMessageBanners?: boolean;
[key: string]: boolean | Variant | undefined;
};

Expand Down
4 changes: 2 additions & 2 deletions src/lib/__snapshots__/create-config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ exports[`should create default config 1`] = `
"featuresExportImport": true,
"filterInvalidClientMetrics": false,
"googleAuthEnabled": false,
"internalMessageBanner": false,
"internalMessageBanners": false,
"lastSeenByEnvironment": false,
"maintenanceMode": false,
"messageBanner": {
Expand Down Expand Up @@ -134,7 +134,7 @@ exports[`should create default config 1`] = `
"featuresExportImport": true,
"filterInvalidClientMetrics": false,
"googleAuthEnabled": false,
"internalMessageBanner": false,
"internalMessageBanners": false,
"lastSeenByEnvironment": false,
"maintenanceMode": false,
"messageBanner": {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/types/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type IFlagKey =
| 'disableMetrics'
| 'transactionalDecorator'
| 'useLastSeenRefactor'
| 'internalMessageBanner';
| 'internalMessageBanners';

export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;

Expand Down Expand Up @@ -158,8 +158,8 @@ const flags: IFlags = {
process.env.UNLEASH_EXPERIMENTAL_USE_LAST_SEEN_REFACTOR,
false,
),
internalMessageBanner: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_INTERNAL_MESSAGE_BANNER,
internalMessageBanners: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_INTERNAL_MESSAGE_BANNERS,
false,
),
};
Expand Down

0 comments on commit 65f4241

Please sign in to comment.