Skip to content

Commit

Permalink
Merge pull request #1289 from merico-dev/1287-after-importing-partial…
Browse files Browse the repository at this point in the history
…-dashboard-querys-runby-condition-contains-invalid-value

1287 after importing partial dashboard querys runby condition contains invalid value
  • Loading branch information
GerilLeto authored Nov 27, 2023
2 parents c80d76f + aca7eea commit f0b8354
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/api",
"version": "10.58.0",
"version": "10.58.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
3 changes: 1 addition & 2 deletions api/src/dashboard_migration/handlers/10.41.0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ function upgradePanels(panels: Record<string, any>[]) {
return panels.map((p) => {
const { title, ...rest } = p;
if (typeof title !== 'string') {
console.log(p);
throw new Error(`Unexpected type of panel.title: ${typeof title}`);
return p;
}
const name = title ? title : p.id;
return {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/dashboard",
"version": "10.58.0",
"version": "10.58.1",
"license": "Apache-2.0",
"publishConfig": {
"access": "public",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,37 @@ export const MuteQueryModel = QueryMeta.views((self) => ({
if (!isAlive(self)) {
return [];
}
// @ts-expect-error untyped getRoot(self)
const contentModel = getRoot(self).content;

const { context } = contentModel.payloadForSQL;
const { context } = this.contentModel.payloadForSQL;
const contextOptions: SelectItem[] = Object.keys(context).map((k) => ({
group: 'Context',
label: k,
value: `context.${k}`,
description: undefined,
}));

const filterOptions: SelectItem[] = contentModel.filters.keyLabelOptions.map((o: SelectItem) => ({
const filterOptions: SelectItem[] = this.contentModel.filters.keyLabelOptions.map((o: SelectItem) => ({
group: 'Filters',
label: o.label,
value: `filters.${o.value}`,
description: o.value,
}));

return [...contextOptions, ...filterOptions];
const ret = [...contextOptions, ...filterOptions];
const validValues = new Set(ret.map((r) => r.value));
self.run_by.forEach((c) => {
if (validValues.has(c)) {
return;
}

ret.push({
group: 'Invalid',
label: c,
value: c,
});
});

return ret;
},
get unmetRunByConditions() {
// this computed has dependencies on reactive values outside the model,
Expand All @@ -47,8 +59,7 @@ export const MuteQueryModel = QueryMeta.views((self) => ({
if (run_by.length === 0) {
return [];
}
// @ts-expect-error untyped getRoot(self)
const payload = getRoot(self).content.payloadForSQL;
const payload = this.contentModel.payloadForSQL;

return run_by.filter((c) => {
const value = _.get(payload, c);
Expand Down Expand Up @@ -91,8 +102,7 @@ export const MuteQueryModel = QueryMeta.views((self) => ({
if (react_to.length === 0) {
return '';
}
// @ts-expect-error untyped getRoot(self)
const source = getRoot(self).content.payloadForSQL;
const source = self.contentModel.payloadForSQL;
const payload = [...react_to].reduce((acc, path) => {
acc[path] = _.get(source, path);
return acc;
Expand All @@ -107,14 +117,13 @@ export const MuteQueryModel = QueryMeta.views((self) => ({
if (self.unmetRunByConditions.length === 0) {
return { context: [], filters: [] };
}
// @ts-expect-error untyped getRoot(self)
const { keyLabelMap } = getRoot(self).content.filters;
const { keyLabelMap } = self.contentModel.filters;
const contextNames = self.unmetRunByConditions
.filter((k) => k.startsWith('context.'))
.map((k) => k.split('context.')[0]);
.map((k) => k.replace('context.', ''));
const filterNames = self.unmetRunByConditions
.filter((k) => k.startsWith('filters.'))
.map((k) => _.get({ filters: keyLabelMap }, k))
.map((k) => _.get({ filters: keyLabelMap }, k, k.replace('filters.', '')))
.filter((v) => !!v);
return {
context: contextNames,
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/types/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,5 @@ export const initialDashboardContent: TDashboardContent = {
],
panels: [],
filters: [],
version: '9.19.0',
version: '10.41.0',
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/root",
"version": "10.58.0",
"version": "10.58.1",
"private": true,
"workspaces": [
"api",
Expand Down
2 changes: 1 addition & 1 deletion settings-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/settings-form",
"version": "10.58.0",
"version": "10.58.1",
"license": "Apache-2.0",
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@devtable/website",
"private": true,
"license": "Apache-2.0",
"version": "10.58.0",
"version": "10.58.1",
"scripts": {
"dev": "vite",
"preview": "vite preview"
Expand Down

0 comments on commit f0b8354

Please sign in to comment.