fix: make sure stepCycle exists before calling (#1509)

* fix: make sure checking stepCycle func exist before calling

* fix: make sure stepCycle func exist before calling

* fix: also check if app exist

* fix: add return

* fix: make sure checking stepCycle func exist before calling

* fix: make sure stepCycle func exist before calling

* fix: also check if app exist

* fix: add return

* chore: update engima and schema version

* test: unit test

* fix: remove engine version

---------

Co-authored-by: caele <tsm@qlik.com>
This commit is contained in:
linhnguyen-qlik
2024-03-18 11:26:07 +01:00
committed by GitHub
parent bfa2486472
commit e29328cae3
16 changed files with 61 additions and 26 deletions

View File

@@ -16,4 +16,4 @@
"@babel/core": "7.24.0",
"parcel": "^2.12.0"
}
}
}

View File

@@ -1,5 +1,5 @@
import enigma from 'enigma.js';
import qixSchema from 'enigma.js/schemas/12.1657.0.json';
import qixSchema from 'enigma.js/schemas/12.2015.0.json';
import { embed } from '@nebula.js/stardust';
import mekko from '@nebula.js/sn-mekko-chart';

View File

@@ -1,5 +1,6 @@
import CyclicIcon from '@nebula.js/ui/icons/cyclic';
import DrillDownIcon from '@nebula.js/ui/icons/drill-down';
import CyclicIcon from '@nebula.js/ui/icons/reload';
import ReloadIcon from '@nebula.js/ui/icons/reload';
const dimensionTypes = {
single: 'N',
@@ -17,16 +18,23 @@ const createDimensionIconData = (dimInfo, app) => {
};
case dimensionTypes.cyclic:
return {
icon: CyclicIcon,
icon: app ? ReloadIcon : CyclicIcon,
tooltip: 'Listbox.Cyclic',
onClick: () => {
app
.getDimension(dimInfo.qLibraryId)
.then((dimensionModel) => {
dimensionModel.stepCycle(1);
})
.catch(() => null);
},
onClick: app
? () => {
app
.getDimension(dimInfo.qLibraryId)
.then((dimensionModel) => {
if (!dimensionModel.stepCycle) {
// eslint-disable-next-line no-console
console.log("engine api spec version doesn't have support for function stepCycle");
return;
}
dimensionModel.stepCycle(1);
})
.catch(() => null);
}
: undefined,
};
default:
return undefined;

View File

@@ -1,5 +1,6 @@
import DrillDownIcon from '@nebula.js/ui/icons/drill-down';
import CyclicIcon from '@nebula.js/ui/icons/reload';
import ReloadIcon from '@nebula.js/ui/icons/reload';
import CyclicIcon from '@nebula.js/ui/icons/cyclic';
import utils from '../ListBoxHeader/icon-utils';
describe('icon-utils', () => {
@@ -19,14 +20,25 @@ describe('icon-utils', () => {
});
});
it('should return no icon data for cyclic dimension', () => {
it('should return icon data for cyclic dimension', () => {
const dimInfo = { qGrouping: 'C' };
const app = {};
const result = utils.createDimensionIconData(dimInfo, app);
expect(result).toMatchObject({
icon: CyclicIcon,
icon: ReloadIcon,
tooltip: 'Listbox.Cyclic',
onClick: expect.any(Function),
});
});
it('should return non interactive icon data for cyclic dimension when there is no app', () => {
const dimInfo = { qGrouping: 'C' };
const app = undefined;
const result = utils.createDimensionIconData(dimInfo, app);
expect(result).toMatchObject({
icon: CyclicIcon,
tooltip: 'Listbox.Cyclic',
onClick: undefined,
});
});
});

View File

@@ -1,5 +1,5 @@
import enigma from 'enigma.js';
import schema from 'enigma.js/schemas/12.1657.0.json';
import schema from 'enigma.js/schemas/12.2015.0.json';
import { Auth, AuthType } from '@qlik/sdk';
export default class Authenticator {

View File

@@ -73,4 +73,4 @@
"react-dom": "18.2.0",
"react-router-dom": "6.22.3"
}
}
}

View File

@@ -1,6 +1,6 @@
import * as SDK from '@qlik/sdk';
import * as ENIGMA from 'enigma.js';
import qixSchema from 'enigma.js/schemas/12.1657.0.json';
import qixSchema from 'enigma.js/schemas/12.2015.0.json';
import * as SenseUtilities from 'enigma.js/sense-utilities';
import { connect, openApp, getConnectionInfo, getParams, parseEngineURL } from '../connect';

View File

@@ -1,5 +1,5 @@
import enigma from 'enigma.js';
import qixSchema from 'enigma.js/schemas/12.1657.0.json';
import qixSchema from 'enigma.js/schemas/12.2015.0.json';
import SenseUtilities from 'enigma.js/sense-utilities';
import { Auth, AuthType } from '@qlik/sdk';

View File

@@ -1,7 +1,7 @@
import { renderHook, act } from '@testing-library/react';
import * as ENIGMA from 'enigma.js';
import * as SenseUtilities from 'enigma.js/sense-utilities';
import qixSchema from 'enigma.js/schemas/12.1657.0.json';
import qixSchema from 'enigma.js/schemas/12.2015.0.json';
import { useOpenApp } from '../useOpenApp';
import * as getAuthInstanceModule from '../../connect';

View File

@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import enigma from 'enigma.js';
import qixSchema from 'enigma.js/schemas/12.1657.0.json';
import qixSchema from 'enigma.js/schemas/12.2015.0.json';
import SenseUtilities from 'enigma.js/sense-utilities';
import { getAuthInstance } from '../connect';

View File

@@ -2,7 +2,7 @@ import enigma from 'enigma.js';
export default function connect() {
const loadSchema = () =>
fetch('https://unpkg.com/enigma.js/schemas/12.1657.0.json').then((response) => response.json());
fetch('https://unpkg.com/enigma.js/schemas/12.2015.0.json').then((response) => response.json());
const createConnection = () =>
loadSchema().then((schema) =>

View File

@@ -42,7 +42,7 @@ import enigma from 'enigma.js';
export default function connect() {
const loadSchema = () =>
fetch('https://unpkg.com/enigma.js/schemas/12.1657.0.json').then((response) => response.json());
fetch('https://unpkg.com/enigma.js/schemas/12.2015.0.json').then((response) => response.json());
const localApp = '/apps/Ctrl-00.qvf';
const createConnection = () =>

View File

@@ -2,7 +2,7 @@ import enigma from 'enigma.js';
export default function connect() {
const loadSchema = () =>
fetch('https://unpkg.com/enigma.js/schemas/12.1657.0.json').then((response) => response.json());
fetch('https://unpkg.com/enigma.js/schemas/12.2015.0.json').then((response) => response.json());
const createConnection = () =>
loadSchema().then((schema) =>

View File

@@ -1,6 +1,6 @@
window.connect = function connect() {
const loadSchema = () =>
fetch('https://unpkg.com/enigma.js/schemas/12.1657.0.json').then((response) => response.json());
fetch('https://unpkg.com/enigma.js/schemas/12.2015.0.json').then((response) => response.json());
const createConnection = () =>
loadSchema().then((schema) =>

View File

@@ -107,4 +107,4 @@
"apis/*",
"test/component/*"
]
}
}

View File

@@ -0,0 +1,15 @@
import SvgIcon from './SvgIcon';
const cyclic = (props) => ({
...props,
shapes: [
{
type: 'path',
attrs: {
d: 'M 6 2 h 10 V 1 H 6 Z m 5 5 h 5 V 6 h -5 Z m 5 5 h -5 v -1 h 5 Z M 5 10 h 1 v 2.663 a 3.5 3.5 0 1 0 -2.922 0.036 l -0.406 0.914 A 4.501 4.501 0 1 1 7.329 13 H 9 v 1 H 5 Z',
},
},
],
});
export default (props) => SvgIcon(cyclic(props));
export { cyclic };