Skip to content

Commit

Permalink
Merge branch 'opensearch-project:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kavilla authored Apr 22, 2022
2 parents 2d85f21 + 376ba8c commit c560fd4
Show file tree
Hide file tree
Showing 216 changed files with 1,842 additions and 11,680 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ target
/packages/osd-test/src/functional_test_runner/__tests__/fixtures/
/packages/osd-test/src/functional_test_runner/lib/config/__tests__/fixtures/
/packages/osd-ui-framework/dist
/packages/osd-ui-framework/doc_site/build
/packages/osd-ui-shared-deps/flot_charts
2 changes: 0 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ module.exports = {
{
files: [
'**/public/**/*.js',
'packages/osd-ui-framework/doc_site/src/**/*.js',
'src/fixtures/**/*.js', // TODO: this directory needs to be more obviously "public" (or go away)
],
settings: {
Expand Down Expand Up @@ -440,7 +439,6 @@ module.exports = {
{
files: [
'packages/osd-ui-framework/**/*.test.js',
'packages/osd-ui-framework/doc_site/**/*.js',
'packages/osd-ui-framework/Gruntfile.js',
'packages/osd-opensearch/src/**/*.js',
'packages/osd-interpreter/tasks/**/*.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,19 @@ jobs:
id: linter
run: yarn lint

- name: Run unit tests
- name: Run unit tests with coverage
id: unit-tests
run: yarn test:jest:ci
run: yarn test:jest:ci:coverage

- name: Run mocha tests
- name: Run mocha tests with coverage
id: mocha-tests
run: yarn test:mocha
run: yarn test:mocha:coverage

- name: Upload Code Coverage
id: upload-code-coverage
uses: codecov/codecov-action@v3
with:
directory: ./target/opensearch-dashboards-coverage

- name: Run integration tests
id: integration-tests
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ selenium
*.swp
*.swo
*.out
/packages/osd-ui-framework/doc_site/build/*
!/packages/osd-ui-framework/doc_site/build/index.html
package-lock.json
.yo-rc.json
.vscode
Expand Down
12 changes: 7 additions & 5 deletions bwctest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

set -e

DEFAULT_VERSIONS="osd-1.1.0,odfe-1.13.2,odfe-0.10.0"
DEFAULT_VERSIONS="osd-1.1.0,odfe-1.13.2,odfe-1.0.2"

function usage() {
echo ""
Expand Down Expand Up @@ -79,16 +79,18 @@ done
# If no OpenSearch build was passed then this constructs the version
if [ -z "$OPENSEARCH" ]; then
IFS='/' read -ra SLASH_ARR <<< "$DASHBOARDS"
# Expected to be opensearch-x.y.z-platform-arch.tar.gz
# Expected to be opensearch-x.y.z-platform-arch.tar.gz or opensearch-x.y.z-qualifier-platform-arch.tar.gz
# Playground is supported path to enable sandbox testing
[[ "$DASHBOARDS" == *"Playground"* ]] && TARBALL="${SLASH_ARR[14]}" || TARBALL="${SLASH_ARR[13]}"
IFS='-' read -ra DASH_ARR <<< "$TARBALL"
# If it contains a qualifer it will be length of 6
[[ ${#DASH_ARR[@]} == 6 ]] && HAS_QUALIFER=true || HAS_QUALIFER=false
# Expected to be arch.tar.gz
DOTS="${DASH_ARR[4]}"
[ $HAS_QUALIFER == true ] && DOTS="${DASH_ARR[5]}" || DOTS="${DASH_ARR[4]}"
IFS='.' read -ra DOTS_ARR <<< "$DOTS"

VERSION="${DASH_ARR[2]}"
PLATFORM="${DASH_ARR[3]}"
[ $HAS_QUALIFER == true ] && VERSION="${DASH_ARR[2]}-${DASH_ARR[3]}" || VERSION="${DASH_ARR[2]}"
[ $HAS_QUALIFER == true ] && PLATFORM="${DASH_ARR[4]}" || PLATFORM="${DASH_ARR[3]}"
ARCH="${DOTS_ARR[0]}"

OPENSEARCH="https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/$VERSION/latest/$PLATFORM/$ARCH/tar/dist/opensearch/opensearch-$VERSION-$PLATFORM-$ARCH.tar.gz"
Expand Down
12 changes: 12 additions & 0 deletions examples/expressions_example/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

module.exports = {
root: true,
extends: ['@elastic/eslint-config-kibana', 'plugin:@elastic/eui/recommended'],
rules: {
'@osd/eslint/require-license-header': 'off',
},
};
7 changes: 7 additions & 0 deletions examples/expressions_example/.i18nrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"prefix": "expressionsExample",
"paths": {
"expressionsExample": "."
},
"translations": ["translations/ja-JP.json"]
}
11 changes: 11 additions & 0 deletions examples/expressions_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# expressions_example

An OpenSearch Dashboards example plugin to demonstrate the expressions plugin

---

## Development

See the [OpenSearch Dashboards contributing
guide](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/master/CONTRIBUTING.md) for instructions
setting up your development environment.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export * from './quick_form_fn';
export * from './quick_form_renderer';
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import {
ExpressionFunctionDefinition,
Render,
} from '../../../../../src/plugins/expressions/public';
import { QuickFormRenderValue } from './quick_form_renderer';

type Arguments = QuickFormRenderValue;

export const quickFormFn = (): ExpressionFunctionDefinition<
'quick-form',
unknown,
Arguments,
Render<QuickFormRenderValue>
> => ({
name: 'quick-form',
type: 'render',
help: i18n.translate('expressionsExample.function.avatar.help', {
defaultMessage: 'Render a simple form that sends the value back as an event on click',
}),
args: {
label: {
types: ['string'],
help: i18n.translate('expressionsExample.function.form.args.label.help', {
defaultMessage: 'Form label',
}),
default: i18n.translate('expressionsExample.function.form.args.label.default', {
defaultMessage: 'Input',
}),
},
buttonLabel: {
types: ['string'],
help: i18n.translate('expressionsExample.function.form.args.buttonLabel.help', {
defaultMessage: 'Button label',
}),
default: i18n.translate('expressionsExample.function.form.args.buttonLabel.default', {
defaultMessage: 'Submit',
}),
},
},
fn: (input, args) => {
return {
type: 'render',
as: 'quick-form-renderer',
value: { ...args },
};
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React, { useCallback, useState } from 'react';
import { EuiForm, EuiFormRow, EuiButton, EuiFieldText } from '@elastic/eui';
import { i18n } from '@osd/i18n';
import { render, unmountComponentAtNode } from 'react-dom';
import { ExpressionRenderDefinition } from '../../../../../src/plugins/expressions/public';

export interface QuickFormRenderValue {
label: string;
buttonLabel: string;
}

export const quickFormRenderer: ExpressionRenderDefinition<QuickFormRenderValue> = {
name: 'quick-form-renderer',
displayName: i18n.translate('expressionsExample.form.render.help', {
defaultMessage: 'Render a simple input form',
}),
reuseDomNode: true,
render: (domNode, config, handlers) => {
handlers.onDestroy(() => {
unmountComponentAtNode(domNode);
});

render(
<QuickForm
{...config}
onSubmit={(value) =>
handlers.event({
data: value,
})
}
/>,
domNode,
handlers.done
);
},
};

interface QuickFormProps extends QuickFormRenderValue {
onSubmit: Function;
}

const QuickForm = ({ onSubmit, buttonLabel, label }: QuickFormProps) => {
const [value, setValue] = useState('');
const handleClick = useCallback(() => {
onSubmit(value);
}, [onSubmit, value]);

return (
<EuiForm>
<EuiFormRow label={label}>
<EuiFieldText value={value} onChange={(e) => setValue(e.target.value)} />
</EuiFormRow>
<EuiButton onClick={handleClick}>{buttonLabel}</EuiButton>
</EuiForm>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export * from './sleep';
export * from './square';
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import { ExpressionFunctionDefinition } from '../../../../../src/plugins/expressions/public';

interface Arguments {
time: number;
}

export const sleep = (): ExpressionFunctionDefinition<'sleep', any, Arguments, any> => ({
name: 'sleep',
help: i18n.translate('expressionsExample.function.sleep.help', {
defaultMessage: 'Generates range object',
}),
args: {
time: {
types: ['number'],
help: i18n.translate('expressionsExample.function.sleep.time.help', {
defaultMessage: 'Time for settimeout',
}),
required: false,
},
},
fn: async (input, args, context) => {
await new Promise((r) => setTimeout(r, args.time));
return input;
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import { ExpressionFunctionDefinition } from '../../../../../src/plugins/expressions/public';

export const square = (): ExpressionFunctionDefinition<'square', number, {}, any> => ({
name: 'square',
help: i18n.translate('expressionsExample.function.square.help', {
defaultMessage: 'Squares the input',
}),
args: {},
fn: async (input, args, context) => {
return input * input;
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export * from './basic';
export * from './render';
export * from './action';
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import {
ExpressionFunctionDefinition,
Render,
} from '../../../../../src/plugins/expressions/public';
import { AvatarRenderValue } from './avatar_renderer';

type Arguments = AvatarRenderValue;

export const avatarFn = (): ExpressionFunctionDefinition<
'avatar',
unknown,
Arguments,
Render<AvatarRenderValue>
> => ({
name: 'avatar',
type: 'render',
help: i18n.translate('expressionsExample.function.avatar.help', {
defaultMessage: 'Avatar expression function',
}),
args: {
name: {
types: ['string'],
help: i18n.translate('expressionsExample.function.avatar.args.name.help', {
defaultMessage: 'Enter Name',
}),
required: true,
},
size: {
types: ['string'],
help: i18n.translate('expressionsExample.function.avatar.args.size.help', {
defaultMessage: 'Size of the avatar',
}),
default: 'l',
},
},
fn: (input, args) => {
return {
type: 'render',
as: 'avatar',
value: {
name: args.name,
size: args.size,
},
};
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { EuiAvatar, EuiAvatarProps } from '@elastic/eui';
import { i18n } from '@osd/i18n';
import { render, unmountComponentAtNode } from 'react-dom';
import { ExpressionRenderDefinition } from '../../../../../src/plugins/expressions/public';

export interface AvatarRenderValue {
name: string;
size: EuiAvatarProps['size'];
}

export const avatar: ExpressionRenderDefinition<AvatarRenderValue> = {
name: 'avatar',
displayName: i18n.translate('expressionsExample.render.help', {
defaultMessage: 'Render an avatar',
}),
reuseDomNode: true,
render: (domNode, { name, size }, handlers) => {
handlers.onDestroy(() => {
unmountComponentAtNode(domNode);
});

render(<EuiAvatar size={size} name={name} />, domNode, handlers.done);
},
};
Loading

0 comments on commit c560fd4

Please sign in to comment.