Skip to content

Commit

Permalink
Merge branch 'main' into console-mappings-ts
Browse files Browse the repository at this point in the history
Signed-off-by: Anan Zhuang <ananzh@amazon.com>
  • Loading branch information
ananzh committed Jun 29, 2023
2 parents ccdee60 + f6e22cb commit e776e9b
Show file tree
Hide file tree
Showing 22 changed files with 622 additions and 256 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [CVE-2022-37603] Bump loader-utils from `2.0.3` to `2.0.4` ([#3031](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3031)). Backwards-compatible fixes included in v2.6.0 and v1.3.7 releases.
- [WS-2021-0638] Bump mocha from `7.2.0` to `10.1.0` ([#2711](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2711))
- Bump `joi` to v14 to avoid the possibility of prototype poisoning in a nested dependency ([#3952](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3952))
- [CVE-2022-25883] Resolve `semver` to `7.5.3` and remove unused package ([#4411](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4411))

### 📈 Features/Enhancements

Expand All @@ -22,10 +23,12 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Hide any output from use_node checking for Node compatibility ([#4237](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4237))
- Add category option within groups for context menus ([#4144](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4144))
- [Saved Object Service] Add Repository Factory Provider ([#4149](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4149))
- [Sample Data] Add visual consistency dashboard to sample logs data ([#4339](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4339))
- [@osd/pm] Fix `file:`-linked dependencies' resolution to improve ability to test with local packages ([#4342](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4342))
- [Multiple DataSource] Backend support for adding sample data ([#4268](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4268))
- Add configurable defaults and overrides to uiSettings ([#4344](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4344))
- Bump OUI to `1.1.2` to make `anomalyDetection` icon available ([#4408](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4408))
- [Multiple DataSource] Frontend support for adding sample data ([#4412](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4412))

### 🐛 Bug Fixes

Expand Down Expand Up @@ -69,6 +72,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Vis Colors] [TSVB] Update default color in `vis_type_timeseries` to use `ouiPaletteColorBlind()[0]`([#4363](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4363))
- [Vis Colors] [Timeline] Replace `vis_type_timeline` colors with `ouiPaletteColorBlind()` ([#4366](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4366))
- [Vis Colors] Update legacy seed colors to use `ouiPaletteColorBlind()` ([#4348](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4348))
- [Vis colors] Update legacy mapped colors in charts plugin to use `ouiPaletteColorBlind()`, Update default color in legacy visualizations to use `ouiPaletteColorBlind()[0]` ([#4398](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4398))
- [Console] Migrate `/lib/mappings/` module to TypeScript ([#4008](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4008))

### 🔩 Tests
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"**/unset-value": "^2.0.1",
"**/jest-config": "npm:@amoo-miki/jest-config@27.5.1",
"**/jest-jasmine2": "npm:@amoo-miki/jest-jasmine2@27.5.1",
"**/semver": "^7.5.3",
"**/set-value": "^4.1.0",
"**/xml2js": "^0.5.0",
"**/yaml": "^2.2.2"
Expand Down Expand Up @@ -211,7 +212,7 @@
"require-in-the-middle": "^5.0.2",
"rison-node": "1.0.2",
"rxjs": "^6.5.5",
"semver": "^5.7.0",
"semver": "^7.5.3",
"set-value": "^4.1.0",
"source-map-support": "^0.5.19",
"symbol-observable": "^1.2.0",
Expand Down Expand Up @@ -322,7 +323,7 @@
"@types/react-virtualized": "^9.18.7",
"@types/recompose": "^0.30.6",
"@types/selenium-webdriver": "^4.0.9",
"@types/semver": "^5.5.0",
"@types/semver": "^7.5.0",
"@types/sinon": "^7.0.13",
"@types/strip-ansi": "^5.2.1",
"@types/styled-components": "^5.1.19",
Expand Down
1 change: 0 additions & 1 deletion packages/osd-pm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@babel/preset-typescript": "^7.16.5",
"@node-rs/xxhash": "^1.3.0",
"@types/cmd-shim": "^2.0.0",
"@types/cpy": "^5.1.0",
"@types/dedent": "^0.7.0",
"@types/getopts": "^2.0.1",
"@types/glob": "^7.1.3",
Expand Down
1 change: 1 addition & 0 deletions packages/osd-stylelint-plugin-stylelint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"devOnly": true
},
"peerDependencies": {
"postcss": "^8.4.12",
"stylelint": "^14.5.2"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
getUntrackedMessage,
getNotCompliantMessage,
getRulesFromConfig,
isColorProperty,
getColorPropertyParent,
isValidOptions,
ValueBasedConfig,
} from '../../utils';
Expand All @@ -32,12 +32,12 @@ const messages = ruleMessages(ruleName, {
expected: (message) => `${message}`,
});

const ruleFunction = (
const ruleFunction: stylelint.Rule = (
primaryOption: Record<string, any>,
secondaryOptionObject: Record<string, any>,
context
) => {
return (postcssRoot: any, postcssResult: any) => {
return (postcssRoot, postcssResult) => {
const validOptions = isValidOptions(postcssResult, ruleName, primaryOption);
if (!validOptions) {
return;
Expand All @@ -47,15 +47,16 @@ const ruleFunction = (

const isAutoFixing = Boolean(context.fix);

postcssRoot.walkDecls((decl: any) => {
if (!isColorProperty(decl.prop)) {
postcssRoot.walkDecls((decl) => {
const parent = getColorPropertyParent(decl);
if (!parent) {
return;
}

let shouldReport = false;

const nodeInfo = {
selector: decl.parent.selector,
selector: parent.selector,
prop: decl.prop,
value: decl.value,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ const messages = ruleMessages(ruleName, {
expected: (message) => `${message}`,
});

const ruleFunction = (
const ruleFunction: stylelint.Rule = (
primaryOption: Record<string, any>,
secondaryOptionObject: Record<string, any>,
context
) => {
return (postcssRoot: any, postcssResult: any) => {
return (postcssRoot, postcssResult) => {
const validOptions = isValidOptions(postcssResult, ruleName, primaryOption);
if (!validOptions) {
return;
Expand All @@ -41,15 +41,19 @@ const ruleFunction = (

const isAutoFixing = Boolean(context.fix);

postcssRoot.walkRules((rule: any) => {
postcssRoot.walkRules((rule) => {
const selectorRule = getRuleFromConfig(rules, rule.selector);
if (!selectorRule) {
return;
}

let shouldReport = false;

const file = postcssRoot.source.input.file;
const file = postcssRoot.source?.input.file;
if (!file) {
return;
}

const approvedFiles = selectorRule.approved;

const reportInfo = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* GitHub history for details.
*/

import { Rule, Declaration } from 'postcss';

const COLOR_PROPERTIES = [
'all',
'animation',
Expand Down Expand Up @@ -58,3 +60,11 @@ const COLOR_PROPERTIES = [
export const isColorProperty = (prop: string) => {
return COLOR_PROPERTIES.includes(prop);
};

export const getColorPropertyParent = (decl: Declaration) => {
if (!isColorProperty(decl.prop)) {
return undefined;
}

return decl.parent as Rule;
};
44 changes: 0 additions & 44 deletions src/plugins/charts/public/services/colors/color_palette.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/plugins/charts/public/services/colors/colors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import { coreMock } from '../../../../../core/public/mocks';
import { COLOR_MAPPING_SETTING } from '../../../common';
import { euiPaletteColorBlind } from '@elastic/eui';

import { ColorsService } from './colors';

// Local state for config
Expand Down
117 changes: 0 additions & 117 deletions src/plugins/charts/public/services/colors/colors_palette.test.ts

This file was deleted.

8 changes: 6 additions & 2 deletions src/plugins/charts/public/services/colors/mapped_colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import Color from 'color';

import { CoreSetup } from 'opensearch-dashboards/public';

import { euiPaletteColorBlind } from '@elastic/eui';
import { COLOR_MAPPING_SETTING } from '../../../common';
import { createColorPalette } from './color_palette';

const standardizeColor = (color: string) => new Color(color).hex().toLowerCase();

Expand Down Expand Up @@ -100,7 +100,11 @@ export class MappedColors {

// Generate a color palette big enough that all new keys can have unique color values
const allColors = _(this._mapping).values().union(configColors).union(oldColors).value();
const colorPalette = createColorPalette(allColors.length + keysToMap.length);
const numColors = allColors.length + keysToMap.length;
const colorPalette = euiPaletteColorBlind({
rotations: Math.ceil(numColors / 10),
direction: 'both',
}).slice(0, numColors);
let newColors = _.difference(colorPalette, allColors);

while (keysToMap.length > newColors.length) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/charts/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class ChartsServerPlugin implements Plugin<object, object> {
defaultMessage: 'Color mapping',
}),
value: JSON.stringify({
Count: '#00A69B',
Count: '#54B399',
}),
type: 'json',
description: i18n.translate('charts.advancedSettings.visualization.colorMappingText', {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/home/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"requiredPlugins": ["data", "urlForwarding"],
"optionalPlugins": ["usageCollection", "telemetry", "dataSource"],
"requiredBundles": [
"opensearchDashboardsReact"
"opensearchDashboardsReact", "dataSourceManagement"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export class SampleDataSetCard extends React.Component {
};

install = () => {
this.props.onInstall(this.props.id);
this.props.onInstall(this.props.id, this.props.dataSourceId);
};

uninstall = () => {
this.props.onUninstall(this.props.id);
this.props.onUninstall(this.props.id, this.props.dataSourceId);
};

renderBtn = () => {
Expand Down
Loading

0 comments on commit e776e9b

Please sign in to comment.