Skip to content

Commit

Permalink
solve the code conflict
Browse files Browse the repository at this point in the history
Signed-off-by: yubonluo <[email protected]>
  • Loading branch information
yubonluo committed Aug 16, 2024
2 parents 49fe15c + 6877bea commit ba4c850
Show file tree
Hide file tree
Showing 224 changed files with 21,131 additions and 6,956 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7598.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [Workspace] Refactor workspace detail page ([#7598](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7598))
2 changes: 2 additions & 0 deletions changelogs/fragments/7637.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Introduce the redesign page and applications headers behind a switch ([#7637](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7637))
2 changes: 2 additions & 0 deletions changelogs/fragments/7651.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [contentManagement] allow to update section input after page rendered ([#7651](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7651))
2 changes: 2 additions & 0 deletions changelogs/fragments/7655.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [navigation] Left navigation collective ([#7655](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7655))
2 changes: 2 additions & 0 deletions changelogs/fragments/7656.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [Workspace]Add name and description characters limitation ([#7656](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7656))
2 changes: 2 additions & 0 deletions changelogs/fragments/7686.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Change the locale dynamically by adding &i18n-locale to URL ([#7686](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7686))
2 changes: 2 additions & 0 deletions changelogs/fragments/7687.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
refactor:
- Refactor search bar & filters to conditionally render new look with application header ([#7687](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7687))
2 changes: 2 additions & 0 deletions changelogs/fragments/7691.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Allow customizing `restrictWidth` and `paddingSize` of `TableListView` ([#7691](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7691))
2 changes: 2 additions & 0 deletions changelogs/fragments/7697.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Integrate new page header for workspace pages ([#7697](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7697))
2 changes: 2 additions & 0 deletions changelogs/fragments/7699.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Add a unit test case to indicate React is anti-xss ([#7699](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7699))
2 changes: 2 additions & 0 deletions changelogs/fragments/7702.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Refractor the homepage assets list section ([#7702](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7702))
2 changes: 2 additions & 0 deletions changelogs/fragments/7721.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Allow `screenTitle` to be present when SearchBar is not in Application header ([#7721](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7721))
2 changes: 2 additions & 0 deletions changelogs/fragments/7723.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Simplify `TopNavControlDescriptionData` to to be followed by links ([#7723](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7723))
2 changes: 2 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- public
- application
- [Hooks](../src/plugins/console/public/application/hooks/README.md)
- [Content_management](../src/plugins/content_management/README.md)
- [Csp_handler](../src/plugins/csp_handler/README.md)
- [Dashboard](../src/plugins/dashboard/README.md)
- [Data](../src/plugins/data/README.md)
Expand Down Expand Up @@ -164,6 +165,7 @@
- [Opensearch dashboards.release notes 2.13.0](../release-notes/opensearch-dashboards.release-notes-2.13.0.md)
- [Opensearch dashboards.release notes 2.14.0](../release-notes/opensearch-dashboards.release-notes-2.14.0.md)
- [Opensearch dashboards.release notes 2.15.0](../release-notes/opensearch-dashboards.release-notes-2.15.0.md)
- [Opensearch dashboards.release notes 2.16.0](../release-notes/opensearch-dashboards.release-notes-2.16.0.md)
- [Opensearch dashboards.release notes 2.2.0](../release-notes/opensearch-dashboards.release-notes-2.2.0.md)
- [Opensearch dashboards.release notes 2.2.1](../release-notes/opensearch-dashboards.release-notes-2.2.1.md)
- [Opensearch dashboards.release notes 2.3.0](../release-notes/opensearch-dashboards.release-notes-2.3.0.md)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"dependencies": {
"@aws-crypto/client-node": "^3.1.1",
"@elastic/datemath": "5.0.3",
"@elastic/eui": "npm:@opensearch-project/oui@1.8.1",
"@elastic/eui": "npm:@opensearch-project/oui@1.9.0",
"@elastic/good": "^9.0.1-kibana3",
"@elastic/numeral": "npm:@amoo-miki/[email protected]",
"@elastic/request-crypto": "2.0.0",
Expand Down
34 changes: 33 additions & 1 deletion packages/osd-i18n/src/core/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,8 +899,17 @@ describe('I18n engine', () => {

describe('load', () => {
let mockFetch: jest.SpyInstance;
let originalWindow: any;

beforeEach(() => {
mockFetch = jest.spyOn(global as any, 'fetch').mockImplementation();
originalWindow = global.window;
global.window = { ...originalWindow };
});

afterEach(() => {
global.window = originalWindow;
delete (window as any).__i18nWarning; // Clear the warning after each test
});

test('fails if server returns >= 300 status code', async () => {
Expand Down Expand Up @@ -928,7 +937,7 @@ describe('I18n engine', () => {

mockFetch.mockResolvedValue({
status: 200,
json: jest.fn().mockResolvedValue(translations),
json: jest.fn().mockResolvedValue({ translations }),
});

await expect(i18n.load('some-url')).resolves.toBeUndefined();
Expand All @@ -938,5 +947,28 @@ describe('I18n engine', () => {

expect(i18n.getTranslation()).toEqual(translations);
});

test('sets warning on window when present in response', async () => {
const warning = { title: 'Warning', text: 'This is a warning' };
mockFetch.mockResolvedValue({
status: 200,
json: jest.fn().mockResolvedValue({ translations: { locale: 'en' }, warning }),
});

await i18n.load('some-url');

expect((window as any).__i18nWarning).toEqual(warning);
});

test('does not set warning on window when not present in response', async () => {
mockFetch.mockResolvedValue({
status: 200,
json: jest.fn().mockResolvedValue({ translations: { locale: 'en' } }),
});

await i18n.load('some-url');

expect((window as any).__i18nWarning).toBeUndefined();
});
});
});
9 changes: 8 additions & 1 deletion packages/osd-i18n/src/core/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,12 @@ export async function load(translationsUrl: string) {
throw new Error(`Translations request failed with status code: ${response.status}`);
}

init(await response.json());
const data = await response.json();

if (data.warning) {
// Store the warning to be displayed after core system setup
(window as any).__i18nWarning = data.warning;
}

init(data.translations);
}
2 changes: 1 addition & 1 deletion packages/osd-ui-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"enzyme-adapter-react-16": "^1.9.1"
},
"devDependencies": {
"@elastic/eui": "npm:@opensearch-project/oui@1.8.1",
"@elastic/eui": "npm:@opensearch-project/oui@1.9.0",
"@osd/babel-preset": "1.0.0",
"@osd/optimizer": "1.0.0",
"comment-stripper": "^0.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@elastic/charts": "31.1.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.8.1",
"@elastic/eui": "npm:@opensearch-project/oui@1.9.0",
"@elastic/numeral": "npm:@amoo-miki/[email protected]",
"@opensearch/datemath": "5.0.3",
"@osd/i18n": "1.0.0",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/core/public/application/application_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ const createStartContractMock = (): jest.Mocked<ApplicationStart> => {
navigateToUrl: jest.fn(),
getUrlForApp: jest.fn(),
registerMountContext: jest.fn(),
setAppLeftControls: jest.fn(),
setAppCenterControls: jest.fn(),
setAppRightControls: jest.fn(),
setAppBadgeControls: jest.fn(),
setAppDescriptionControls: jest.fn(),
setAppBottomControls: jest.fn(),
};
};

Expand Down Expand Up @@ -98,6 +104,18 @@ const createInternalStartContractMock = (): jest.Mocked<InternalApplicationStart
capabilities: capabilitiesServiceMock.createStartContract().capabilities,
currentAppId$: currentAppId$.asObservable(),
currentActionMenu$: new BehaviorSubject<MountPoint | undefined>(undefined),
currentLeftControls$: new BehaviorSubject<MountPoint | undefined>(undefined),
currentCenterControls$: new BehaviorSubject<MountPoint | undefined>(undefined),
currentRightControls$: new BehaviorSubject<MountPoint | undefined>(undefined),
currentBadgeControls$: new BehaviorSubject<MountPoint | undefined>(undefined),
currentDescriptionControls$: new BehaviorSubject<MountPoint | undefined>(undefined),
currentBottomControls$: new BehaviorSubject<MountPoint | undefined>(undefined),
setAppLeftControls: jest.fn(),
setAppCenterControls: jest.fn(),
setAppRightControls: jest.fn(),
setAppBadgeControls: jest.fn(),
setAppDescriptionControls: jest.fn(),
setAppBottomControls: jest.fn(),
getComponent: jest.fn(),
getUrlForApp: jest.fn(),
navigateToApp: jest.fn().mockImplementation((appId) => currentAppId$.next(appId)),
Expand Down
32 changes: 31 additions & 1 deletion src/core/public/application/application_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
} from './application_service.test.mocks';

import { createElement } from 'react';
import { BehaviorSubject, Subject } from 'rxjs';
import { BehaviorSubject, Subject, Observable } from 'rxjs';
import { bufferCount, take, takeUntil } from 'rxjs/operators';
import { shallow, mount } from 'enzyme';

Expand All @@ -51,7 +51,9 @@ import {
AppStatus,
AppUpdater,
WorkspaceAvailability,
InternalApplicationStart,
} from './types';
import { MountPoint } from '../types';
import { act } from 'react-dom/test-utils';
import { workspacesServiceMock } from '../mocks';

Expand Down Expand Up @@ -937,6 +939,34 @@ describe('#start()', () => {
expect(setupDeps.redirectTo).not.toHaveBeenCalled();
});
});

describe('AppControls', () => {
test.each(['Left', 'Center', 'Right', 'Badge', 'Description', 'Bottom'])(
'records the App%sControls',
async (container) => {
const { register } = service.setup(setupDeps);

register(Symbol(), createApp({ id: `app${container}` }));
const appStart = await service.start(startDeps);
const setControls = appStart[
`setApp${container}Controls` as keyof InternalApplicationStart
] as (mount: MountPoint | undefined) => void;
const currentControls$ = appStart[
`current${container}Controls$` as keyof InternalApplicationStart
] as Observable<MountPoint | undefined>;

const oldMountPoint = jest.fn();
const expectedMountPoint = jest.fn();

await appStart.navigateToApp(`app${container}`);
setControls(oldMountPoint);
setControls(expectedMountPoint);

const mountPoint = await currentControls$.pipe(take(1)).toPromise();
expect(mountPoint).toBe(expectedMountPoint);
}
);
});
});

describe('#stop()', () => {
Expand Down
Loading

0 comments on commit ba4c850

Please sign in to comment.