Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 35 additions & 29 deletions src/devtools/active-query-panel/ActiveQueryPanel.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { defineComponent, PropType, h } from "vue-demi";
import { defineComponent, PropType, h, isVue2 } from "vue-demi";

import type { Query } from "react-query/types";

Expand All @@ -17,6 +17,38 @@ export default defineComponent({
},
},
render() {
const dataExplorer = h(Explorer, {
// Vue3
label: "Data",
value: this.$props.query.state.data,
defaultExpanded: true,
// Vue2
props: {
label: "Data",
value: this.$props.query.state.data,
defaultExpanded: true,
},
});
const dataExplorerSlot = isVue2
? [dataExplorer]
: { default: () => dataExplorer };

const queryExplorer = h(Explorer, {
// Vue3
label: "Query",
value: this.$props.query,
defaultExpanded: { queryKey: true },
// Vue2
props: {
label: "Query",
value: this.$props.query,
defaultExpanded: { queryKey: true },
},
});
const queryExplorerSlot = isVue2
? [queryExplorer]
: { default: () => queryExplorer };

return h(
"div",
{
Expand Down Expand Up @@ -49,20 +81,7 @@ export default defineComponent({
title: "Data Explorer",
},
},
[
h(Explorer, {
// Vue3
label: "Data",
value: this.$props.query.state.data,
defaultExpanded: true,
// Vue2
props: {
label: "Data",
value: this.$props.query.state.data,
defaultExpanded: true,
},
}),
]
dataExplorerSlot
),
h(
InfoPanel,
Expand All @@ -74,20 +93,7 @@ export default defineComponent({
title: "Query Explorer",
},
},
[
h(Explorer, {
// Vue3
label: "Query",
value: this.$props.query,
defaultExpanded: { queryKey: true },
// Vue2
props: {
label: "Query",
value: this.$props.query,
defaultExpanded: { queryKey: true },
},
}),
]
queryExplorerSlot
),
]
);
Expand Down
181 changes: 92 additions & 89 deletions src/devtools/active-query-panel/QueryActions.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { computed, defineComponent, PropType, h } from "vue-demi";
import { computed, defineComponent, PropType, h, isVue2 } from "vue-demi";

import type { Query } from "react-query/types";

Expand Down Expand Up @@ -44,6 +44,96 @@ export default defineComponent({
};
},
render() {
const actions = [
h(
"button",
{
class: "action-button",
style: {
background: this.isFetching
? this.theme.grayAlt
: this.theme.active,
cursor: this.isFetching ? "not-allowed" : "pointer",
},
// Vue3
type: "button",
disabled: this.isFetching,
onClick: this.doFetch,
// Vue2
attrs: {
type: "button",
disabled: this.isFetching,
},
on: {
click: this.doFetch,
},
},
"Refetch"
),
h(
"button",
{
class: "action-button",
style: {
background: this.theme.warning,
color: this.theme.inputTextColor,
},
// Vue3
type: "button",
onClick: this.doInvalidate,
// Vue2
attrs: {
type: "button",
},
on: {
click: this.doInvalidate,
},
},
"Invalidate"
),
h(
"button",
{
class: "action-button",
style: {
background: this.theme.gray,
},
// Vue3
type: "button",
onClick: this.doReset,
// Vue2
attrs: {
type: "button",
},
on: {
click: this.doReset,
},
},
"Reset"
),
h(
"button",
{
class: "action-button",
style: {
background: this.theme.danger,
},
// Vue3
type: "button",
onClick: this.doRemove,
// Vue2
attrs: {
type: "button",
},
on: {
click: this.doRemove,
},
},
"Remove"
),
];
const actionsSlot = isVue2 ? actions : { default: () => actions };

return h(
InfoPanel,
{
Expand All @@ -54,94 +144,7 @@ export default defineComponent({
title: "Actions",
},
},
[
h(
"button",
{
class: "action-button",
style: {
background: this.isFetching
? this.theme.grayAlt
: this.theme.active,
cursor: this.isFetching ? "not-allowed" : "pointer",
},
// Vue3
type: "button",
disabled: this.isFetching,
onClick: this.doFetch,
// Vue2
attrs: {
type: "button",
disabled: this.isFetching,
},
on: {
click: this.doFetch,
},
},
"Refetch"
),
h(
"button",
{
class: "action-button",
style: {
background: this.theme.warning,
color: this.theme.inputTextColor,
},
// Vue3
type: "button",
onClick: this.doInvalidate,
// Vue2
attrs: {
type: "button",
},
on: {
click: this.doInvalidate,
},
},
"Invalidate"
),
h(
"button",
{
class: "action-button",
style: {
background: this.theme.gray,
},
// Vue3
type: "button",
onClick: this.doReset,
// Vue2
attrs: {
type: "button",
},
on: {
click: this.doReset,
},
},
"Reset"
),
h(
"button",
{
class: "action-button",
style: {
background: this.theme.danger,
},
// Vue3
type: "button",
onClick: this.doRemove,
// Vue2
attrs: {
type: "button",
},
on: {
click: this.doRemove,
},
},
"Remove"
),
]
actionsSlot
);
},
});
Expand Down
82 changes: 42 additions & 40 deletions src/devtools/active-query-panel/QueryDetails.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { computed, defineComponent, PropType, h } from "vue-demi";
import { computed, defineComponent, PropType, h, isVue2 } from "vue-demi";

import type { Query } from "react-query/types";

Expand Down Expand Up @@ -38,6 +38,46 @@ export default defineComponent({
};
},
render() {
const details = [
h("div", { class: "details-info-line" }, [
h(
"code",
{
class: "details-code",
},
[h("pre", { class: "details-pre" }, this.formattedQueryKey)]
),
h(
"span",
{
class: "details-span",
style: { background: this.statusBackground },
},
this.queryStatusLabel
),
]),
h("div", { class: "details-info-line" }, [
"Observers:",
h(
"code",
{
class: "details-code",
},
this.observersCount
),
]),
h("div", { class: "details-info-line" }, [
"Last Updated:",
h(
"code",
{
class: "details-code",
},
this.updateDate
),
]),
];
const detailsSlot = isVue2 ? details : { default: () => details };
return h(
InfoPanel,
{
Expand All @@ -48,45 +88,7 @@ export default defineComponent({
title: "Query Details",
},
},
[
h("div", { class: "details-info-line" }, [
h(
"code",
{
class: "details-code",
},
[h("pre", { class: "details-pre" }, this.formattedQueryKey)]
),
h(
"span",
{
class: "details-span",
style: { background: this.statusBackground },
},
this.queryStatusLabel
),
]),
h("div", { class: "details-info-line" }, [
"Observers:",
h(
"code",
{
class: "details-code",
},
this.observersCount
),
]),
h("div", { class: "details-info-line" }, [
"Last Updated:",
h(
"code",
{
class: "details-code",
},
this.updateDate
),
]),
]
detailsSlot
);
},
});
Expand Down