@prefecthq/prefect-ui-library
Version:
This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.
26 lines (23 loc) • 960 B
text/typescript
import { DateRangeSelectValue } from '@prefecthq/prefect-design'
import { BooleanRouteParam, useRouteQueryParam } from '@prefecthq/vue-compositions'
import { computed, reactive } from 'vue'
import { useDateRangeSelectValueFromRoute } from '@/compositions/useDateRangeSelectValue'
import { WorkspaceDashboardFilter } from '@/types/dashboard'
export function useWorkspaceDashboardFilterFromRoute(defaultValue: WorkspaceDashboardFilter): WorkspaceDashboardFilter {
const tags = useRouteQueryParam('tags', defaultValue.tags)
const dateRange = useDateRangeSelectValueFromRoute(defaultValue.range)
const hideSubflows = useRouteQueryParam('hide-subflows', BooleanRouteParam, defaultValue.hideSubflows)
const range = computed<NonNullable<DateRangeSelectValue>>({
get() {
return dateRange.range ?? defaultValue.range
},
set(value) {
dateRange.range = value
},
})
return reactive({
range,
tags,
hideSubflows,
})
}