ryanahamilton commented on a change in pull request #15674:
URL: https://github.com/apache/airflow/pull/15674#discussion_r628240258



##########
File path: airflow/ui/src/components/AppContainer/TimezoneDropdown.tsx
##########
@@ -0,0 +1,88 @@
+/*!
+ * 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, { useState } from 'react';
+import {
+  Box,
+  Button,
+  Menu,
+  MenuButton,
+  MenuList,
+  Tooltip,
+} from '@chakra-ui/react';
+import dayjs from 'dayjs';
+import tz from 'dayjs/plugin/timezone';
+import { getTimeZones } from '@vvo/tzdb';
+
+import Select from 'components/MultiSelect';
+import { useTimezoneContext } from 'providers/TimezoneProvider';
+
+dayjs.extend(tz);
+
+interface Option { value: string, label: string }
+
+const TimezoneDropdown: React.FC = () => {
+  const { timezone, setTimezone } = useTimezoneContext();
+  const [now, setNow] = useState(dayjs().tz(timezone));
+
+  const timezones = getTimeZones();
+
+  let currentTimezone;
+  const options = timezones.map(({ name, currentTimeFormat, group }) => {
+    const label = `${currentTimeFormat.substring(0, 6)} ${name.replace(/_/g, ' 
')}`;
+    if (name === timezone || group.includes(timezone)) currentTimezone = { 
label, value: name };
+    return { label, value: name };
+  });
+
+  const onChangeTimezone = (newTimezone: Option | null) => {
+    if (newTimezone) {
+      setTimezone(newTimezone.value);
+      setNow(dayjs().tz(newTimezone.value));
+    }
+  };
+
+  return (
+    <Menu isLazy>
+      <Tooltip label="Change time zone" hasArrow>
+        <MenuButton as={Button} variant="ghost" mr="4">
+          <Box
+            as="time"
+            dateTime={now.toString()}
+            fontSize="md"
+          >
+            {now.format('HH:mm Z')}
+          </Box>
+        </MenuButton>
+      </Tooltip>
+      <MenuList placement="top-end" minWidth="350px">
+        <Box px="3" pb="1">

Review comment:
       You should be able to remove this `Box` wrapper and just move the style 
props to the parent `MenuList`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to