Skip to content

Commit

Permalink
Added pinned announcements whitelist config
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardik-hi committed Jul 18, 2022
1 parent c23f118 commit 54e1316
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/announcements/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function App() {
theme={theme}
routes={routes}
AuthComponent={LoginComponent}
isShowPinnedAnnouncements={true}
appName="announcements"
/>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/announcements/src/pages/Announcements.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const Announcements = ({ footerLinks, appName, pinnedAnnouncementsData }) => {
subHeading: moment().format("hh:mm A"),
_subHeading: { fontWeight: 500, textTransform: "uppercase" },
}}
_appBar={{ languages: manifest.languages, showPinnedAnnouncements: true }}
_appBar={{ languages: manifest.languages }}
subHeader={t("VIEW_LATEST_ANNOUNCEMENTS")}
_subHeader={{
bg: colors?.cardBg,
Expand Down
1 change: 1 addition & 0 deletions packages/attendance/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function App() {
basename={process.env.PUBLIC_URL}
routes={routes}
AuthComponent={LoginComponent}
appName="attendance"
/>
);
}
Expand Down
11 changes: 7 additions & 4 deletions packages/common-lib/src/components/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function AppShell({
basename,
isShowFooterLink,
appName,
isShowPinnedAnnouncements,
...otherProps
}: any) {
const [token, setToken] = useState(localStorage.getItem('token'))
Expand Down Expand Up @@ -57,10 +56,14 @@ function AppShell({
]
}

//TODO: integrate with API call to fetch whitelisted modules
const pinnedAnnouncementsWhitelist = ['announcements']
//TODO: integrate with API call to fetch pinned announcements
//pinned announcements data is common to all components depending on their
const pinnedAnnouncementsData = !isShowPinnedAnnouncements
? []

const pinnedAnnouncementsData = !pinnedAnnouncementsWhitelist.some(
(val: string) => val === appName
)
? undefined
: [
{
data: 'Shiksha V2.0 Is Live! 🚀🎉',
Expand Down
4 changes: 3 additions & 1 deletion packages/common-lib/src/components/layout/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export default function Layout({
}}
space={5}
>
<PinnedAnnouncements {...{ _pinnedAnnouncementsData }} />
{_pinnedAnnouncementsData ? (
<PinnedAnnouncements {...{ _pinnedAnnouncementsData }} />
) : null}
{!isDisabledAppBar ? (
<AppBar color={imageUrl ? 'white' : ''} {..._appBar} />
) : (
Expand Down

0 comments on commit 54e1316

Please sign in to comment.