-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI layout containers + navigation (#15007)
* Adds layout containers to render navigation - Adds additional placeholder routes/views * Remove "containers" directory, move files in context w/in views * Add app container to Login view * Convert static list to use data array * Move/separate Icons and SVGs into separate components * Remove unintention file addition * Update test contex * Make the env var more universal
- Loading branch information
1 parent
f94cf99
commit 645e772
Showing
39 changed files
with
1,456 additions
and
119 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
API_URL = 'http://127.0.0.1:28080/api/v1/' | ||
WEBSERVER_URL = 'http://127.0.0.1:28080' |
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 |
---|---|---|
|
@@ -57,7 +57,7 @@ module.exports = { | |
}), | ||
react({ | ||
env: [ | ||
'API_URL' | ||
'WEBSERVER_URL' | ||
], | ||
html: { | ||
title: 'Apache Airflow', | ||
|
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/*! | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import dayjs from 'dayjs'; | ||
import { | ||
Avatar, | ||
Box, | ||
Button, | ||
Flex, | ||
Icon, | ||
Menu, | ||
MenuButton, | ||
MenuDivider, | ||
MenuList, | ||
MenuItem, | ||
useColorMode, | ||
useColorModeValue, | ||
Tooltip, | ||
} from '@chakra-ui/react'; | ||
import { | ||
MdWbSunny, | ||
MdBrightness2, | ||
MdAccountCircle, | ||
MdExitToApp, | ||
} from 'react-icons/md'; | ||
|
||
import { useAuthContext } from 'auth/context'; | ||
|
||
import ApacheAirflowLogo from 'components/icons/ApacheAirflowLogo'; | ||
|
||
interface Props { | ||
bodyBg: string; | ||
overlayBg: string; | ||
breadcrumb?: React.ReactNode; | ||
} | ||
|
||
const AppHeader: React.FC<Props> = ({ bodyBg, overlayBg, breadcrumb }) => { | ||
const { toggleColorMode } = useColorMode(); | ||
const now = dayjs(); | ||
const headerHeight = '56px'; | ||
const { hasValidAuthToken, logout } = useAuthContext(); | ||
|
||
const handleOpenTZ = () => window.alert('This will open time zone select modal!'); | ||
|
||
const handleOpenProfile = () => window.alert('This will take you to your user profile view.'); | ||
|
||
return ( | ||
<Flex | ||
as="header" | ||
role="banner" | ||
position="fixed" | ||
width={`calc(100vw - ${headerHeight})`} | ||
height={headerHeight} | ||
zIndex={2} | ||
align="center" | ||
justifyContent="space-between" | ||
py="2" | ||
px="4" | ||
backgroundColor={overlayBg} | ||
borderBottomWidth="1px" | ||
borderBottomColor={bodyBg} | ||
> | ||
{breadcrumb} | ||
{!breadcrumb && ( | ||
<Link to="/" aria-label="Back to home"> | ||
<ApacheAirflowLogo /> | ||
</Link> | ||
)} | ||
{hasValidAuthToken && ( | ||
<Flex align="center"> | ||
<Tooltip label="Change time zone" hasArrow> | ||
{/* TODO: open modal for time zone update */} | ||
<Button variant="ghost" mr="4" onClick={handleOpenTZ}> | ||
<Box | ||
as="time" | ||
dateTime={now.toString()} | ||
fontSize="md" | ||
> | ||
{now.format('h:mmA Z')} | ||
</Box> | ||
</Button> | ||
</Tooltip> | ||
<Menu> | ||
<MenuButton> | ||
<Avatar name="Ryan Hamilton" size="sm" color="blue.900" bg="blue.200" /> | ||
</MenuButton> | ||
<MenuList placement="top-end"> | ||
<MenuItem onClick={handleOpenProfile}> | ||
<Icon as={MdAccountCircle} mr="2" /> | ||
Your Profile | ||
</MenuItem> | ||
<MenuItem onClick={toggleColorMode}> | ||
<Icon as={useColorModeValue(MdBrightness2, MdWbSunny)} mr="2" /> | ||
Set | ||
{useColorModeValue(' Dark ', ' Light ')} | ||
Mode | ||
</MenuItem> | ||
<MenuDivider /> | ||
<MenuItem onClick={logout}> | ||
<Icon as={MdExitToApp} mr="2" /> | ||
Logout | ||
</MenuItem> | ||
</MenuList> | ||
</Menu> | ||
</Flex> | ||
)} | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default AppHeader; |
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,111 @@ | ||
/*! | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { Box } from '@chakra-ui/react'; | ||
import { | ||
FiActivity, | ||
FiBookOpen, | ||
FiSettings, | ||
FiUsers, | ||
} from 'react-icons/fi'; | ||
|
||
import { useAuthContext } from 'auth/context'; | ||
|
||
import PinwheelLogo from 'components/icons/PinwheelLogo'; | ||
import PipelineIcon from 'components/icons/PipelineIcon'; | ||
|
||
import AppNavBtn from './AppNavBtn'; | ||
|
||
interface Props { | ||
bodyBg: string; | ||
overlayBg: string; | ||
} | ||
|
||
const AppNav: React.FC<Props> = ({ bodyBg, overlayBg }) => { | ||
const { hasValidAuthToken } = useAuthContext(); | ||
|
||
const navItems = [ | ||
{ | ||
label: 'Pipelines', | ||
icon: PipelineIcon, | ||
path: '/pipelines', | ||
activePath: '/pipelines', | ||
}, | ||
{ | ||
label: 'Activity', | ||
icon: FiActivity, | ||
path: '/activity/event-logs', | ||
activePath: '/activity', | ||
}, | ||
{ | ||
label: 'Config', | ||
icon: FiSettings, | ||
path: '/config', | ||
activePath: '/config', | ||
}, | ||
{ | ||
label: 'access', | ||
icon: FiUsers, | ||
path: '/access', | ||
activePath: '/access', | ||
}, | ||
{ | ||
label: 'Docs', | ||
icon: FiBookOpen, | ||
path: '/docs', | ||
activePath: '/docs', | ||
}, | ||
]; | ||
|
||
return ( | ||
<Box | ||
as="nav" | ||
role="navigation" | ||
width="56px" | ||
backgroundColor={overlayBg} | ||
borderRightWidth="1px" | ||
borderRightColor={bodyBg} | ||
display="flex" | ||
flexDirection="column" | ||
> | ||
<Box | ||
as={Link} | ||
to="/" | ||
aria-label="Back to home" | ||
width="56px" | ||
height="56px" | ||
display="flex" | ||
alignItems="center" | ||
justifyContent="center" | ||
_hover={{ | ||
transformOrigin: '28px 28px', | ||
}} | ||
> | ||
<PinwheelLogo /> | ||
</Box> | ||
{hasValidAuthToken && navItems.map((item) => ( | ||
<AppNavBtn key={item.label} navItem={item} /> | ||
))} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default AppNav; |
Oops, something went wrong.