forked from opensearch-project/OpenSearch-Dashboards
-
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.
Signed-off-by: Zelin Hao <zelinhao@amazon.com>
- Loading branch information
Showing
52 changed files
with
4,144 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
**Is your feature request related to a problem?** | ||
A new feature has been added. | ||
|
||
**What solution would you like?** | ||
Document the usage of the new feature. | ||
|
||
**What alternatives have you considered?** | ||
N/A | ||
|
||
**Do you have any additional context?** | ||
See please |
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,42 @@ | ||
name: Create Documentation Issue | ||
on: | ||
pull_request: | ||
types: | ||
- labeled | ||
env: | ||
PR_NUMBER: ${{ github.event.number }} | ||
|
||
jobs: | ||
create-issue: | ||
if: ${{ github.event.label.name == 'needs-documentation' }} | ||
runs-on: ubuntu-latest | ||
name: Create Documentation Issue | ||
steps: | ||
- name: GitHub App token | ||
id: github_app_token | ||
uses: tibdex/github-app-token@v1.5.0 | ||
with: | ||
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
# opensearch-trigger-bot installation ID | ||
installation_id: 22958780 | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Edit the issue template | ||
run: | | ||
echo "https://github.com/opensearch-project/OpenSearch-Dashboards/pull/${{ env.PR_NUMBER }}." >> ./.github/doc_issue_template.md | ||
- name: Create Issue From File | ||
id: create-issue | ||
uses: peter-evans/create-issue-from-file@v4 | ||
with: | ||
title: Add documentation related to new feature | ||
content-filepath: ./.github/doc_issue_template.md | ||
labels: documentation | ||
repository: opensearch-project/documentation-website | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
|
||
- name: Print Issue | ||
run: echo "Created related documentation issue ${{ steps.create-issue.outputs.issue-number }}" |
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,2 @@ | ||
# use stylelint | ||
*.scss |
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,2 @@ | ||
build | ||
target |
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,19 @@ | ||
extends: | ||
- stylelint-config-standard-scss | ||
rules: | ||
# while we still use node-sass, only legacy rgb() notation is allowed | ||
color-function-notation: "legacy" | ||
# recommended to turn off descending specificity since we use a lot of nesting: | ||
# https://stylelint.io/user-guide/rules/list/no-descending-specificity/ | ||
no-descending-specificity: null | ||
# need to use global function/value names from EUI | ||
function-name-case: null | ||
value-keyword-case: null | ||
scss/no-global-function-names: null | ||
# camelCase names | ||
keyframes-name-pattern: "^[a-z][a-zA-Z0-9_-]+$" | ||
selector-class-pattern: "^[a-z][a-zA-Z0-9_-]+$" | ||
selector-id-pattern: "^[a-z][a-zA-Z0-9_-]+$" | ||
scss/at-mixin-pattern: "^[a-z][a-zA-Z0-9_-]+$" | ||
scss/at-function-pattern: "^[a-z][a-zA-Z0-9_-]+$" | ||
scss/dollar-variable-pattern: "^[a-z][a-zA-Z0-9_-]+$" |
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,15 @@ | ||
{ | ||
"scanSettings": { | ||
"configMode": "LOCAL", | ||
"configExternalURL": "", | ||
"projectToken": "", | ||
"baseBranches": [] | ||
}, | ||
"checkRunSettings": { | ||
"vulnerableCheckRunConclusionLevel": "failure", | ||
"displayMode": "diff" | ||
}, | ||
"issueSettings": { | ||
"minSeverityLevel": "LOW" | ||
} | ||
} |
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,15 @@ | ||
#!/bin/bash | ||
|
||
# Copyright OpenSearch Contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -e | ||
|
||
PACKAGE_VERSION=$(cat package.json \ | ||
| grep version \ | ||
| head -1 \ | ||
| awk -F: '{ print $2 }' \ | ||
| sed 's/[",]//g' \ | ||
| tr -d [:space:]) | ||
|
||
echo "$PACKAGE_VERSION" |
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,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', | ||
}, | ||
}; |
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": "expressionsExample", | ||
"paths": { | ||
"expressionsExample": "." | ||
}, | ||
"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,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. |
7 changes: 7 additions & 0 deletions
7
examples/expressions_example/common/expression_functions/action/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,7 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export * from './quick_form_fn'; | ||
export * from './quick_form_renderer'; |
53 changes: 53 additions & 0 deletions
53
examples/expressions_example/common/expression_functions/action/quick_form_fn.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,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 }, | ||
}; | ||
}, | ||
}); |
61 changes: 61 additions & 0 deletions
61
examples/expressions_example/common/expression_functions/action/quick_form_renderer.tsx
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,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> | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
examples/expressions_example/common/expression_functions/basic/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,7 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export * from './sleep'; | ||
export * from './square'; |
31 changes: 31 additions & 0 deletions
31
examples/expressions_example/common/expression_functions/basic/sleep.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,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; | ||
}, | ||
}); |
18 changes: 18 additions & 0 deletions
18
examples/expressions_example/common/expression_functions/basic/square.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,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; | ||
}, | ||
}); |
8 changes: 8 additions & 0 deletions
8
examples/expressions_example/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,8 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export * from './basic'; | ||
export * from './render'; | ||
export * from './action'; |
Oops, something went wrong.