forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): Toolbar wrap hides search. Refactor Page (argoproj#5593)
Signed-off-by: Remington Breeze <remington@breeze.software>
- Loading branch information
Showing
6 changed files
with
153 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.page-wrapper { | ||
.page { | ||
$single-toolbar-height: 50px; | ||
&--has-toolbar { | ||
padding-top: $single-toolbar-height; | ||
} | ||
&__top-bar { | ||
height: $single-toolbar-height; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {DataLoader, Page as ArgoPage, Toolbar, Utils} from 'argo-ui'; | ||
import * as React from 'react'; | ||
import {BehaviorSubject, Observable} from 'rxjs'; | ||
import {Context, ContextApis} from '../../context'; | ||
import {services} from '../../services'; | ||
const mostRecentLoggedIn = new BehaviorSubject<boolean>(false); | ||
|
||
import './page.scss'; | ||
|
||
function isLoggedIn(): Observable<boolean> { | ||
services.users.get().then(info => mostRecentLoggedIn.next(info.loggedIn)); | ||
return mostRecentLoggedIn; | ||
} | ||
|
||
export const AddAuthToToolbar = (init: Toolbar | Observable<Toolbar>, ctx: ContextApis): Observable<Toolbar> => { | ||
return Utils.toObservable(init).map(toolbar => { | ||
toolbar = toolbar || {}; | ||
toolbar.tools = [ | ||
toolbar.tools, | ||
<DataLoader key='loginPanel' load={() => isLoggedIn()}> | ||
{loggedIn => | ||
loggedIn ? ( | ||
<a key='logout' onClick={() => ctx.navigation.goto('/auth/logout')}> | ||
Log out | ||
</a> | ||
) : ( | ||
<a key='login' onClick={() => ctx.navigation.goto('/login')}> | ||
Log in | ||
</a> | ||
) | ||
} | ||
</DataLoader> | ||
]; | ||
return toolbar; | ||
}); | ||
}; | ||
|
||
interface PageProps extends React.Props<any> { | ||
title: string; | ||
hideAuth?: boolean; | ||
toolbar?: Toolbar | Observable<Toolbar>; | ||
} | ||
|
||
export const Page = (props: PageProps) => { | ||
const ctx = React.useContext(Context); | ||
return ( | ||
<div className={`${props.hideAuth ? 'page-wrapper' : ''}`}> | ||
<ArgoPage title={props.title} children={props.children} toolbar={!props.hideAuth ? AddAuthToToolbar(props.toolbar, ctx) : props.toolbar} /> | ||
</div> | ||
); | ||
}; |