Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Add i18n support for acceleration panels #1564

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import React, { useState } from 'react';
import { EuiOverlayMask, EuiConfirmModal, EuiFormRow, EuiFieldText } from '@elastic/eui';
import { i18n } from '@osd/i18n';
import { CachedAcceleration } from '../../../../../../common/types/data_connections';
import {
ACC_DELETE_MSG,
Expand Down Expand Up @@ -48,9 +49,14 @@

switch (actionType) {
case 'vacuum':
title = `Vacuum acceleration ${displayIndexName} on ${displayFullPath} ?`;
title = i18n.translate('accelerationActionOverlay.vacuum.title', {

Check warning on line 52 in public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx#L52

Added line #L52 was not covered by tests
defaultMessage: 'Vacuum acceleration {displayIndexName} on {displayFullPath}?',
values: { displayIndexName, displayFullPath },
});
description = ACC_VACUUM_MSG;
confirmButtonText = 'Vacuum';
confirmButtonText = i18n.translate('accelerationActionOverlay.vacuum.confirmButtonText', {

Check warning on line 57 in public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx#L57

Added line #L57 was not covered by tests
defaultMessage: 'Vacuum',
});
confirmEnabled = confirmationInput === displayIndexName;
break;
case 'delete':
Expand All @@ -59,10 +65,25 @@
confirmButtonText = 'Delete';
break;
case 'sync':
title = 'Manual sync data?';
title = i18n.translate('accelerationActionOverlay.sync.title', {

Check warning on line 68 in public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx#L68

Added line #L68 was not covered by tests
defaultMessage: 'Manual sync data?',
});
description = ACC_SYNC_MSG;
confirmButtonText = 'Sync';
confirmButtonText = i18n.translate('accelerationActionOverlay.sync.confirmButtonText', {

Check warning on line 72 in public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx#L72

Added line #L72 was not covered by tests
defaultMessage: 'Sync',
});
break;
default:
title = i18n.translate('accelerationActionOverlay.unknownAction.title', {

Check warning on line 77 in public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx#L76-L77

Added lines #L76 - L77 were not covered by tests
defaultMessage: 'Unknown Action',
});
description = '';
confirmButtonText = i18n.translate(

Check warning on line 81 in public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/acceleration_action_overlay.tsx#L80-L81

Added lines #L80 - L81 were not covered by tests
'accelerationActionOverlay.unknownAction.confirmButtonText',
{
defaultMessage: 'Confirm',
}
);
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
EuiText,
} from '@elastic/eui';
import React, { useEffect, useState } from 'react';
import { i18n } from '@osd/i18n';
import { AccelerationDetailsTab } from './flyout_modules/acceleration_details_tab';
import { AccelerationSchemaTab } from './flyout_modules/accelerations_schema_tab';
import {
Expand Down Expand Up @@ -61,7 +62,7 @@
const { dataSourceName, acceleration, resetFlyout, handleRefresh } = props;
const { flintIndexName } = acceleration;
const [selectedTab, setSelectedTab] = useState('details');
const tabsMap: { [key: string]: any } = {

Check warning on line 65 in public/components/datasources/components/manage/accelerations/acceleration_details_flyout.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
details: AccelerationDetailsTab,
schema: AccelerationSchemaTab,
};
Expand Down Expand Up @@ -141,7 +142,7 @@
if (flintIndexName !== undefined && flintIndexName.trim().length > 0) {
getAccDetail(flintIndexName);
}
}, [flintIndexName]);

Check warning on line 145 in public/components/datasources/components/manage/accelerations/acceleration_details_flyout.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'getAccDetail'. Either include it or remove the dependency array

const DiscoverIcon = () => {
return (
Expand Down Expand Up @@ -186,12 +187,16 @@
const accelerationDetailsTabs = [
{
id: 'details',
name: 'Details',
name: i18n.translate('accelerationDetailsFlyout.tabs.details', {
defaultMessage: 'Details',
}),
disabled: false,
},
{
id: 'schema',
name: 'Schema',
name: i18n.translate('accelerationDetailsFlyout.tabs.schema', {
defaultMessage: 'Schema',
}),
disabled: false,
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { useEffect, useState } from 'react';
import { i18n } from '@osd/i18n';
import { CachedAcceleration } from '../../../../../../common/types/data_connections';
import { useToast } from '../../../../common/toast';
import { useDirectQuery } from '../../../../../framework/datasources/direct_query_hook';
Expand Down Expand Up @@ -36,17 +37,38 @@

switch (operationType) {
case 'delete':
operationInProgressMessage = `Deleting acceleration: ${displayAccelerationName}`;
operationSuccessMessage = `Successfully deleted acceleration: ${displayAccelerationName}`;
operationFailureMessage = `Failed to delete acceleration: ${displayAccelerationName}`;
operationInProgressMessage = i18n.translate('useAccelerationOperation.deletingInProgress', {
defaultMessage: 'Deleting acceleration: {displayAccelerationName}',
values: { displayAccelerationName },
});
operationSuccessMessage = i18n.translate('useAccelerationOperation.deleteSuccess', {
defaultMessage: 'Successfully deleted acceleration: {displayAccelerationName}',
values: { displayAccelerationName },
});
operationFailureMessage = i18n.translate('useAccelerationOperation.deleteFailure', {
defaultMessage: 'Failed to delete acceleration: {displayAccelerationName}',
values: { displayAccelerationName },
});
break;
case 'vacuum':
operationInProgressMessage = `Vacuuming acceleration: ${displayAccelerationName}`;
operationSuccessMessage = `Successfully vacuumed acceleration: ${displayAccelerationName}`;
operationFailureMessage = `Failed to vacuum acceleration: ${displayAccelerationName}`;
operationInProgressMessage = i18n.translate('useAccelerationOperation.vacuumInProgress', {

Check warning on line 54 in public/components/datasources/components/manage/accelerations/acceleration_operation.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/acceleration_operation.tsx#L54

Added line #L54 was not covered by tests
defaultMessage: 'Vacuuming acceleration: {displayAccelerationName}',
values: { displayAccelerationName },
});
operationSuccessMessage = i18n.translate('useAccelerationOperation.vacuumSuccess', {

Check warning on line 58 in public/components/datasources/components/manage/accelerations/acceleration_operation.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/acceleration_operation.tsx#L58

Added line #L58 was not covered by tests
defaultMessage: 'Successfully vacuumed acceleration: {displayAccelerationName}',
values: { displayAccelerationName },
});
operationFailureMessage = i18n.translate('useAccelerationOperation.vacuumFailure', {

Check warning on line 62 in public/components/datasources/components/manage/accelerations/acceleration_operation.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/acceleration_operation.tsx#L62

Added line #L62 was not covered by tests
defaultMessage: 'Failed to vacuum acceleration: {displayAccelerationName}',
values: { displayAccelerationName },
});
break;
case 'sync':
operationInProgressMessage = `Syncing acceleration: ${displayAccelerationName}`;
operationInProgressMessage = i18n.translate('useAccelerationOperation.syncInProgress', {

Check warning on line 68 in public/components/datasources/components/manage/accelerations/acceleration_operation.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/acceleration_operation.tsx#L68

Added line #L68 was not covered by tests
defaultMessage: 'Syncing acceleration: {displayAccelerationName}',
values: { displayAccelerationName },
});
break;
}

Expand All @@ -68,13 +90,13 @@
}

setCurrentStatus(loadStatus);
}, [loadStatus, setToast, accelerationToOperate, operationType, currentStatus]);

Check warning on line 93 in public/components/datasources/components/manage/accelerations/acceleration_operation.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'stopLoading'. Either include it or remove the dependency array

useEffect(() => {
return () => {
stopLoading();
};
}, []);

Check warning on line 99 in public/components/datasources/components/manage/accelerations/acceleration_operation.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'stopLoading'. Either include it or remove the dependency array

const performOperation = (
acceleration: CachedAcceleration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
ACC_LOADING_MSG,
ACC_PANEL_TITLE,
ACC_PANEL_DESC,
ACC_TABLE_ACTION_DESC,
getAccelerationName,
AccelerationActionType,
CreateAccelerationFlyoutButton,
ACC_TABLE_COLUMN_NAMES,
} from './utils/acceleration_utils';
import { getRenderAccelerationDetailsFlyout } from '../../../../../plugin';
import { CatalogCacheManager } from '../../../../../framework/catalog_cache/cache_manager';
Expand All @@ -42,7 +44,7 @@

interface AccelerationTableProps {
dataSourceName: string;
cacheLoadingHooks: any;

Check warning on line 47 in public/components/datasources/components/manage/accelerations/acceleration_table.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

interface ModalState {
Expand Down Expand Up @@ -73,7 +75,7 @@
if (operationSuccess) {
handleRefresh();
}
}, [operationSuccess]);

Check warning on line 78 in public/components/datasources/components/manage/accelerations/acceleration_table.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'handleRefresh'. Either include it or remove the dependency array

const handleActionClick = (
actionType: ModalState['actionType'],
Expand Down Expand Up @@ -113,7 +115,7 @@
setAccelerations(cachedDataSource.accelerations);
setUpdatedTime(cachedDataSource.lastUpdated);
}
}, []);

Check warning on line 118 in public/components/datasources/components/manage/accelerations/acceleration_table.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'accelerationsLoadStatus', 'dataSourceName', and 'startLoadingAccelerations'. Either include them or remove the dependency array

useEffect(() => {
if (accelerationsLoadStatus === DirectQueryLoadingStatus.SUCCESS) {
Expand All @@ -127,14 +129,14 @@
if (accelerationsLoadStatus === DirectQueryLoadingStatus.FAILED) {
setIsRefreshing(false);
}
}, [accelerationsLoadStatus]);

Check warning on line 132 in public/components/datasources/components/manage/accelerations/acceleration_table.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'dataSourceName'. Either include it or remove the dependency array

const handleRefresh = useCallback(() => {
if (!isCatalogCacheFetching(accelerationsLoadStatus)) {
setIsRefreshing(true);
startLoadingAccelerations(dataSourceName);
}
}, [accelerationsLoadStatus]);

Check warning on line 139 in public/components/datasources/components/manage/accelerations/acceleration_table.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useCallback has missing dependencies: 'dataSourceName' and 'startLoadingAccelerations'. Either include them or remove the dependency array

const RefreshButton = () => {
return (
Expand Down Expand Up @@ -213,21 +215,21 @@
},
{
name: 'Sync',
description: 'Manual Sync Data',
description: ACC_TABLE_ACTION_DESC.syncAction,
icon: 'inputOutput',
onClick: (item: CachedAcceleration) => handleActionClick('sync', item),
enabled: (item: CachedAcceleration) => !item.autoRefresh && item.status === 'active',
},
{
name: 'Delete',
description: 'Delete acceleration',
description: ACC_TABLE_ACTION_DESC.deleteAction,
icon: 'trash',
onClick: (item: CachedAcceleration) => handleActionClick('delete', item),
enabled: (item: CachedAcceleration) => item.status !== 'deleted',
},
{
name: 'Vacuum',
description: 'Vacuum acceleration',
description: ACC_TABLE_ACTION_DESC.vacuumAction,
icon: 'broom',
onClick: (item: CachedAcceleration) => handleActionClick('vacuum', item),
enabled: (item: CachedAcceleration) => item.status === 'deleted',
Expand All @@ -237,7 +239,7 @@
const accelerationTableColumns = [
{
field: 'indexName',
name: 'Name',
name: ACC_TABLE_COLUMN_NAMES.columnName,
sortable: true,
render: (indexName: string, acceleration: CachedAcceleration) => {
const displayName = getAccelerationName(acceleration);
Expand All @@ -254,13 +256,13 @@
},
{
field: 'status',
name: 'Status',
name: ACC_TABLE_COLUMN_NAMES.columnStatus,
sortable: true,
render: (status: string) => <AccelerationStatus status={status} />,
},
{
field: 'type',
name: 'Type',
name: ACC_TABLE_COLUMN_NAMES.columnType,
sortable: true,
render: (type: string) => {
let label;
Expand All @@ -282,27 +284,27 @@
},
{
field: 'database',
name: 'Database',
name: ACC_TABLE_COLUMN_NAMES.columnDatabase,
sortable: true,
render: (database: string) => <EuiText size="s">{database}</EuiText>,
},
{
field: 'table',
name: 'Table',
name: ACC_TABLE_COLUMN_NAMES.columnTable,
sortable: true,
render: (table: string) => <EuiText size="s">{table || '-'}</EuiText>,
},
{
field: 'refreshType',
name: 'Refresh Type',
name: ACC_TABLE_COLUMN_NAMES.columnRefreshType,
sortable: true,
render: (autoRefresh: boolean, acceleration: CachedAcceleration) => {
return <EuiText size="s">{acceleration.autoRefresh ? 'Auto refresh' : 'Manual'}</EuiText>;
},
},
{
field: 'flintIndexName',
name: 'Destination Index',
name: ACC_TABLE_COLUMN_NAMES.columnDestinationIndex,
sortable: true,
render: (flintIndexName: string, acceleration: CachedAcceleration) => {
if (acceleration.type === 'skipping') {
Expand All @@ -315,7 +317,7 @@
name: 'Actions',
actions: tableActions,
},
] as Array<EuiTableFieldDataColumnType<any>>;

Check warning on line 320 in public/components/datasources/components/manage/accelerations/acceleration_table.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

const pagination = {
initialPageSize: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import { useToast } from '../../../../../../common/toast';
import { accelerationQueryBuilder } from '../visual_editors/query_builder';
import { formValidator, hasError } from './utils';
import {
ACC_CREATE_SUBMIT_SUCCESS_MSG,
ACC_CREATE_SUBMIT_FAIL_MSG,

Check failure on line 20 in public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration_button.tsx

View workflow job for this annotation

GitHub Actions / Lint

'ACC_CREATE_SUBMIT_FAIL_MSG' is defined but never used. Allowed unused vars must match /^_/u
} from '../../utils/acceleration_utils';

interface CreateAccelerationButtonProps {
accelerationFormData: CreateAccelerationForm;
Expand Down Expand Up @@ -54,7 +58,7 @@
const status = directqueryLoadStatus.toLowerCase();
if (status === DirectQueryLoadingStatus.SUCCESS) {
setIsLoading(false);
setToast('Create acceleration query submitted successfully!', 'success');
setToast(ACC_CREATE_SUBMIT_SUCCESS_MSG, 'success');

Check warning on line 61 in public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration_button.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration_button.tsx#L61

Added line #L61 was not covered by tests
if (refreshHandler) refreshHandler();
resetFlyout();
} else if (
Expand Down
Loading
Loading