Skip to content

Commit

Permalink
Merge branch 'main' into tooltip.for-the-last
Browse files Browse the repository at this point in the history
  • Loading branch information
szabosteve authored Feb 16, 2022
2 parents 7923d66 + 3fe08af commit 99ac7cf
Show file tree
Hide file tree
Showing 24 changed files with 1,326 additions and 109 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/label-qa-fixed-in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
}
}
prnumber: ${{ github.event.number }}
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.FLEET_TECH_KIBANA_USER_TOKEN }}
- uses: sergeysova/jq-action@v2
id: issues_to_label
with:
Expand Down Expand Up @@ -75,4 +75,4 @@ jobs:
}
issueid: ${{ matrix.issueNodeId }}
labelids: ${{ needs.fetch_issues_to_label.outputs.label_ids }}
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.FLEET_TECH_KIBANA_USER_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import './inline_editable_tables.scss';
export interface InlineEditableTableProps<Item extends ItemWithAnID> {
columns: Array<InlineEditableTableColumn<Item>>;
items: Item[];
defaultItem?: Partial<Item>;
title: string;
addButtonText?: string;
canRemoveLastItem?: boolean;
Expand All @@ -53,6 +54,7 @@ export const InlineEditableTable = <Item extends ItemWithAnID>(
const {
instanceId,
columns,
defaultItem,
onAdd,
onDelete,
onReorder,
Expand All @@ -67,6 +69,7 @@ export const InlineEditableTable = <Item extends ItemWithAnID>(
props={{
instanceId,
columns,
defaultItem,
onAdd,
onDelete,
onReorder,
Expand All @@ -90,6 +93,7 @@ export const InlineEditableTableContents = <Item extends ItemWithAnID>({
description,
isLoading,
lastItemWarning,
defaultItem,
noItemsMessage = () => null,
uneditableItems,
...rest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ interface InlineEditableTableValues<Item extends ItemWithAnID> {
export interface InlineEditableTableProps<Item extends ItemWithAnID> {
columns: Array<InlineEditableTableColumn<Item>>;
instanceId: string;
defaultItem: Item;
// TODO Because these callbacks are params, they are only set on the logic once (i.e., they are cached)
// which makes using "useState" to back this really hard.
onAdd(item: Item, onSuccess: () => void): void;
Expand Down Expand Up @@ -79,12 +80,15 @@ export const InlineEditableTableLogic = kea<InlineEditableTableLogicType<ItemWit
setFieldErrors: (fieldErrors) => ({ fieldErrors }),
setRowErrors: (rowErrors) => ({ rowErrors }),
}),
reducers: ({ props: { columns } }) => ({
reducers: ({ props: { columns, defaultItem } }) => ({
editingItemValue: [
null,
{
doneEditing: () => null,
editNewItem: () => generateEmptyItem(columns),
editNewItem: () =>
defaultItem
? { ...generateEmptyItem(columns), ...defaultItem }
: generateEmptyItem(columns),
editExistingItem: (_, { item }) => item,
setEditingItemValue: (_, { item }) => item,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { groups } from './groups.mock';

import { IndexingRule } from '../types';
import { staticSourceData } from '../views/content_sources/source_data';
import { mergeServerAndStaticData } from '../views/content_sources/sources_logic';

Expand Down Expand Up @@ -45,10 +46,25 @@ export const contentSources = [
},
];

const defaultIndexingRules: IndexingRule[] = [
{
filterType: 'object_type',
include: 'value',
},
{
filterType: 'path_template',
exclude: 'value',
},
{
filterType: 'file_extension',
include: 'value',
},
];

const defaultIndexing = {
enabled: true,
defaultAction: 'include',
rules: [],
rules: defaultIndexingRules,
schedule: {
full: 'P1D',
incremental: 'PT2H',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export const NAV = {
defaultMessage: 'Frequency',
}
),
SYNCHRONIZATION_OBJECTS_AND_ASSETS: i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.nav.synchronizationObjectsAndAssets',
SYNCHRONIZATION_ASSETS_AND_OBJECTS: i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.nav.synchronizationAssetsAndObjects',
{
defaultMessage: 'Objects and assets',
defaultMessage: 'Assets and objects',
}
),
DISPLAY_SETTINGS: i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.displaySettings', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export const DISPLAY_SETTINGS_RESULT_DETAIL_PATH = `${SOURCE_DISPLAY_SETTINGS_PA

export const SYNC_FREQUENCY_PATH = `${SOURCE_SYNCHRONIZATION_PATH}/frequency`;
export const BLOCKED_TIME_WINDOWS_PATH = `${SOURCE_SYNCHRONIZATION_PATH}/frequency/blocked_windows`;
export const OBJECTS_AND_ASSETS_PATH = `${SOURCE_SYNCHRONIZATION_PATH}/objects_and_assets`;
export const OLD_OBJECTS_AND_ASSETS_PATH = `${SOURCE_SYNCHRONIZATION_PATH}/objects_and_assets`;
export const ASSETS_AND_OBJECTS_PATH = `${SOURCE_SYNCHRONIZATION_PATH}/assets_and_objects`;

export const ORG_SETTINGS_PATH = '/settings';
export const ORG_SETTINGS_CUSTOMIZE_PATH = `${ORG_SETTINGS_PATH}/customize`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ export interface BlockedWindow {
end: string;
}

export interface IndexingRuleExclude {
filterType: 'object_type' | 'path_template' | 'file_extension';
exclude: string;
}

export interface IndexingRuleInclude {
filterType: 'object_type' | 'path_template' | 'file_extension';
include: string;
}

export type IndexingRule = IndexingRuleInclude | IndexingRuleExclude;

export interface IndexingConfig {
enabled: boolean;
features: {
Expand All @@ -178,6 +190,7 @@ export interface IndexingConfig {
enabled: boolean;
};
};
rules: IndexingRule[];
schedule: IndexingSchedule;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ describe('useSourceSubNav', () => {
href: '/sources/2/synchronization/frequency',
},
{
id: 'sourceSynchronizationObjectsAndAssets',
name: 'Objects and assets',
href: '/sources/2/synchronization/objects_and_assets',
id: 'sourceSynchronizationAssetsAndObjects',
name: 'Assets and objects',
href: '/sources/2/synchronization/assets_and_objects',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ import { shallow } from 'enzyme';

import { EuiSwitch } from '@elastic/eui';

import { ObjectsAndAssets } from './objects_and_assets';
import { AssetsAndObjects } from './assets_and_objects';

describe('ObjectsAndAssets', () => {
describe('AssetsAndObjects', () => {
const setThumbnailsChecked = jest.fn();
const setContentExtractionChecked = jest.fn();
const updateObjectsAndAssetsSettings = jest.fn();
const updateAssetsAndObjectsSettings = jest.fn();
const resetSyncSettings = jest.fn();
const contentSource = fullContentSources[0];

const mockActions = {
setThumbnailsChecked,
setContentExtractionChecked,
updateObjectsAndAssetsSettings,
updateAssetsAndObjectsSettings,
resetSyncSettings,
};
const mockValues = {
Expand All @@ -37,7 +37,7 @@ describe('ObjectsAndAssets', () => {
contentSource,
thumbnailsChecked: true,
contentExtractionChecked: true,
hasUnsavedObjectsAndAssetsChanges: false,
hasUnsavedAssetsAndObjectsChanges: false,
};

beforeEach(() => {
Expand All @@ -46,13 +46,13 @@ describe('ObjectsAndAssets', () => {
});

it('renders', () => {
const wrapper = shallow(<ObjectsAndAssets />);
const wrapper = shallow(<AssetsAndObjects />);

expect(wrapper.find(EuiSwitch)).toHaveLength(2);
});

it('handles thumbnails switch change', () => {
const wrapper = shallow(<ObjectsAndAssets />);
const wrapper = shallow(<AssetsAndObjects />);
wrapper
.find('[data-test-subj="ThumbnailsToggle"]')
.simulate('change', { target: { checked: false } });
Expand All @@ -61,7 +61,7 @@ describe('ObjectsAndAssets', () => {
});

it('handles content extraction switch change', () => {
const wrapper = shallow(<ObjectsAndAssets />);
const wrapper = shallow(<AssetsAndObjects />);
wrapper
.find('[data-test-subj="ContentExtractionToggle"]')
.simulate('change', { target: { checked: false } });
Expand All @@ -77,7 +77,7 @@ describe('ObjectsAndAssets', () => {
areThumbnailsConfigEnabled: false,
},
});
const wrapper = shallow(<ObjectsAndAssets />);
const wrapper = shallow(<AssetsAndObjects />);

expect(wrapper.find('[data-test-subj="ThumbnailsToggle"]').prop('label')).toEqual(
'Sync thumbnails - disabled at global configuration level'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
EuiLink,
EuiSpacer,
EuiSwitch,
EuiText,
EuiTitle,
} from '@elastic/eui';

import { SAVE_BUTTON_LABEL } from '../../../../../shared/constants';
Expand All @@ -27,75 +27,73 @@ import { UnsavedChangesPrompt } from '../../../../../shared/unsaved_changes_prom
import { ViewContentHeader } from '../../../../components/shared/view_content_header';
import { NAV, RESET_BUTTON } from '../../../../constants';
import {
LEARN_MORE_LINK,
SYNC_MANAGEMENT_CONTENT_EXTRACTION_LABEL,
SYNC_MANAGEMENT_THUMBNAILS_LABEL,
SYNC_MANAGEMENT_THUMBNAILS_GLOBAL_CONFIG_LABEL,
SOURCE_OBJECTS_AND_ASSETS_DESCRIPTION,
SOURCE_OBJECTS_AND_ASSETS_LABEL,
SOURCE_ASSETS_AND_OBJECTS_DESCRIPTION,
SOURCE_ASSETS_AND_OBJECTS_ASSETS_LABEL,
SYNC_UNSAVED_CHANGES_MESSAGE,
SOURCE_ASSETS_AND_OBJECTS_LEARN_MORE_LINK,
SOURCE_ASSETS_AND_OBJECTS_OBJECTS_LABEL,
} from '../../constants';
import { SourceLogic } from '../../source_logic';
import { SourceLayout } from '../source_layout';

import { IndexingRulesTable } from './indexing_rules_table';
import { SynchronizationLogic } from './synchronization_logic';

export const ObjectsAndAssets: React.FC = () => {
export const AssetsAndObjects: React.FC = () => {
const { contentSource, dataLoading } = useValues(SourceLogic);
const { thumbnailsChecked, contentExtractionChecked, hasUnsavedObjectsAndAssetsChanges } =
const { thumbnailsChecked, contentExtractionChecked, hasUnsavedAssetsAndObjectsChanges } =
useValues(SynchronizationLogic({ contentSource }));
const {
setThumbnailsChecked,
setContentExtractionChecked,
updateObjectsAndAssetsSettings,
updateAssetsAndObjectsSettings,
resetSyncSettings,
} = useActions(SynchronizationLogic({ contentSource }));

const { areThumbnailsConfigEnabled } = contentSource;

const actions = (
<EuiFlexGroup>
<EuiFlexItem>
<EuiButtonEmpty onClick={resetSyncSettings} disabled={!hasUnsavedObjectsAndAssetsChanges}>
{RESET_BUTTON}
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem>
<EuiButton
fill
onClick={updateObjectsAndAssetsSettings}
disabled={!hasUnsavedObjectsAndAssetsChanges}
onClick={updateAssetsAndObjectsSettings}
disabled={!hasUnsavedAssetsAndObjectsChanges}
>
{SAVE_BUTTON_LABEL}
</EuiButton>
</EuiFlexItem>
<EuiFlexItem>
<EuiButtonEmpty onClick={resetSyncSettings} disabled={!hasUnsavedAssetsAndObjectsChanges}>
{RESET_BUTTON}
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
);

return (
<SourceLayout
pageChrome={[NAV.SYNCHRONIZATION_OBJECTS_AND_ASSETS]}
pageChrome={[NAV.SYNCHRONIZATION_ASSETS_AND_OBJECTS]}
pageViewTelemetry="source_synchronization"
isLoading={dataLoading}
>
<UnsavedChangesPrompt
hasUnsavedChanges={hasUnsavedObjectsAndAssetsChanges}
hasUnsavedChanges={hasUnsavedAssetsAndObjectsChanges}
messageText={SYNC_UNSAVED_CHANGES_MESSAGE}
/>
<ViewContentHeader
title={NAV.SYNCHRONIZATION_OBJECTS_AND_ASSETS}
description={
<>
{SOURCE_OBJECTS_AND_ASSETS_DESCRIPTION}{' '}
<EuiLink href={docLinks.workplaceSearchSynch} external>
{LEARN_MORE_LINK}
</EuiLink>
</>
}
action={actions}
/>
<ViewContentHeader title={NAV.SYNCHRONIZATION_ASSETS_AND_OBJECTS} action={actions} />
{SOURCE_ASSETS_AND_OBJECTS_DESCRIPTION}
<EuiSpacer />
<EuiLink href={docLinks.workplaceSearchSynch} external>
{SOURCE_ASSETS_AND_OBJECTS_LEARN_MORE_LINK}
</EuiLink>
<EuiHorizontalRule />
<EuiText size="m">{SOURCE_OBJECTS_AND_ASSETS_LABEL}</EuiText>
<EuiTitle size="s">
<h3>{SOURCE_ASSETS_AND_OBJECTS_ASSETS_LABEL}</h3>
</EuiTitle>
<EuiSpacer />
<EuiFlexGroup>
<EuiFlexItem grow={false}>
Expand All @@ -122,6 +120,15 @@ export const ObjectsAndAssets: React.FC = () => {
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiHorizontalRule />
<EuiTitle size="s">
<h3>{SOURCE_ASSETS_AND_OBJECTS_OBJECTS_LABEL}</h3>
</EuiTitle>
<EuiFlexGroup>
<EuiFlexItem>
<IndexingRulesTable />
</EuiFlexItem>
</EuiFlexGroup>
</SourceLayout>
);
};
Loading

0 comments on commit 99ac7cf

Please sign in to comment.