Skip to content

Commit

Permalink
Fix types from other plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Jun 29, 2023
1 parent b070bd9 commit b50a3e0
Show file tree
Hide file tree
Showing 26 changed files with 52 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const connectors = [
config: {},
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
referencedByCount: 1,
},
{
Expand All @@ -47,6 +48,7 @@ const connectors = [
name: 'Email (preconfigured)',
config: {},
isPreconfigured: true,
isSystemAction: false,
isDeprecated: false,
referencedByCount: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const connectors = [
config: {},
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
referencedByCount: 1,
},
{
Expand All @@ -47,6 +48,7 @@ const connectors = [
config: {},
isPreconfigured: true,
isDeprecated: false,
isSystemAction: false,
referencedByCount: 1,
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ describe('importRuleActionConnectors', () => {
id: 'cabc78e0-9031-11ed-b076-53cc4d57aaf1',
referencedByCount: 1,
isDeprecated: false,
isSystemAction: false,
},
]);
const actionsImporter2 = core.savedObjects.getImporter;
Expand Down Expand Up @@ -358,6 +359,7 @@ describe('importRuleActionConnectors', () => {
id: 'cabc78e0-9031-11ed-b076-53cc4d57aaf1',
referencedByCount: 1,
isDeprecated: false,
isSystemAction: false,
},
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ describe('utils', () => {
name: 'name',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
},
]);
const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient);
Expand Down Expand Up @@ -918,6 +919,7 @@ describe('utils', () => {
name: 'name',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
},
{
id: '789',
Expand All @@ -926,6 +928,7 @@ describe('utils', () => {
name: 'name',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
},
]);
const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient);
Expand Down Expand Up @@ -976,6 +979,7 @@ describe('utils', () => {
name: 'name',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
},
{
id: '789',
Expand All @@ -984,6 +988,7 @@ describe('utils', () => {
name: 'name',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
},
]);
const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient);
Expand Down Expand Up @@ -1041,6 +1046,7 @@ describe('utils', () => {
name: 'name',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
},
{
id: '789',
Expand All @@ -1049,6 +1055,7 @@ describe('utils', () => {
name: 'name',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
},
]);
const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient);
Expand Down Expand Up @@ -1108,6 +1115,7 @@ describe('utils', () => {
name: 'name',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
},
{
id: '789',
Expand All @@ -1116,6 +1124,7 @@ describe('utils', () => {
name: 'name',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
},
]);
const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient);
Expand Down Expand Up @@ -1216,6 +1225,7 @@ describe('utils', () => {
name: 'name',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
},
{
id: '789',
Expand All @@ -1224,6 +1234,7 @@ describe('utils', () => {
name: 'name',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
},
]);
const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const actionConnector = {
},
id: 'es index connector',
isPreconfigured: false,
isSystemAction: false as const,
isDeprecated: false,
name: 'test name',
secrets: {},
Expand All @@ -45,6 +46,7 @@ const preconfiguredActionConnector = {
},
id: AlertHistoryEsIndexConnectorId,
isPreconfigured: true,
isSystemAction: false as const,
isDeprecated: false,
name: 'Alert history Elasticsearch index',
secrets: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ describe('Gen AI Params Fields renders', () => {
id: 'test',
actionTypeId: '.gen-ai',
isPreconfigured: false,
isSystemAction: false as const,
isDeprecated: false,
name: 'My GenAI Connector',
config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const connector: ActionConnector = {
name: 'Test',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false as const,
};
const editAction = jest.fn();
const defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const deprecatedConnector: ActionConnector = {
name: 'Test',
isPreconfigured: false,
isDeprecated: true,
isSystemAction: false as const,
};

const validConnector = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const ServiceNowConnectorFields: React.FC<ActionConnectorFieldsProps> = ({
...connectorToUpdate,
isDeprecated,
isPreconfigured: false,
isSystemAction: false,
actionTypeId,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const actionConnector = {
actionTypeId: '.servicenow',
name: 'ServiceNow ITSM',
isPreconfigured: false,
isSystemAction: false as const,
isDeprecated: false,
config: {
apiUrl: 'https://dev94428.service-now.com/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const actionConnector = {
actionTypeId: '.servicenow',
name: 'ServiceNow ITSM',
isPreconfigured: false,
isSystemAction: false as const,
isDeprecated: false,
config: {
apiUrl: 'https://dev94428.service-now.com/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('OpsgenieParamFields', () => {
actionTypeId: '.test',
name: 'Test',
isPreconfigured: false,
isSystemAction: false as const,
isDeprecated: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const connector = {
actionTypeId: '.test',
name: 'Test',
isPreconfigured: false,
isSystemAction: false as const,
isDeprecated: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const connector: ActionConnector = {
actionTypeId: '.test',
name: 'Test',
isPreconfigured: false,
isSystemAction: false as const,
isDeprecated: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const connector: ActionConnector = {
actionTypeId: '.test',
name: 'Test',
isPreconfigured: false,
isSystemAction: false as const,
isDeprecated: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const connector: ActionConnector = {
actionTypeId: '.test',
name: 'Test',
isPreconfigured: false,
isSystemAction: false as const,
isDeprecated: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('SwimlaneParamsFields renders', () => {
actionTypeId: '.test',
name: 'Test',
isPreconfigured: false,
isSystemAction: false as const,
isDeprecated: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const fetchConnectors = async (): Promise<ActionConnector[]> => {
is_preconfigured: isPreconfigured,
is_deprecated: isDeprecated,
is_missing_secrets: isMissingSecrets,
is_system_action: isSystemAction,
...res
}) => ({
...res,
Expand All @@ -69,6 +70,7 @@ export const fetchConnectors = async (): Promise<ActionConnector[]> => {
isDeprecated,
isPreconfigured,
isMissingSecrets,
isSystemAction,
})
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export async function loadAllActions({ http }: { http: HttpSetup }): Promise<Act
const res = await http.get<Parameters<typeof rewriteResponseRes>[0]>(
`${BASE_ACTION_API_PATH}/connectors`
);
return rewriteResponseRes(res);

return rewriteResponseRes(res) as ActionConnector[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ export async function createActionConnector({
`${BASE_ACTION_API_PATH}/connector`,
{ body: JSON.stringify(rewriteBodyRequest(connector)) }
);
return rewriteBodyRes(res);
return rewriteBodyRes(res) as ActionConnector;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ export async function updateActionConnector({
}
);

return rewriteBodyRes(res);
return rewriteBodyRes(res) as ActionConnector;
}
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ function getActionTypeForm({
id: 'test',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
isSystemAction: false as const,
name: 'test name',
secrets: {},
};
Expand All @@ -580,7 +580,7 @@ function getActionTypeForm({
id: 'test',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
isSystemAction: false as const,
name: 'test name',
secrets: {},
},
Expand All @@ -590,7 +590,7 @@ function getActionTypeForm({
actionTypeId: '.server-log',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
isSystemAction: false as const,
config: {},
secrets: {},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('connectors_selection', () => {
id: 'testId',
isPreconfigured: false,
isDeprecated: false,
isSystemAction: false,
isSystemAction: false as const,
name: 'test pagerduty',
secrets: {},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ const EditConnectorFlyoutComponent: React.FC<EditConnectorFlyoutProps> = ({
/>
<EuiFlyoutBody>
{selectedTab === EditConnectorTabs.Configuration ? (
!connector.isPreconfigured ? (
!connector.isPreconfigured && !connector.isSystemAction ? (
<>
{isEdit && (
<>
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/triggers_actions_ui/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,25 @@ export type PreConfiguredActionConnector = Omit<
'config' | 'secrets'
> & {
isPreconfigured: true;
isSystemAction: false;
};

export type UserConfiguredActionConnector<Config, Secrets> = ActionConnectorProps<
Config,
Secrets
> & {
isPreconfigured: false;
isSystemAction: false;
};

export type SystemAction = Omit<ActionConnectorProps<never, never>, 'config' | 'secrets'> & {
isSystemAction: true;
isPreconfigured: false;
};

export type ActionConnector<Config = Record<string, unknown>, Secrets = Record<string, unknown>> =
| PreConfiguredActionConnector
| SystemAction
| UserConfiguredActionConnector<Config, Secrets>;

export type ActionConnectorWithoutId<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const fetchConnectors = async (): Promise<ActionConnector[]> => {
is_preconfigured: isPreconfigured,
is_deprecated: isDeprecated,
is_missing_secrets: isMissingSecrets,
is_system_action: isSystemAction,
...res
}) => ({
...res,
Expand All @@ -46,6 +47,7 @@ export const fetchConnectors = async (): Promise<ActionConnector[]> => {
isDeprecated,
isPreconfigured,
isMissingSecrets,
isSystemAction,
})
);
};
Expand Down

0 comments on commit b50a3e0

Please sign in to comment.