Skip to content

Commit 1b078e6

Browse files
committed
Fix after review, better typing and typos
1 parent de61e62 commit 1b078e6

File tree

6 files changed

+29
-53
lines changed

6 files changed

+29
-53
lines changed

x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/agent_config.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66
import { HttpFetchQuery } from 'src/core/public';
7-
import { useRequest, sendRequest, useConditionnalRequest } from './use_request';
7+
import {
8+
useRequest,
9+
sendRequest,
10+
useConditionalRequest,
11+
SendConditionalRequestConfig,
12+
} from './use_request';
813
import { agentConfigRouteService } from '../../services';
914
import {
1015
GetAgentConfigsResponse,
@@ -26,17 +31,11 @@ export const useGetAgentConfigs = (query: HttpFetchQuery = {}) => {
2631
};
2732

2833
export const useGetOneAgentConfig = (agentConfigId: string | undefined) => {
29-
return useConditionnalRequest<GetOneAgentConfigResponse>(
30-
agentConfigId
31-
? {
32-
path: agentConfigRouteService.getInfoPath(agentConfigId),
33-
method: 'get',
34-
shouldSendRequest: true,
35-
}
36-
: {
37-
shouldSendRequest: false,
38-
}
39-
);
34+
return useConditionalRequest<GetOneAgentConfigResponse>({
35+
path: agentConfigId ? agentConfigRouteService.getInfoPath(agentConfigId) : undefined,
36+
method: 'get',
37+
shouldSendRequest: !!agentConfigId,
38+
} as SendConditionalRequestConfig);
4039
};
4140

4241
export const useGetOneAgentConfigFull = (agentConfigId: string) => {

x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/enrollment_api_keys.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { useRequest, UseRequestConfig, sendRequest, useConditionnalRequest } from './use_request';
7+
import {
8+
useRequest,
9+
UseRequestConfig,
10+
sendRequest,
11+
useConditionalRequest,
12+
SendConditionalRequestConfig,
13+
} from './use_request';
814
import { enrollmentAPIKeyRouteService } from '../../services';
915
import {
1016
GetOneEnrollmentAPIKeyResponse,
@@ -15,17 +21,11 @@ import {
1521
type RequestOptions = Pick<Partial<UseRequestConfig>, 'pollIntervalMs'>;
1622

1723
export function useGetOneEnrollmentAPIKey(keyId: string | undefined) {
18-
return useConditionnalRequest<GetOneEnrollmentAPIKeyResponse>(
19-
keyId
20-
? {
21-
method: 'get',
22-
path: enrollmentAPIKeyRouteService.getInfoPath(keyId),
23-
shouldSendRequest: true,
24-
}
25-
: {
26-
shouldSendRequest: false,
27-
}
28-
);
24+
return useConditionalRequest<GetOneEnrollmentAPIKeyResponse>({
25+
method: 'get',
26+
path: keyId ? enrollmentAPIKeyRouteService.getInfoPath(keyId) : undefined,
27+
shouldSendRequest: !!keyId,
28+
} as SendConditionalRequestConfig);
2929
}
3030

3131
export function sendGetOneEnrollmentAPIKey(keyId: string, options?: RequestOptions) {

x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/use_request.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ export const useRequest = <D = any>(config: UseRequestConfig) => {
3737
return _useRequest<D>(httpClient, config);
3838
};
3939

40-
type SendConditionnalRequestConfig =
40+
export type SendConditionalRequestConfig =
4141
| (SendRequestConfig & { shouldSendRequest: true })
4242
| (Partial<SendRequestConfig> & { shouldSendRequest: false });
4343

44-
export const useConditionnalRequest = <D = any>(config: SendConditionnalRequestConfig) => {
44+
export const useConditionalRequest = <D = any>(config: SendConditionalRequestConfig) => {
4545
const [state, setState] = useState<{
4646
error: Error | null;
4747
data: D | null;

x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/agent_list_page/components/agent_enrollment_flyout/key_selection.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface Props {
2525
agentConfigs: AgentConfig[];
2626
}
2727

28-
function useCreateApiKeyForm(configId: string | null, onSuccess: (keyId: string) => void) {
28+
function useCreateApiKeyForm(configId: string | undefined, onSuccess: (keyId: string) => void) {
2929
const { notifications } = useCore();
3030
const [isLoading, setIsLoading] = useState(false);
3131
const apiKeyNameInput = useInput('');
@@ -67,11 +67,10 @@ export const APIKeySelection: React.FunctionComponent<Props> = ({ onKeyChange, a
6767
});
6868

6969
const [selectedState, setSelectedState] = useState<{
70-
agentConfigId: string | null;
71-
enrollmentAPIKeyId: string | undefined;
70+
agentConfigId?: string;
71+
enrollmentAPIKeyId?: string;
7272
}>({
73-
agentConfigId: agentConfigs.length ? agentConfigs[0].id : null,
74-
enrollmentAPIKeyId: undefined,
73+
agentConfigId: agentConfigs.length ? agentConfigs[0].id : undefined,
7574
});
7675
const filteredEnrollmentAPIKeys = React.useMemo(() => {
7776
if (!selectedState.agentConfigId || !enrollmentAPIKeysRequest.data) {

x-pack/plugins/translations/translations/ja-JP.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8325,13 +8325,6 @@
83258325
"xpack.ingestManager.agentListStatus.offlineLabel": "オフライン",
83268326
"xpack.ingestManager.agentListStatus.onlineLabel": "オンライン",
83278327
"xpack.ingestManager.agentListStatus.totalLabel": "エージェント",
8328-
"xpack.ingestManager.apiKeysForm.configLabel": "構成",
8329-
"xpack.ingestManager.apiKeysForm.nameLabel": "キー名",
8330-
"xpack.ingestManager.apiKeysForm.saveButton": "保存",
8331-
"xpack.ingestManager.apiKeysList.apiKeyColumnTitle": "API キー",
8332-
"xpack.ingestManager.apiKeysList.configColumnTitle": "構成",
8333-
"xpack.ingestManager.apiKeysList.emptyEnrollmentKeysMessage": "API キーがありません",
8334-
"xpack.ingestManager.apiKeysList.nameColumnTitle": "名前",
83358328
"xpack.ingestManager.appNavigation.configurationsLinkText": "構成",
83368329
"xpack.ingestManager.appNavigation.fleetLinkText": "フリート",
83378330
"xpack.ingestManager.appNavigation.overviewLinkText": "概要",
@@ -8410,8 +8403,6 @@
84108403
"xpack.ingestManager.deleteAgentConfigs.successMultipleNotificationTitle": "{count} 件のエージェント構成を削除しました",
84118404
"xpack.ingestManager.deleteAgentConfigs.successSingleNotificationTitle": "エージェント構成「{id}」を削除しました",
84128405
"xpack.ingestManager.deleteApiKeys.confirmModal.cancelButtonLabel": "キャンセル",
8413-
"xpack.ingestManager.deleteApiKeys.confirmModal.confirmButtonLabel": "削除",
8414-
"xpack.ingestManager.deleteApiKeys.confirmModal.title": "API キーを削除: {apiKeyId}",
84158406
"xpack.ingestManager.deleteDatasource.confirmModal.affectedAgentsMessage": "{agentConfigName} が一部のエージェントで既に使用されていることをフリートが検出しました。",
84168407
"xpack.ingestManager.deleteDatasource.confirmModal.affectedAgentsTitle": "このアクションは {agentsCount} {agentsCount, plural, one {# エージェント} other {# エージェント}}に影響します",
84178408
"xpack.ingestManager.deleteDatasource.confirmModal.cancelButtonLabel": "キャンセル",
@@ -8434,9 +8425,7 @@
84348425
"xpack.ingestManager.editConfig.successNotificationTitle": "エージェント構成「{name}」を更新しました",
84358426
"xpack.ingestManager.enrollmentApiKeyForm.namePlaceholder": "名前を選択",
84368427
"xpack.ingestManager.enrollmentApiKeyList.createNewButton": "新規キーを作成",
8437-
"xpack.ingestManager.enrollmentApiKeyList.hideTableButton": "を非表示",
84388428
"xpack.ingestManager.enrollmentApiKeyList.useExistingsButton": "既存のキーを使用",
8439-
"xpack.ingestManager.enrollmentApiKeyList.viewTableButton": "表示",
84408429
"xpack.ingestManager.epm.addDatasourceButtonText": "データソースを作成",
84418430
"xpack.ingestManager.epm.pageSubtitle": "人気のアプリやサービスのパッケージを参照する",
84428431
"xpack.ingestManager.epm.pageTitle": "Elastic Package Manager",

x-pack/plugins/translations/translations/zh-CN.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8328,13 +8328,6 @@
83288328
"xpack.ingestManager.agentListStatus.offlineLabel": "脱机",
83298329
"xpack.ingestManager.agentListStatus.onlineLabel": "联机",
83308330
"xpack.ingestManager.agentListStatus.totalLabel": "代理",
8331-
"xpack.ingestManager.apiKeysForm.configLabel": "配置",
8332-
"xpack.ingestManager.apiKeysForm.nameLabel": "密钥名称",
8333-
"xpack.ingestManager.apiKeysForm.saveButton": "保存",
8334-
"xpack.ingestManager.apiKeysList.apiKeyColumnTitle": "API 密钥",
8335-
"xpack.ingestManager.apiKeysList.configColumnTitle": "配置",
8336-
"xpack.ingestManager.apiKeysList.emptyEnrollmentKeysMessage": "无 API 密钥",
8337-
"xpack.ingestManager.apiKeysList.nameColumnTitle": "名称",
83388331
"xpack.ingestManager.appNavigation.configurationsLinkText": "配置",
83398332
"xpack.ingestManager.appNavigation.fleetLinkText": "Fleet",
83408333
"xpack.ingestManager.appNavigation.overviewLinkText": "概览",
@@ -8413,8 +8406,6 @@
84138406
"xpack.ingestManager.deleteAgentConfigs.successMultipleNotificationTitle": "已删除 {count} 个代理配置",
84148407
"xpack.ingestManager.deleteAgentConfigs.successSingleNotificationTitle": "已删除代理配置“{id}”",
84158408
"xpack.ingestManager.deleteApiKeys.confirmModal.cancelButtonLabel": "取消",
8416-
"xpack.ingestManager.deleteApiKeys.confirmModal.confirmButtonLabel": "删除",
8417-
"xpack.ingestManager.deleteApiKeys.confirmModal.title": "删除 api 密钥:{apiKeyId}",
84188409
"xpack.ingestManager.deleteDatasource.confirmModal.affectedAgentsMessage": "Fleet 已检测到 {agentConfigName} 已由您的部分代理使用。",
84198410
"xpack.ingestManager.deleteDatasource.confirmModal.affectedAgentsTitle": "此操作将影响 {agentsCount} 个 {agentsCount, plural, one {代理} other {代理}}。",
84208411
"xpack.ingestManager.deleteDatasource.confirmModal.cancelButtonLabel": "取消",
@@ -8437,9 +8428,7 @@
84378428
"xpack.ingestManager.editConfig.successNotificationTitle": "代理配置“{name}”已更新",
84388429
"xpack.ingestManager.enrollmentApiKeyForm.namePlaceholder": "选择名称",
84398430
"xpack.ingestManager.enrollmentApiKeyList.createNewButton": "创建新密钥",
8440-
"xpack.ingestManager.enrollmentApiKeyList.hideTableButton": "隐藏",
84418431
"xpack.ingestManager.enrollmentApiKeyList.useExistingsButton": "使用现有密钥",
8442-
"xpack.ingestManager.enrollmentApiKeyList.viewTableButton": "查看",
84438432
"xpack.ingestManager.epm.addDatasourceButtonText": "创建数据源",
84448433
"xpack.ingestManager.epm.pageSubtitle": "浏览热门应用和服务的软件。",
84458434
"xpack.ingestManager.epm.pageTitle": "Elastic Package Manager",

0 commit comments

Comments
 (0)