Skip to content

Commit

Permalink
Remove newly added uses of kbnVersion
Browse files Browse the repository at this point in the history
These happened on master in the meantime.
  • Loading branch information
rylnd committed Jan 6, 2020
1 parent b4b4635 commit 896d7e0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 37 deletions.
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/siem/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const DEFAULT_SEARCH_AFTER_PAGE_SIZE = 100;
export const DEFAULT_ANOMALY_SCORE = 'siem:defaultAnomalyScore';
export const DEFAULT_MAX_TABLE_QUERY_SIZE = 10000;
export const DEFAULT_SCALE_DATE_FORMAT = 'dateFormat:scaled';
export const DEFAULT_KBN_VERSION = 'kbnVersion';
export const DEFAULT_FROM = 'now-24h';
export const DEFAULT_TO = 'now';
export const DEFAULT_INTERVAL_PAUSE = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,15 @@ export const updateSignalStatus = async ({
/**
* Fetch Signal Index
*
* @param kbnVersion current Kibana Version to use for headers
* @param signal AbortSignal for cancelling request
*/
export const getSignalIndex = async ({
kbnVersion,
signal,
}: BasicSignals): Promise<SignalsIndex | null> => {
export const getSignalIndex = async ({ signal }: BasicSignals): Promise<SignalsIndex | null> => {
const response = await fetch(`${chrome.getBasePath()}${DETECTION_ENGINE_INDEX_URL}`, {
method: 'GET',
credentials: 'same-origin',
headers: {
'content-type': 'application/json',
'kbn-version': kbnVersion,
'kbn-xsrf': kbnVersion,
'kbn-xsrf': 'true',
},
signal,
});
Expand All @@ -111,20 +106,15 @@ export const getSignalIndex = async ({
/**
* Get User Privileges
*
* @param kbnVersion current Kibana Version to use for headers
* @param signal AbortSignal for cancelling request
*/
export const getUserPrivilege = async ({
kbnVersion,
signal,
}: BasicSignals): Promise<Privilege | null> => {
export const getUserPrivilege = async ({ signal }: BasicSignals): Promise<Privilege | null> => {
const response = await fetch(`${chrome.getBasePath()}${DETECTION_ENGINE_PRIVILEGES_URL}`, {
method: 'GET',
credentials: 'same-origin',
headers: {
'content-type': 'application/json',
'kbn-version': kbnVersion,
'kbn-xsrf': kbnVersion,
'kbn-xsrf': 'true',
},
signal,
});
Expand All @@ -136,20 +126,15 @@ export const getUserPrivilege = async ({
/**
* Create Signal Index if needed it
*
* @param kbnVersion current Kibana Version to use for headers
* @param signal AbortSignal for cancelling request
*/
export const createSignalIndex = async ({
kbnVersion,
signal,
}: BasicSignals): Promise<SignalsIndex | null> => {
export const createSignalIndex = async ({ signal }: BasicSignals): Promise<SignalsIndex | null> => {
const response = await fetch(`${chrome.getBasePath()}${DETECTION_ENGINE_INDEX_URL}`, {
method: 'POST',
credentials: 'same-origin',
headers: {
'content-type': 'application/json',
'kbn-version': kbnVersion,
'kbn-xsrf': kbnVersion,
'kbn-xsrf': 'true',
},
signal,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import { useEffect, useState } from 'react';

import { DEFAULT_KBN_VERSION } from '../../../../common/constants';
import { useUiSetting$ } from '../../../lib/kibana';
import { getUserPrivilege } from './api';

type Return = [boolean, boolean | null, boolean | null];
Expand All @@ -20,7 +18,6 @@ export const usePrivilegeUser = (): Return => {
const [loading, setLoading] = useState(true);
const [isAuthenticated, setAuthenticated] = useState<boolean | null>(null);
const [hasWrite, setHasWrite] = useState<boolean | null>(null);
const [kbnVersion] = useUiSetting$<string>(DEFAULT_KBN_VERSION);

useEffect(() => {
let isSubscribed = true;
Expand All @@ -30,7 +27,6 @@ export const usePrivilegeUser = (): Return => {
async function fetchData() {
try {
const privilege = await getUserPrivilege({
kbnVersion,
signal: abortCtrl.signal,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

import { useEffect, useState, useRef } from 'react';

import { DEFAULT_KBN_VERSION } from '../../../../common/constants';
import { errorToToaster } from '../../../components/ml/api/error_to_toaster';
import { useStateToaster } from '../../../components/toasters';
import { useUiSetting$ } from '../../../lib/kibana';
import { createSignalIndex, getSignalIndex } from './api';
import * as i18n from './translations';
import { PostSignalError } from './types';
Expand All @@ -28,7 +26,6 @@ export const useSignalIndex = (): Return => {
const [signalIndexName, setSignalIndexName] = useState<string | null>(null);
const [signalIndexExists, setSignalIndexExists] = useState<boolean | null>(null);
const createDeSignalIndex = useRef<Func | null>(null);
const [kbnVersion] = useUiSetting$<string>(DEFAULT_KBN_VERSION);
const [, dispatchToaster] = useStateToaster();

useEffect(() => {
Expand All @@ -38,10 +35,7 @@ export const useSignalIndex = (): Return => {
const fetchData = async () => {
try {
setLoading(true);
const signal = await getSignalIndex({
kbnVersion,
signal: abortCtrl.signal,
});
const signal = await getSignalIndex({ signal: abortCtrl.signal });

if (isSubscribed && signal != null) {
setSignalIndexName(signal.name);
Expand All @@ -62,10 +56,7 @@ export const useSignalIndex = (): Return => {
let isFetchingData = false;
try {
setLoading(true);
await createSignalIndex({
kbnVersion,
signal: abortCtrl.signal,
});
await createSignalIndex({ signal: abortCtrl.signal });

if (isSubscribed) {
isFetchingData = true;
Expand Down

0 comments on commit 896d7e0

Please sign in to comment.