-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Skeleton for metrics section. Refactor time selector into a separ…
…ate component.
- Loading branch information
Showing
3 changed files
with
123 additions
and
44 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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/*! | ||
* 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 { | ||
HStack, | ||
Text, | ||
type SelectValueChangeDetails, | ||
type ListCollection, | ||
} from "@chakra-ui/react"; | ||
import dayjs from "dayjs"; | ||
import { FiCalendar } from "react-icons/fi"; | ||
|
||
import Time from "src/components/Time"; | ||
import { Select } from "src/components/ui"; | ||
|
||
type Props = { | ||
readonly defaultValue: string; | ||
readonly endDate: string; | ||
readonly setEndDate: (startDate: string) => void; | ||
readonly setStartDate: (startDate: string) => void; | ||
readonly startDate: string; | ||
readonly timeOptions: ListCollection<{ label: string; value: string }>; | ||
}; | ||
|
||
const TimeSelector = ({ | ||
defaultValue, | ||
endDate, | ||
setEndDate, | ||
setStartDate, | ||
startDate, | ||
timeOptions, | ||
}: Props) => { | ||
const handleTimeChange = ({ | ||
value, | ||
}: SelectValueChangeDetails<Array<string>>) => { | ||
const cnow = dayjs(); | ||
|
||
setStartDate(cnow.subtract(Number(value[0]), "hour").toISOString()); | ||
setEndDate(cnow.toISOString()); | ||
}; | ||
|
||
return ( | ||
<HStack> | ||
<FiCalendar /> | ||
<Select.Root | ||
collection={timeOptions} | ||
data-testid="filter-duration" | ||
defaultValue={[defaultValue]} | ||
onValueChange={handleTimeChange} | ||
width="200px" | ||
> | ||
<Select.Trigger> | ||
<Select.ValueText placeholder="Duration" /> | ||
</Select.Trigger> | ||
<Select.Content> | ||
{timeOptions.items.map((option) => ( | ||
<Select.Item item={option} key={option.value}> | ||
{option.label} | ||
</Select.Item> | ||
))} | ||
</Select.Content> | ||
</Select.Root> | ||
<Text> | ||
<Time datetime={startDate} /> - <Time datetime={endDate} /> | ||
</Text> | ||
</HStack> | ||
); | ||
}; | ||
|
||
export default TimeSelector; |
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
26 changes: 26 additions & 0 deletions
26
airflow/ui/src/pages/Dashboard/HistoricalMetrics/MetricSectionSkeleton.tsx
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,26 @@ | ||
/*! | ||
* 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 { VStack, Skeleton } from "@chakra-ui/react"; | ||
|
||
export const MetricSectionSkeleton = () => ( | ||
<VStack height={200} width="full"> | ||
<Skeleton height={200} width="full" /> | ||
<Skeleton height={200} width="full" /> | ||
</VStack> | ||
); |