feat: add date math for filters #1342

Merged
konrad merged 88 commits from feature/date-math into main 2022-03-28 17:30:43 +00:00
3 changed files with 16 additions and 12 deletions
Showing only changes of commit aac777e286 - Show all commits

View File

@ -1,6 +1,7 @@
<template>
<card class="has-no-shadow how-it-works-modal"
:title="$t('input.datepickerRange.math.title')">
<card
class="has-no-shadow how-it-works-modal"
:title="$t('input.datepickerRange.math.title')">
<p>
{{ $t('input.datepickerRange.math.intro') }}
konrad marked this conversation as resolved Outdated

The naming of this feels wrong now that it's not part of the component anymore.
If this help is specific to datepickerRange maybe we should also show that via the component name.

The naming of this feels wrong now that it's not part of the component anymore. If this help is specific to datepickerRange maybe we should also show that via the component name.

Changed!

Changed!
</p>
@ -12,12 +13,14 @@
</p>
<p>
<i18n-t keypath="input.datepickerRange.math.similar">
<a href="https://grafana.com/docs/grafana/latest/dashboards/time-range-controls/"
rel="noreferrer noopener nofollow" target="_blank">
<a
konrad marked this conversation as resolved Outdated

use BaseButton

use BaseButton

Done.

Done.
href="https://grafana.com/docs/grafana/latest/dashboards/time-range-controls/"
rel="noreferrer noopener nofollow" target="_blank">
konrad marked this conversation as resolved Outdated

Remove rel attribute here and below.
Show we also add target="_blank" as default for the BaseButton is a link case?

Remove rel attribute here and below. Show we also add `target="_blank"` as default for the BaseButton is a link case?

Show we also add target="_blank" as default for the BaseButton is a link case?

Mh I think there will still be cases where we want to control this so right now I think we should not add one.

> Show we also add target="_blank" as default for the BaseButton is a link case? Mh I think there will still be cases where we want to control this so right now I think we should not add one.
Grafana
</a>
<a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.3/common-options.html#date-math"
rel="noreferrer noopener nofollow" target="_blank">
<a
konrad marked this conversation as resolved Outdated

use BaseButton

use BaseButton
href="https://www.elastic.co/guide/en/elasticsearch/reference/7.3/common-options.html#date-math"
rel="noreferrer noopener nofollow" target="_blank">
Elasticsearch
</a>
</i18n-t>

View File

@ -256,7 +256,7 @@ const router = createRouter({
dateTo: parseDateOrString(route.query.to, getNextWeekDate()),
showNulls: route.query.showNulls === 'true',
showOverdue: route.query.showOverdue === 'true',
})
}),
},
{
path: '/lists/new/:namespaceId/',

View File

@ -5,7 +5,7 @@
</h3>
<p v-if="!showAll" class="show-tasks-options">
<datepicker-with-range @dateChanged="setDate">
<template #trigger="{toggle, buttonText}">
<template #trigger="{toggle}">
<x-button @click.prevent.stop="toggle()" variant="primary" :shadow="false" class="mb-2">
{{ $t('task.show.select') }}
</x-button>
@ -46,8 +46,7 @@
<script setup lang="ts">
import SingleTaskInList from '@/components/tasks/partials/singleTaskInList.vue'
import {parseDateOrString} from '@/helpers/time/parseDateOrString'
import {mapState, useStore} from 'vuex'
import {useStore} from 'vuex'
import {computed, ref, watchEffect} from 'vue'
import Fancycheckbox from '@/components/input/fancycheckbox.vue'
@ -73,6 +72,8 @@ const showNothingToDo = ref<boolean>(false)
setTimeout(() => showNothingToDo.value = true, 100)
// NOTE: You MUST provide either dateFrom and dateTo OR showAll for the component to actually show tasks.
// Linting disabled because we explicitely enabled destructuring in vite's config, this will work.
konrad marked this conversation as resolved Outdated

Wouldn't it be better to make showAll a computed that gets autoset when dateFrom and dateTo doesn't contain a value?

Wouldn't it be better to make showAll a computed that gets autoset when dateFrom and dateTo doesn't contain a value?

Excellent idea. Changed it!

Excellent idea. Changed it!
// eslint-disable-next-line vue/no-setup-props-destructure
const {
dateFrom,
dateTo,
@ -128,7 +129,7 @@ const tasksSorted = computed(() => {
...tasksWithoutDueDate,
]
})
const hasTasks = computed(() => tasks && tasks.value.length > 0)
const hasTasks = computed(() => tasks.value && tasks.value.length > 0)
const userAuthenticated = computed(() => store.state.auth.authenticated)
const loading = computed(() => store.state[LOADING] && store.state[LOADING_MODULE] === 'tasks')
@ -173,7 +174,7 @@ async function loadPendingTasks(from: string, to: string) {
// Since this route is authentication only, users would get an error message if they access the page unauthenticated.
konrad marked this conversation as resolved Outdated

This should be marked as a Hack because it's something that shouldn't happen.
When I tried to change the auth these days I tried to fix this, but got tangled.
We should try to solve this in the future because else we will just add more and more hacks =)

This should be marked as a Hack because it's something that shouldn't happen. When I tried to change the auth these days I tried to fix this, but got tangled. We should try to solve this in the future because else we will just add more and more hacks =)

Done.

Done.
// Since this component is mounted as the home page before unauthenticated users get redirected
// to the login page, they will almost always see the error message.
if (!userAuthenticated) {
if (!userAuthenticated.value) {
return
}