Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newswires UI: fix offline banner #104

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 76 additions & 63 deletions newswires/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,52 +56,14 @@ export function App() {
max-height: 100vh;
`}
>
{!isPoppedOut && (
<EuiHeader position="fixed">
<EuiHeaderSection>
<EuiHeaderSectionItem>
<EuiTitle
size={'s'}
css={css`
padding-bottom: 3px;
`}
>
<h1>Newswires</h1>
</EuiTitle>
</EuiHeaderSectionItem>
<EuiHeaderSectionItem>
<SideNav />
</EuiHeaderSectionItem>
</EuiHeaderSection>
<EuiHeaderSectionItem>
{
<EuiButton
iconType={'popout'}
onClick={() =>
window.open(
configToUrl({
...config,
view: 'feed',
itemId: undefined,
}),
'_blank',
'popout=true,width=400,height=800,top=200,location=no,menubar=no,toolbar=no',
)
}
>
New ticker
</EuiButton>
}
</EuiHeaderSectionItem>
</EuiHeader>
)}
{status === 'offline' && (
<EuiToast
title="You Are Currently Offline"
iconType="warning"
css={css`
border-radius: 0;
background: #fdf6d8;
position: fixed;
`}
>
<p>
Expand All @@ -110,9 +72,55 @@ export function App() {
</p>
</EuiToast>
)}
{status !== 'error' &&
state.queryData &&
state.queryData.results.length > 0 && (
<div
css={css`
${status === 'offline' && 'padding-top: 84px;'}
height: 100%;
${(status === 'loading' || status === 'error') &&
'display: flex; align-items: center;'}
${status === 'loading' && 'background: white;'}
`}
>
{!isPoppedOut && (
<EuiHeader position="fixed">
<EuiHeaderSection>
<EuiHeaderSectionItem>
<EuiTitle
size={'s'}
css={css`
padding-bottom: 3px;
`}
>
<h1>Newswires</h1>
</EuiTitle>
</EuiHeaderSectionItem>
<EuiHeaderSectionItem>
<SideNav />
</EuiHeaderSectionItem>
</EuiHeaderSection>
<EuiHeaderSectionItem>
{
<EuiButton
iconType={'popout'}
onClick={() =>
window.open(
configToUrl({
...config,
view: 'feed',
itemId: undefined,
}),
'_blank',
'popout=true,width=400,height=800,top=200,location=no,menubar=no,toolbar=no',
)
}
>
New ticker
</EuiButton>
}
</EuiHeaderSectionItem>
</EuiHeader>
)}
{status !== 'error' && (
<>
<EuiShowFor sizes={['xs', 's']}>
{view === 'item' ? <Item id={selectedItemId} /> : <Feed />}
Expand Down Expand Up @@ -146,27 +154,32 @@ export function App() {
</EuiShowFor>
</>
)}
{status == 'error' && (
<EuiEmptyPrompt
css={css`
background: white;
`}
actions={[
<EuiButton onClick={handleRetry} key="retry" iconType={'refresh'}>
Retry
</EuiButton>,
<EuiButton
onClick={() => handleEnterQuery(defaultQuery)}
key="clear"
iconType={'cross'}
>
Clear
</EuiButton>,
]}
body={<p>Sorry, failed to load because of {state.error}</p>}
hasBorder={true}
/>
)}
{status == 'error' && (
<EuiEmptyPrompt
css={css`
background: white;
`}
actions={[
<EuiButton
onClick={handleRetry}
key="retry"
iconType={'refresh'}
>
Retry
</EuiButton>,
<EuiButton
onClick={() => handleEnterQuery(defaultQuery)}
key="clear"
iconType={'cross'}
>
Clear
</EuiButton>,
]}
body={<p>Sorry, failed to load because of {state.error}</p>}
hasBorder={true}
/>
)}
</div>
</EuiPageTemplate>
</EuiProvider>
);
Expand Down
Loading