forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Canvas] Expression reveal image. (elastic#101987)
* expression_reveal_image skeleton. * expression_functions added. * expression_renderers added. * Backup of daily work. * Fixed errors. * Added legacy support. Added button for legacy. * Added storybook. * Removed revealImage from canvas. * setState while rendering error fixed. * tsconfig.json added. * jest.config.js added. * Demo doc added. * Types fixed. * added limits. * Removed not used imports. * i18n namespaces fixed. * Fixed test suite error. * Some errors fixed. * Fixed eslint error. * Removed more unused translations. * Moved UI and elements, related to expressionRevealImage from canvas. * Fixed unused translations errors. * Moved type of element to types. * Fixed types and added service for representing elements, ui and supported renderers to canvas. * Added expression registration to canvas. * Fixed * Fixed mutiple call of the function. * Removed support of a legacy lib for revealImage chart. * Removed legacy presentation_utils plugin import. * Doc error fixed. * Removed useless translations and tried to fix error. * One more fix. * Small imports fix. * Fixed translations. * Made fixes based on nits. * Removed useless params. * fix. * Fixed errors, related to jest and __mocks__. * Removed useless type definition. * Replaced RendererHandlers with IInterpreterRendererHandlers. * fixed supported_shareable. * Moved elements back to canvas. * Moved views to canvas, removed expression service and imported renderer to canvas. * Fixed translations. * Types fix. * Moved libs to presentation utils. * Fixed one mistake. * removed dataurl lib. * Fixed jest files. * elasticLogo removed. * Removed elastic_outline. * removed httpurl. * Removed missing_asset. * removed url. * replaced mostly all tests. * Fixed types. * Fixed types and removed function_wrapper.ts * Fixed types of test helpers. * Changed limits of presentationUtil plugin. * Fixed imports. * One more fix. * Fixed huge size of bundle. * Reduced allow limit for presentationUtil * Updated limits for presentationUtil. * Fixed public API. * fixed type errors. * Moved css to component. * Fixed spaces at element. * Changed order of requiredPlugins. * Updated limits. * Removed unused plugin. * Added rule for allowing import from __stories__ directory. * removed useless comment. * Changed readme.md * Fixed docs error. * A possible of smoke test. * onResize changed to useResizeObserver. * Remove useless events and `useEffect` block. * Changed from passing handlers to separate functions. * `function` moved to `server`. * Fixed eslint error. Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
15abbff
commit 8fbcab4
Showing
159 changed files
with
1,311 additions
and
512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"prefix": "expressionRevealImage", | ||
"paths": { | ||
"expressionRevealImage": "." | ||
}, | ||
"translations": ["translations/ja-JP.json"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
// eslint-disable-next-line import/no-commonjs | ||
module.exports = require('@kbn/storybook').defaultConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# expressionRevealImage | ||
|
||
Expression Reveal Image plugin adds a `revealImage` function to the expression plugin and an associated renderer. The renderer will display the given percentage of a given image. | ||
|
||
--- | ||
|
||
## Development | ||
|
||
See the [kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) for instructions setting up your development environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
export const PLUGIN_ID = 'expressionRevealImage'; | ||
export const PLUGIN_NAME = 'expressionRevealImage'; |
13 changes: 13 additions & 0 deletions
13
src/plugins/expression_reveal_image/common/expression_functions/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { revealImageFunction } from './reveal_image_function'; | ||
|
||
export const functions = [revealImageFunction]; | ||
|
||
export { revealImageFunction }; |
168 changes: 168 additions & 0 deletions
168
src/plugins/expression_reveal_image/common/expression_functions/reveal_image.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { | ||
functionWrapper, | ||
elasticOutline, | ||
elasticLogo, | ||
} from '../../../presentation_util/common/lib'; | ||
import { getFunctionErrors } from '../i18n'; | ||
import { revealImageFunction } from './reveal_image_function'; | ||
import { Origin } from '../types'; | ||
import { ExecutionContext } from 'src/plugins/expressions'; | ||
|
||
const errors = getFunctionErrors().revealImage; | ||
|
||
describe('revealImageFunction', () => { | ||
const fn = functionWrapper(revealImageFunction); | ||
|
||
it('returns a render as revealImage', () => { | ||
const result = fn( | ||
0.5, | ||
{ | ||
image: null, | ||
emptyImage: null, | ||
origin: Origin.BOTTOM, | ||
}, | ||
{} as ExecutionContext | ||
); | ||
expect(result).toHaveProperty('type', 'render'); | ||
expect(result).toHaveProperty('as', 'revealImage'); | ||
}); | ||
|
||
describe('context', () => { | ||
it('throws when context is not a number between 0 and 1', () => { | ||
expect(() => { | ||
fn( | ||
10, | ||
{ | ||
image: elasticLogo, | ||
emptyImage: elasticOutline, | ||
origin: Origin.TOP, | ||
}, | ||
{} as ExecutionContext | ||
); | ||
}).toThrow(new RegExp(errors.invalidPercent(10).message)); | ||
|
||
expect(() => { | ||
fn( | ||
-0.1, | ||
{ | ||
image: elasticLogo, | ||
emptyImage: elasticOutline, | ||
origin: Origin.TOP, | ||
}, | ||
{} as ExecutionContext | ||
); | ||
}).toThrow(new RegExp(errors.invalidPercent(-0.1).message)); | ||
}); | ||
}); | ||
|
||
describe('args', () => { | ||
describe('image', () => { | ||
it('sets the image', () => { | ||
const result = fn( | ||
0.89, | ||
{ | ||
emptyImage: null, | ||
origin: Origin.TOP, | ||
image: elasticLogo, | ||
}, | ||
{} as ExecutionContext | ||
).value; | ||
expect(result).toHaveProperty('image', elasticLogo); | ||
}); | ||
|
||
it('defaults to the Elastic outline logo', () => { | ||
const result = fn( | ||
0.89, | ||
{ | ||
emptyImage: null, | ||
origin: Origin.TOP, | ||
image: null, | ||
}, | ||
{} as ExecutionContext | ||
).value; | ||
expect(result).toHaveProperty('image', elasticOutline); | ||
}); | ||
}); | ||
|
||
describe('emptyImage', () => { | ||
it('sets the background image', () => { | ||
const result = fn( | ||
0, | ||
{ | ||
emptyImage: elasticLogo, | ||
origin: Origin.TOP, | ||
image: null, | ||
}, | ||
{} as ExecutionContext | ||
).value; | ||
expect(result).toHaveProperty('emptyImage', elasticLogo); | ||
}); | ||
|
||
it('sets emptyImage to null', () => { | ||
const result = fn( | ||
0, | ||
{ | ||
emptyImage: null, | ||
origin: Origin.TOP, | ||
image: null, | ||
}, | ||
{} as ExecutionContext | ||
).value; | ||
expect(result).toHaveProperty('emptyImage', null); | ||
}); | ||
}); | ||
|
||
describe('origin', () => { | ||
it('sets which side to start the reveal from', () => { | ||
let result = fn( | ||
1, | ||
{ | ||
emptyImage: null, | ||
origin: Origin.TOP, | ||
image: null, | ||
}, | ||
{} as ExecutionContext | ||
).value; | ||
expect(result).toHaveProperty('origin', 'top'); | ||
result = fn( | ||
1, | ||
{ | ||
emptyImage: null, | ||
origin: Origin.LEFT, | ||
image: null, | ||
}, | ||
{} as ExecutionContext | ||
).value; | ||
expect(result).toHaveProperty('origin', 'left'); | ||
result = fn( | ||
1, | ||
{ | ||
emptyImage: null, | ||
origin: Origin.BOTTOM, | ||
image: null, | ||
}, | ||
{} as ExecutionContext | ||
).value; | ||
expect(result).toHaveProperty('origin', 'bottom'); | ||
result = fn( | ||
1, | ||
{ | ||
emptyImage: null, | ||
origin: Origin.RIGHT, | ||
image: null, | ||
}, | ||
{} as ExecutionContext | ||
).value; | ||
expect(result).toHaveProperty('origin', 'right'); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/plugins/expression_reveal_image/common/i18n/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export const BASE64 = '`base64`'; | ||
export const URL = 'URL'; |
Oops, something went wrong.