From 62870d55b6b4853192e715f950e35b16e08c4125 Mon Sep 17 00:00:00 2001 From: Mohamad Choupan Date: Fri, 3 Jan 2025 19:21:06 +0330 Subject: [PATCH 1/4] feat: cleanup compliance part1 --- services/web-ui/src/api/api.ts | 481 +------ services/web-ui/src/api/compliance.gen.ts | 1166 +---------------- .../NewBenchmarkSummary/Evaluate/index.tsx | 4 +- .../EvaluateTable/EvaluateDetail/inde.tsx | 10 +- .../EvaluateTable/index.tsx | 6 +- .../Findings/Filter/index.tsx | 2 +- .../NewBenchmarkSummary/Settings/index.tsx | 7 +- .../Compliance/NewBenchmarkSummary/index.tsx | 6 +- .../Tabs/ControlFindings/Filter/index.tsx | 2 +- .../Findings/ControlsWithFailure/index.tsx | 1 - .../Governance/Findings/Filter/index.tsx | 2 +- .../pages/Insights/ScoreCategory/index.tsx | 6 +- .../web-ui/src/pages/Search/View/index.tsx | 2 +- .../src/pages/Settings/APIKeys/index.tsx | 2 +- 14 files changed, 59 insertions(+), 1638 deletions(-) diff --git a/services/web-ui/src/api/api.ts b/services/web-ui/src/api/api.ts index 6f0b642ed..51db3956f 100644 --- a/services/web-ui/src/api/api.ts +++ b/services/web-ui/src/api/api.ts @@ -4364,30 +4364,7 @@ export class Api< }), } compliance = { - /** - * No description - * - * @tags compliance - * @name ApiV1AiControlRemediationCreate - * @summary Get control remediation using AI - * @request POST:/compliance/api/v1/ai/control/{controlID}/remediation - * @secure - */ - apiV1AiControlRemediationCreate: ( - controlId: string, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkRemediation, - any - >({ - path: `/compliance/api/v1/ai/control/${controlId}/remediation`, - method: 'POST', - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), + /** * @description API for get new control list * @@ -4524,165 +4501,9 @@ export class Api< ...params, }), - /** - * @description Retrieving all benchmark assigned to a connection with connection id - * - * @tags benchmarks_assignment - * @name ApiV1AssignmentsConnectionDetail - * @summary Get list of benchmark assignments for a connection - * @request GET:/compliance/api/v1/assignments/connection/{connection_id} - * @secure - */ - apiV1AssignmentsConnectionDetail: ( - connectionId: string, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiAssignedBenchmark[], - any - >({ - path: `/compliance/api/v1/assignments/connection/${connectionId}`, - method: 'GET', - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), - - /** - * @description Retrieving all benchmark assigned to a resource collection with resource collection id - * - * @tags benchmarks_assignment - * @name ApiV1AssignmentsResourceCollectionDetail - * @summary Get list of benchmark assignments for a resource collection - * @request GET:/compliance/api/v1/assignments/resource_collection/{resource_collection_id} - * @secure - */ - apiV1AssignmentsResourceCollectionDetail: ( - resourceCollectionId: string, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiAssignedBenchmark[], - any - >({ - path: `/compliance/api/v1/assignments/resource_collection/${resourceCollectionId}`, - method: 'GET', - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), - - /** - * @description Creating a benchmark assignment for a connection. - * - * @tags benchmarks_assignment - * @name ApiV1AssignmentsConnectionCreate - * @summary Create benchmark assignment - * @request POST:/compliance/api/v1/assignments/{benchmark_id}/connection - * @secure - */ - apiV1AssignmentsConnectionCreate: ( - benchmarkId: string, - query?: { - /** Auto enable benchmark for connections */ - auto_assign?: boolean - /** Connection ID or 'all' for everything */ - connectionId?: string[] - /** Connection group */ - connectionGroup?: string[] - /** Resource collection */ - resourceCollection?: string[] - }, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkAssignment[], - any - >({ - path: `/compliance/api/v1/assignments/${benchmarkId}/connection`, - method: 'POST', - query: query, - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), - - /** - * @description Delete benchmark assignment with source id and benchmark id - * - * @tags benchmarks_assignment - * @name ApiV1AssignmentsConnectionDelete - * @summary Delete benchmark assignment - * @request DELETE:/compliance/api/v1/assignments/{benchmark_id}/connection - * @secure - */ - apiV1AssignmentsConnectionDelete: ( - benchmarkId: string, - query?: { - /** Connection ID or 'all' for everything */ - connectionId?: string[] - /** Connection Group */ - connectionGroup?: string[] - /** Resource Collection */ - resourceCollection?: string[] - }, - params: RequestParams = {} - ) => - this.request({ - path: `/compliance/api/v1/assignments/${benchmarkId}/connection`, - method: 'DELETE', - query: query, - secure: true, - type: ContentType.Json, - ...params, - }), - - /** - * @description Retrieving a summary of all benchmarks and their associated checks and results within a specified time interval. - * - * @tags compliance - * @name ApiV1BenchmarksSummaryList - * @summary List benchmarks summaries - * @request GET:/compliance/api/v1/benchmarks/summary - * @secure - */ - apiV1BenchmarksSummaryList: ( - query?: { - /** Connection IDs to filter by */ - connectionId?: string[] - /** Connection groups to filter by */ - connectionGroup?: string[] - /** Resource collection IDs to filter by */ - resourceCollection?: string[] - /** Connector type to filter by */ - connector?: ('' | 'AWS' | 'Azure')[] - /** Key-Value tags in key=value format to filter by */ - tag?: string[] - /** timestamp for values in epoch seconds */ - timeAt?: number - /** - * Top account count - * @default 3 - */ - topAccountCount?: number - }, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiListBenchmarksSummaryResponse, - any - >({ - path: `/compliance/api/v1/benchmarks/summary`, - method: 'GET', - query: query, - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), + + + /** * No description @@ -4720,41 +4541,7 @@ export class Api< ...params, }), - /** - * No description - * - * @tags compliance - * @name ApiV1BenchmarksControlsDetail2 - * @summary Get benchmark controls - * @request GET:/compliance/api/v1/benchmarks/{benchmark_id}/controls/{controlId} - * @originalName apiV1BenchmarksControlsDetail - * @duplicate - * @secure - */ - apiV1BenchmarksControlsDetail2: ( - benchmarkId: string, - controlId: string, - query?: { - /** Connection IDs to filter by */ - connectionId?: string[] - /** Connection groups to filter by */ - connectionGroup?: string[] - }, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiControlSummary, - any - >({ - path: `/compliance/api/v1/benchmarks/${benchmarkId}/controls/${controlId}`, - method: 'GET', - query: query, - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), - + /** * @description Changes benchmark settings. * @@ -4824,81 +4611,8 @@ export class Api< ...params, }), - /** - * @description Retrieving a trend of a benchmark result and checks. - * - * @tags compliance - * @name ApiV1BenchmarksTrendDetail - * @summary Get benchmark trend - * @request GET:/compliance/api/v1/benchmarks/{benchmark_id}/trend - * @secure - */ - apiV1BenchmarksTrendDetail: ( - benchmarkId: string, - query?: { - /** Connection IDs to filter by */ - connectionId?: string[] - /** Connection groups to filter by */ - connectionGroup?: string[] - /** Resource collection IDs to filter by */ - resourceCollection?: string[] - /** Connector type to filter by */ - connector?: ('' | 'AWS' | 'Azure')[] - /** timestamp for start of the chart in epoch seconds */ - startTime?: number - /** timestamp for end of the chart in epoch seconds */ - endTime?: number - }, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkTrendDatapoint[], - any - >({ - path: `/compliance/api/v1/benchmarks/${benchmarkId}/trend`, - method: 'GET', - query: query, - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), - - /** - * No description - * - * @tags compliance - * @name ApiV1ControlsSummaryList - * @summary List controls summaries - * @request GET:/compliance/api/v1/controls/summary - * @secure - */ - apiV1ControlsSummaryList: ( - query?: { - /** Control IDs to filter by */ - controlId?: string[] - /** Connection IDs to filter by */ - connectionId?: string[] - /** Connection groups to filter by */ - connectionGroup?: string[] - /** Key-Value tags in key=value format to filter by */ - tag?: string[] - }, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiControlSummary[], - any - >({ - path: `/compliance/api/v1/controls/summary`, - method: 'GET', - query: query, - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), - + + /** * No description * @@ -4931,47 +4645,6 @@ export class Api< ...params, }), - /** - * No description - * - * @tags compliance - * @name ApiV1ControlsTrendDetail - * @summary Get control trend - * @request GET:/compliance/api/v1/controls/{controlId}/trend - * @secure - */ - apiV1ControlsTrendDetail: ( - controlId: string, - query?: { - /** Connection IDs to filter by */ - connectionId?: string[] - /** Connection groups to filter by */ - connectionGroup?: string[] - /** timestamp for start of the chart in epoch seconds */ - startTime?: number - /** timestamp for end of the chart in epoch seconds */ - endTime?: number - /** - * granularity of the chart - * @default "daily" - */ - granularity?: 'daily' | 'monthly' - }, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiControlTrendDatapoint[], - any - >({ - path: `/compliance/api/v1/controls/${controlId}/trend`, - method: 'GET', - query: query, - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), - /** * @description Retrieving all compliance finding events with respect to filters. * @@ -5113,36 +4786,7 @@ export class Api< ...params, }), - /** - * @description Retrieving all compliance run findings count with respect to filters. - * - * @tags compliance - * @name ApiV1FindingsCountList - * @summary Get findings count - * @request GET:/compliance/api/v1/compliance_result/count - * @secure - */ - apiV1FindingsCountList: ( - query?: { - /** ConformanceStatus to filter by defaults to all conformanceStatus except passed */ - conformanceStatus?: ('failed' | 'passed')[] - /** StateActive to filter by defaults to true */ - stateActive?: boolean[] - }, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiCountFindingsResponse, - any - >({ - path: `/compliance/api/v1/compliance_result/count`, - method: 'GET', - query: query, - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), + /** * @description Retrieving all compliance run finding events with respect to filters. @@ -5192,28 +4836,7 @@ export class Api< ...params, }), - /** - * @description Retrieving KPIs for findings. - * - * @tags compliance - * @name ApiV1FindingsKpiList - * @summary Get finding KPIs - * @request GET:/compliance/api/v1/compliance_result/kpi - * @secure - */ - apiV1FindingsKpiList: (params: RequestParams = {}) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiFindingKPIResponse, - any - >({ - path: `/compliance/api/v1/compliance_result/kpi`, - method: 'GET', - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), - + /** * @description Retrieving a single finding * @@ -5378,65 +5001,7 @@ export class Api< ...params, }), - /** - * @description Retrieving the number of findings field count by controls. - * - * @tags compliance - * @name ApiV1FindingsCountDetail - * @summary Get findings field count by controls - * @request GET:/compliance/api/v1/compliance_result/{benchmarkId}/{field}/count - * @secure - */ - apiV1FindingsCountDetail: ( - benchmarkId: string, - field: 'resourceType' | 'integrationID' | 'resourceID' | 'service', - query?: { - /** Connection IDs to filter by */ - connectionId?: string[] - /** Connection groups to filter by */ - connectionGroup?: string[] - /** Resource collection IDs to filter by */ - resourceCollection?: string[] - /** Connector type to filter by */ - connector?: ('' | 'AWS' | 'Azure')[] - /** Severities to filter by defaults to all severities except passed */ - severities?: ('none' | 'low' | 'medium' | 'high' | 'critical')[] - /** ConformanceStatus to filter by defaults to failed */ - conformanceStatus?: ('failed' | 'passed')[] - }, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgComplianceApiGetTopFieldResponse, - any - >({ - path: `/compliance/api/v1/compliance_result/${benchmarkId}/${field}/count`, - method: 'GET', - query: query, - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), - - /** - * @description Retrieving a list of compliance tag keys with their possible values. - * - * @tags compliance - * @name ApiV1MetadataTagComplianceList - * @summary List compliance tag keys - * @request GET:/compliance/api/v1/metadata/tag/compliance - * @secure - */ - apiV1MetadataTagComplianceList: (params: RequestParams = {}) => - this.request, any>({ - path: `/compliance/api/v1/metadata/tag/compliance`, - method: 'GET', - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), + /** * @description Syncs queries with the git backend. @@ -5488,31 +5053,7 @@ export class Api< format: 'json', ...params, }), - /** - * @description Retrieving list of categories for all controls - * - * @tags analytics - * @name ApiV3ComplianceControlCategoryList - * @summary List Analytics categories - * @request GET:/compliance/api/v3/controls/categories - * @secure - */ - apiV3ComplianceControlCategoryList: ( - query: string[] | undefined, - params: RequestParams = {} - ) => - this.request< - GithubComKaytuIoKaytuEnginePkgInventoryApiInventoryCategoriesResponse, - any - >({ - path: `/compliance/api/v3/controls/categories`, - method: 'GET', - query: query, - secure: true, - type: ContentType.Json, - format: 'json', - ...params, - }), + } integration = { /** diff --git a/services/web-ui/src/api/compliance.gen.ts b/services/web-ui/src/api/compliance.gen.ts index 5d8f9b874..6ecae2ac1 100755 --- a/services/web-ui/src/api/compliance.gen.ts +++ b/services/web-ui/src/api/compliance.gen.ts @@ -41,920 +41,12 @@ import { import AxiosAPI, { setWorkspace } from './ApiConfig' -interface IuseComplianceApiV1AiControlRemediationCreateState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkRemediation - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1AiControlRemediationCreate = ( - controlId: string, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([controlId, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqcontrolId: string, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1AiControlRemediationCreate(reqcontrolId, reqparamsSignal) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if (JSON.stringify([controlId, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([controlId, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, controlId, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, controlId, params) - } - - const sendNowWithParams = ( - reqcontrolId: string, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqcontrolId, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1AssignmentsBenchmarkDetailState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkAssignedEntities - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1AssignmentsBenchmarkDetail = ( - benchmarkId: string, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([benchmarkId, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqbenchmarkId: string, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1AssignmentsBenchmarkDetail( - reqbenchmarkId, - reqparamsSignal - ) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if (JSON.stringify([benchmarkId, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([benchmarkId, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, params) - } - - const sendNowWithParams = ( - reqbenchmarkId: string, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqbenchmarkId, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1AssignmentsConnectionDetailState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiAssignedBenchmark[] - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1AssignmentsConnectionDetail = ( - connectionId: string, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([connectionId, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqconnectionId: string, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1AssignmentsConnectionDetail( - reqconnectionId, - reqparamsSignal - ) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if (JSON.stringify([connectionId, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([connectionId, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, connectionId, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, connectionId, params) - } - - const sendNowWithParams = ( - reqconnectionId: string, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqconnectionId, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1AssignmentsResourceCollectionDetailState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiAssignedBenchmark[] - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1AssignmentsResourceCollectionDetail = ( - resourceCollectionId: string, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([resourceCollectionId, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqresourceCollectionId: string, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1AssignmentsResourceCollectionDetail( - reqresourceCollectionId, - reqparamsSignal - ) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if ( - JSON.stringify([resourceCollectionId, params, autoExecute]) !== - lastInput - ) { - setLastInput( - JSON.stringify([resourceCollectionId, params, autoExecute]) - ) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, resourceCollectionId, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, resourceCollectionId, params) - } - - const sendNowWithParams = ( - reqresourceCollectionId: string, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqresourceCollectionId, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1AssignmentsConnectionCreateState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkAssignment[] - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1AssignmentsConnectionCreate = ( - benchmarkId: string, - query?: { - auto_assign?: boolean - - connectionId?: string[] - - connectionGroup?: string[] - - resourceCollection?: string[] - }, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([benchmarkId, query, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqbenchmarkId: string, - reqquery: - | { - auto_assign?: boolean - - connectionId?: string[] - - connectionGroup?: string[] - - resourceCollection?: string[] - } - | undefined, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1AssignmentsConnectionCreate( - reqbenchmarkId, - reqquery, - reqparamsSignal - ) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if ( - JSON.stringify([benchmarkId, query, params, autoExecute]) !== lastInput - ) { - setLastInput(JSON.stringify([benchmarkId, query, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, query, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, query, params) - } - - const sendNowWithParams = ( - reqbenchmarkId: string, - reqquery: - | { - auto_assign?: boolean - - connectionId?: string[] - - connectionGroup?: string[] - - resourceCollection?: string[] - } - | undefined, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqbenchmarkId, reqquery, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1AssignmentsConnectionDeleteState { - isLoading: boolean - isExecuted: boolean - response?: void - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1AssignmentsConnectionDelete = ( - benchmarkId: string, - query?: { - connectionId?: string[] - - connectionGroup?: string[] - - resourceCollection?: string[] - }, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([benchmarkId, query, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqbenchmarkId: string, - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - - resourceCollection?: string[] - } - | undefined, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1AssignmentsConnectionDelete( - reqbenchmarkId, - reqquery, - reqparamsSignal - ) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if ( - JSON.stringify([benchmarkId, query, params, autoExecute]) !== lastInput - ) { - setLastInput(JSON.stringify([benchmarkId, query, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, query, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, query, params) - } - - const sendNowWithParams = ( - reqbenchmarkId: string, - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - - resourceCollection?: string[] - } - | undefined, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqbenchmarkId, reqquery, reqparams) - } - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} -interface IuseComplianceApiV1BenchmarksSummaryListState { +interface IuseComplianceApiV1AssignmentsBenchmarkDetailState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiListBenchmarksSummaryResponse + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkAssignedEntities // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -962,22 +54,8 @@ interface IuseComplianceApiV1BenchmarksSummaryListState { /** * URL: */ -export const useComplianceApiV1BenchmarksSummaryList = ( - query?: { - connectionId?: string[] - - connectionGroup?: string[] - - resourceCollection?: string[] - - connector?: ('' | 'AWS' | 'Azure')[] - - tag?: string[] - - timeAt?: number - - topAccountCount?: number - }, +export const useComplianceApiV1AssignmentsBenchmarkDetail = ( + benchmarkId: string, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -989,33 +67,17 @@ export const useComplianceApiV1BenchmarksSummaryList = ( api.instance = AxiosAPI const [state, setState] = - useState({ + useState({ isLoading: true, isExecuted: false, }) const [lastInput, setLastInput] = useState( - JSON.stringify([query, params, autoExecute]) + JSON.stringify([benchmarkId, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - - resourceCollection?: string[] - - connector?: ('' | 'AWS' | 'Azure')[] - - tag?: string[] - - timeAt?: number - - topAccountCount?: number - } - | undefined, + reqbenchmarkId: string, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -1039,7 +101,10 @@ export const useComplianceApiV1BenchmarksSummaryList = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1BenchmarksSummaryList(reqquery, reqparamsSignal) + .apiV1AssignmentsBenchmarkDetail( + reqbenchmarkId, + reqparamsSignal + ) .then((resp) => { setState({ ...state, @@ -1075,8 +140,8 @@ export const useComplianceApiV1BenchmarksSummaryList = ( } } - if (JSON.stringify([query, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([query, params, autoExecute])) + if (JSON.stringify([benchmarkId, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([benchmarkId, params, autoExecute])) } useEffect(() => { @@ -1084,7 +149,7 @@ export const useComplianceApiV1BenchmarksSummaryList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, query, params) + sendRequest(newController, benchmarkId, params) } }, [lastInput]) @@ -1096,33 +161,17 @@ export const useComplianceApiV1BenchmarksSummaryList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, query, params) + sendRequest(newController, benchmarkId, params) } const sendNowWithParams = ( - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - - resourceCollection?: string[] - - connector?: ('' | 'AWS' | 'Azure')[] - - tag?: string[] - - timeAt?: number - - topAccountCount?: number - } - | undefined, + reqbenchmarkId: string, reqparams: RequestParams ) => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqquery, reqparams) + sendRequest(newController, reqbenchmarkId, reqparams) } return { @@ -1135,6 +184,13 @@ export const useComplianceApiV1BenchmarksSummaryList = ( } } + + + + + + + interface IuseComplianceApiV1BenchmarksControlsDetailState { isLoading: boolean isExecuted: boolean @@ -1310,181 +366,7 @@ export const useComplianceApiV1BenchmarksControlsDetail = ( } } -interface IuseComplianceApiV1BenchmarksControlsDetail2State { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiControlSummary - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1BenchmarksControlsDetail2 = ( - benchmarkId: string, - controlId: string, - query?: { - connectionId?: string[] - - connectionGroup?: string[] - }, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([benchmarkId, controlId, query, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqbenchmarkId: string, - reqcontrolId: string, - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - } - | undefined, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1BenchmarksControlsDetail2( - reqbenchmarkId, - reqcontrolId, - reqquery, - reqparamsSignal - ) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if ( - JSON.stringify([benchmarkId, controlId, query, params, autoExecute]) !== - lastInput - ) { - setLastInput( - JSON.stringify([benchmarkId, controlId, query, params, autoExecute]) - ) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, controlId, query, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, controlId, query, params) - } - - const sendNowWithParams = ( - reqbenchmarkId: string, - reqcontrolId: string, - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - } - | undefined, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest( - newController, - reqbenchmarkId, - reqcontrolId, - reqquery, - reqparams - ) - } - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} interface IuseComplianceApiV3ControlListFilters { isLoading: boolean diff --git a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Evaluate/index.tsx b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Evaluate/index.tsx index 9dcb41821..514a52768 100644 --- a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Evaluate/index.tsx +++ b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Evaluate/index.tsx @@ -79,7 +79,7 @@ export default function Evaluate({ // } // }, [assignments]) const RunBenchmark = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL @@ -138,7 +138,7 @@ export default function Evaluate({ } const GetEnabled = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setLoading(true) let url = '' if (window.location.origin === 'http://localhost:3000') { diff --git a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/EvaluateTable/EvaluateDetail/inde.tsx b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/EvaluateTable/EvaluateDetail/inde.tsx index 7ba8e407f..6ca3372b2 100644 --- a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/EvaluateTable/EvaluateDetail/inde.tsx +++ b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/EvaluateTable/EvaluateDetail/inde.tsx @@ -126,7 +126,7 @@ export default function EvaluateDetail() { const [integrationDetail,setIntegrationDetail]= useState() const [integrationDetailLoading,setIntegrationDetailLoading]= useState(false) const GetDetail = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setDetailLoading(true) let url = '' if (window.location.origin === 'http://localhost:3000') { @@ -163,7 +163,7 @@ export default function EvaluateDetail() { } const GetControls = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setDetailLoading(true) let url = '' if (window.location.origin === 'http://localhost:3000') { @@ -206,7 +206,7 @@ export default function EvaluateDetail() { }) } const GetResults = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setDetailLoading(true) let url = '' if (window.location.origin === 'http://localhost:3000') { @@ -252,7 +252,7 @@ export default function EvaluateDetail() { } const GetFullResults = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setFullLoading(true) let url = '' if (window.location.origin === 'http://localhost:3000') { @@ -292,7 +292,7 @@ export default function EvaluateDetail() { }) } const GetIntegrationDetail = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setIntegrationDetailLoading(true) let url = '' if (window.location.origin === 'http://localhost:3000') { diff --git a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/EvaluateTable/index.tsx b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/EvaluateTable/index.tsx index a70b87ce2..112e8edf6 100644 --- a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/EvaluateTable/index.tsx +++ b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/EvaluateTable/index.tsx @@ -115,7 +115,7 @@ export default function EvaluateTable({ type: 'relative', }) const GetHistory = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setLoading(true) let url = '' if (window.location.origin === 'http://localhost:3000') { @@ -185,7 +185,7 @@ export default function EvaluateTable({ }) } const GetIntegrations = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setLoadingI(true) let url = '' if (window.location.origin === 'http://localhost:3000') { @@ -220,7 +220,7 @@ export default function EvaluateTable({ } const GetDetail = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setLoading(true) let url = '' if (window.location.origin === 'http://localhost:3000') { diff --git a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Findings/Filter/index.tsx b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Findings/Filter/index.tsx index 6069186c6..0f9c9b770 100644 --- a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Findings/Filter/index.tsx +++ b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Findings/Filter/index.tsx @@ -127,7 +127,7 @@ export default function Filter({ onApply, type, setDate }: IFilters) { const { benchmarkId } = useParams() const GetJobs = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL diff --git a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Settings/index.tsx b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Settings/index.tsx index 6b2402ce3..b0c9c88b4 100644 --- a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Settings/index.tsx +++ b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Settings/index.tsx @@ -224,7 +224,7 @@ export default function Settings({ } }, [enableExecuted, disableExecuted, enableLoading, disableLoading]) const GetEnabled = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setLoading(true) let url = '' if (window.location.origin === 'http://localhost:3000') { @@ -258,7 +258,7 @@ export default function Settings({ }) } const ChangeStatus = (status: string) => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setLoading(true) setEnableStatus(status) let url = '' @@ -294,8 +294,7 @@ export default function Settings({ }) } const ChangeStatusItem = (status: string,tracker_id: string) => { - console.log("salan"); - console.log(tracker_id); + setLoading(true); setEnableStatus(status); let url = '' diff --git a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/index.tsx b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/index.tsx index 45b705aec..978d8e261 100644 --- a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/index.tsx +++ b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/index.tsx @@ -285,7 +285,7 @@ export default function NewBenchmarkSummary() { endTime: activeTimeRange.end.unix(), }) const GetEnabled = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL @@ -334,7 +334,7 @@ export default function NewBenchmarkSummary() { }) } const GetChart = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL @@ -401,7 +401,7 @@ export default function NewBenchmarkSummary() { }) } const RunBenchmark = (c: any[],b: boolean) => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL diff --git a/services/web-ui/src/pages/Governance/Controls/ControlSummary/Tabs/ControlFindings/Filter/index.tsx b/services/web-ui/src/pages/Governance/Controls/ControlSummary/Tabs/ControlFindings/Filter/index.tsx index 6f996ab6e..a376ef99a 100644 --- a/services/web-ui/src/pages/Governance/Controls/ControlSummary/Tabs/ControlFindings/Filter/index.tsx +++ b/services/web-ui/src/pages/Governance/Controls/ControlSummary/Tabs/ControlFindings/Filter/index.tsx @@ -115,7 +115,7 @@ export default function Filter({ onApply, type, setDate }: IFilters) { const [jobData, setJobData] = useState([]) const [jobs, setJobs] = useState([]) const GetJobs = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL diff --git a/services/web-ui/src/pages/Governance/Findings/ControlsWithFailure/index.tsx b/services/web-ui/src/pages/Governance/Findings/ControlsWithFailure/index.tsx index cfda75025..a5ab4eb56 100644 --- a/services/web-ui/src/pages/Governance/Findings/ControlsWithFailure/index.tsx +++ b/services/web-ui/src/pages/Governance/Findings/ControlsWithFailure/index.tsx @@ -10,7 +10,6 @@ import { TypesFindingSeverity, } from '../../../../api/api' import Table, { IColumn } from '../../../../components/Table' -import { topControls } from '../../Compliance/BenchmarkSummary/TopDetails/Controls' import { severityBadge } from '../../Controls' import { DateRange, searchAtom } from '../../../../utilities/urlstate' import { useEffect, useState } from 'react' diff --git a/services/web-ui/src/pages/Governance/Findings/Filter/index.tsx b/services/web-ui/src/pages/Governance/Findings/Filter/index.tsx index 6515642be..30fd81c32 100644 --- a/services/web-ui/src/pages/Governance/Findings/Filter/index.tsx +++ b/services/web-ui/src/pages/Governance/Findings/Filter/index.tsx @@ -127,7 +127,7 @@ export default function Filter({ onApply, type, setDate }: IFilters) { const [jobs, setJobs] = useState([]) const GetJobs = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL diff --git a/services/web-ui/src/pages/Insights/ScoreCategory/index.tsx b/services/web-ui/src/pages/Insights/ScoreCategory/index.tsx index 2c727a572..d13d19c36 100644 --- a/services/web-ui/src/pages/Insights/ScoreCategory/index.tsx +++ b/services/web-ui/src/pages/Insights/ScoreCategory/index.tsx @@ -397,7 +397,7 @@ export default function ScoreCategory() { endDate: today.toUTCString(), }) const RunBenchmark = (c: any[]) => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL @@ -481,7 +481,7 @@ export default function ScoreCategory() { const [enable, setEnable] = useState(false) const GetChart = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL @@ -539,7 +539,7 @@ export default function ScoreCategory() { }) } const GetEnabled = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL diff --git a/services/web-ui/src/pages/Search/View/index.tsx b/services/web-ui/src/pages/Search/View/index.tsx index 726c21a8b..bbefef148 100644 --- a/services/web-ui/src/pages/Search/View/index.tsx +++ b/services/web-ui/src/pages/Search/View/index.tsx @@ -258,7 +258,7 @@ export default function View({ setTab }: Props) { // }) const getRows = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setLoading(true) let url = '' if (window.location.origin === 'http://localhost:3000') { diff --git a/services/web-ui/src/pages/Settings/APIKeys/index.tsx b/services/web-ui/src/pages/Settings/APIKeys/index.tsx index 49a2c8019..712214dbf 100644 --- a/services/web-ui/src/pages/Settings/APIKeys/index.tsx +++ b/services/web-ui/src/pages/Settings/APIKeys/index.tsx @@ -84,7 +84,7 @@ const fixRole = (role: string) => { }, [responseDelete,deleteIsExecuted,deleteIsLoading]) const EditKey = () => { - // /compliance/api/v3/benchmark/{benchmark-id}/assignments + setEditLoading(true) let url = '' if (window.location.origin === 'http://localhost:3000') { From 4e6dbff97101e348f10bff5effc891c4a73d47be Mon Sep 17 00:00:00 2001 From: Mohamad Choupan Date: Fri, 3 Jan 2025 19:23:08 +0330 Subject: [PATCH 2/4] feat: cleanup compliance part2 --- services/web-ui/src/api/compliance.gen.ts | 2021 ++++----------------- 1 file changed, 369 insertions(+), 1652 deletions(-) diff --git a/services/web-ui/src/api/compliance.gen.ts b/services/web-ui/src/api/compliance.gen.ts index 6ecae2ac1..5c0b87578 100755 --- a/services/web-ui/src/api/compliance.gen.ts +++ b/services/web-ui/src/api/compliance.gen.ts @@ -976,10 +976,13 @@ export const useComplianceApiV1BenchmarksSummaryDetail = ( } } -interface IuseComplianceApiV1BenchmarksTrendDetailState { + + + +interface IuseComplianceApiV1ControlsSummaryDetailState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkTrendDatapoint[] + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiControlSummary // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -987,20 +990,12 @@ interface IuseComplianceApiV1BenchmarksTrendDetailState { /** * URL: */ -export const useComplianceApiV1BenchmarksTrendDetail = ( - benchmarkId: string, +export const useComplianceApiV1ControlsSummaryDetail = ( + controlId: string, query?: { connectionId?: string[] connectionGroup?: string[] - - resourceCollection?: string[] - - connector?: ('' | 'AWS' | 'Azure')[] - - startTime?: number - - endTime?: number }, params: RequestParams = {}, autoExecute = true, @@ -1013,30 +1008,22 @@ export const useComplianceApiV1BenchmarksTrendDetail = ( api.instance = AxiosAPI const [state, setState] = - useState({ + useState({ isLoading: true, isExecuted: false, }) const [lastInput, setLastInput] = useState( - JSON.stringify([benchmarkId, query, params, autoExecute]) + JSON.stringify([controlId, query, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqbenchmarkId: string, + reqcontrolId: string, reqquery: | { connectionId?: string[] connectionGroup?: string[] - - resourceCollection?: string[] - - connector?: ('' | 'AWS' | 'Azure')[] - - startTime?: number - - endTime?: number } | undefined, reqparams: RequestParams @@ -1062,8 +1049,8 @@ export const useComplianceApiV1BenchmarksTrendDetail = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1BenchmarksTrendDetail( - reqbenchmarkId, + .apiV1ControlsSummaryDetail( + reqcontrolId, reqquery, reqparamsSignal ) @@ -1102,10 +1089,8 @@ export const useComplianceApiV1BenchmarksTrendDetail = ( } } - if ( - JSON.stringify([benchmarkId, query, params, autoExecute]) !== lastInput - ) { - setLastInput(JSON.stringify([benchmarkId, query, params, autoExecute])) + if (JSON.stringify([controlId, query, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([controlId, query, params, autoExecute])) } useEffect(() => { @@ -1113,7 +1098,7 @@ export const useComplianceApiV1BenchmarksTrendDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, benchmarkId, query, params) + sendRequest(newController, controlId, query, params) } }, [lastInput]) @@ -1125,24 +1110,16 @@ export const useComplianceApiV1BenchmarksTrendDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, benchmarkId, query, params) + sendRequest(newController, controlId, query, params) } const sendNowWithParams = ( - reqbenchmarkId: string, + reqcontrolId: string, reqquery: | { connectionId?: string[] connectionGroup?: string[] - - resourceCollection?: string[] - - connector?: ('' | 'AWS' | 'Azure')[] - - startTime?: number - - endTime?: number } | undefined, reqparams: RequestParams @@ -1150,7 +1127,7 @@ export const useComplianceApiV1BenchmarksTrendDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqbenchmarkId, reqquery, reqparams) + sendRequest(newController, reqcontrolId, reqquery, reqparams) } return { @@ -1163,10 +1140,12 @@ export const useComplianceApiV1BenchmarksTrendDetail = ( } } -interface IuseComplianceApiV1ControlsSummaryListState { + + +interface IuseComplianceApiV1FindingEventsCreateState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiControlSummary[] + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsResponse // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -1174,16 +1153,8 @@ interface IuseComplianceApiV1ControlsSummaryListState { /** * URL: */ -export const useComplianceApiV1ControlsSummaryList = ( - query?: { - controlId?: string[] - - connectionId?: string[] - - connectionGroup?: string[] - - tag?: string[] - }, +export const useComplianceApiV1FindingEventsCreate = ( + request: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsRequest, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -1195,27 +1166,17 @@ export const useComplianceApiV1ControlsSummaryList = ( api.instance = AxiosAPI const [state, setState] = - useState({ + useState({ isLoading: true, isExecuted: false, }) const [lastInput, setLastInput] = useState( - JSON.stringify([query, params, autoExecute]) + JSON.stringify([request, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqquery: - | { - controlId?: string[] - - connectionId?: string[] - - connectionGroup?: string[] - - tag?: string[] - } - | undefined, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsRequest, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -1239,7 +1200,7 @@ export const useComplianceApiV1ControlsSummaryList = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1ControlsSummaryList(reqquery, reqparamsSignal) + .apiV1FindingEventsCreate(reqrequest, reqparamsSignal) .then((resp) => { setState({ ...state, @@ -1275,8 +1236,8 @@ export const useComplianceApiV1ControlsSummaryList = ( } } - if (JSON.stringify([query, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([query, params, autoExecute])) + if (JSON.stringify([request, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([request, params, autoExecute])) } useEffect(() => { @@ -1284,7 +1245,7 @@ export const useComplianceApiV1ControlsSummaryList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, query, params) + sendRequest(newController, request, params) } }, [lastInput]) @@ -1296,27 +1257,17 @@ export const useComplianceApiV1ControlsSummaryList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, query, params) + sendRequest(newController, request, params) } const sendNowWithParams = ( - reqquery: - | { - controlId?: string[] - - connectionId?: string[] - - connectionGroup?: string[] - - tag?: string[] - } - | undefined, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsRequest, reqparams: RequestParams ) => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqquery, reqparams) + sendRequest(newController, reqrequest, reqparams) } return { @@ -1329,10 +1280,10 @@ export const useComplianceApiV1ControlsSummaryList = ( } } -interface IuseComplianceApiV1ControlsSummaryDetailState { +interface IuseComplianceApiV1FindingEventsCountListState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiControlSummary + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiCountFindingEventsResponse // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -1340,12 +1291,17 @@ interface IuseComplianceApiV1ControlsSummaryDetailState { /** * URL: */ -export const useComplianceApiV1ControlsSummaryDetail = ( - controlId: string, +export const useComplianceApiV1FindingEventsCountList = ( query?: { - connectionId?: string[] + conformanceStatus?: ('failed' | 'passed')[] - connectionGroup?: string[] + benchmarkID?: string[] + + stateActive?: boolean[] + + startTime?: number + + endTime?: number }, params: RequestParams = {}, autoExecute = true, @@ -1358,22 +1314,27 @@ export const useComplianceApiV1ControlsSummaryDetail = ( api.instance = AxiosAPI const [state, setState] = - useState({ + useState({ isLoading: true, isExecuted: false, }) const [lastInput, setLastInput] = useState( - JSON.stringify([controlId, query, params, autoExecute]) + JSON.stringify([query, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqcontrolId: string, reqquery: | { - connectionId?: string[] + conformanceStatus?: ('failed' | 'passed')[] - connectionGroup?: string[] + benchmarkID?: string[] + + stateActive?: boolean[] + + startTime?: number + + endTime?: number } | undefined, reqparams: RequestParams @@ -1399,11 +1360,7 @@ export const useComplianceApiV1ControlsSummaryDetail = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1ControlsSummaryDetail( - reqcontrolId, - reqquery, - reqparamsSignal - ) + .apiV1FindingEventsCountList(reqquery, reqparamsSignal) .then((resp) => { setState({ ...state, @@ -1439,8 +1396,8 @@ export const useComplianceApiV1ControlsSummaryDetail = ( } } - if (JSON.stringify([controlId, query, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([controlId, query, params, autoExecute])) + if (JSON.stringify([query, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([query, params, autoExecute])) } useEffect(() => { @@ -1448,7 +1405,7 @@ export const useComplianceApiV1ControlsSummaryDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, controlId, query, params) + sendRequest(newController, query, params) } }, [lastInput]) @@ -1460,16 +1417,21 @@ export const useComplianceApiV1ControlsSummaryDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, controlId, query, params) + sendRequest(newController, query, params) } const sendNowWithParams = ( - reqcontrolId: string, reqquery: | { - connectionId?: string[] + conformanceStatus?: ('failed' | 'passed')[] - connectionGroup?: string[] + benchmarkID?: string[] + + stateActive?: boolean[] + + startTime?: number + + endTime?: number } | undefined, reqparams: RequestParams @@ -1477,7 +1439,7 @@ export const useComplianceApiV1ControlsSummaryDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqcontrolId, reqquery, reqparams) + sendRequest(newController, reqquery, reqparams) } return { @@ -1490,10 +1452,10 @@ export const useComplianceApiV1ControlsSummaryDetail = ( } } -interface IuseComplianceApiV1ControlsTrendDetailState { +interface IuseComplianceApiV1FindingEventsFiltersCreateState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiControlTrendDatapoint[] + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEventFiltersWithMetadata // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -1501,19 +1463,8 @@ interface IuseComplianceApiV1ControlsTrendDetailState { /** * URL: */ -export const useComplianceApiV1ControlsTrendDetail = ( - controlId: string, - query?: { - connectionId?: string[] - - connectionGroup?: string[] - - startTime?: number - - endTime?: number - - granularity?: 'daily' | 'monthly' - }, +export const useComplianceApiV1FindingEventsFiltersCreate = ( + request: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEventFilters, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -1525,30 +1476,17 @@ export const useComplianceApiV1ControlsTrendDetail = ( api.instance = AxiosAPI const [state, setState] = - useState({ + useState({ isLoading: true, isExecuted: false, }) const [lastInput, setLastInput] = useState( - JSON.stringify([controlId, query, params, autoExecute]) + JSON.stringify([request, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqcontrolId: string, - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - - startTime?: number - - endTime?: number - - granularity?: 'daily' | 'monthly' - } - | undefined, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEventFilters, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -1572,11 +1510,7 @@ export const useComplianceApiV1ControlsTrendDetail = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1ControlsTrendDetail( - reqcontrolId, - reqquery, - reqparamsSignal - ) + .apiV1FindingEventsFiltersCreate(reqrequest, reqparamsSignal) .then((resp) => { setState({ ...state, @@ -1612,8 +1546,8 @@ export const useComplianceApiV1ControlsTrendDetail = ( } } - if (JSON.stringify([controlId, query, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([controlId, query, params, autoExecute])) + if (JSON.stringify([request, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([request, params, autoExecute])) } useEffect(() => { @@ -1621,7 +1555,7 @@ export const useComplianceApiV1ControlsTrendDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, controlId, query, params) + sendRequest(newController, request, params) } }, [lastInput]) @@ -1633,30 +1567,17 @@ export const useComplianceApiV1ControlsTrendDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, controlId, query, params) + sendRequest(newController, request, params) } const sendNowWithParams = ( - reqcontrolId: string, - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - - startTime?: number - - endTime?: number - - granularity?: 'daily' | 'monthly' - } - | undefined, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEventFilters, reqparams: RequestParams ) => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqcontrolId, reqquery, reqparams) + sendRequest(newController, reqrequest, reqparams) } return { @@ -1669,10 +1590,10 @@ export const useComplianceApiV1ControlsTrendDetail = ( } } -interface IuseComplianceApiV1FindingEventsCreateState { +interface IuseComplianceApiV1FindingEventsSingleDetailState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsResponse + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEvent // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -1680,8 +1601,9 @@ interface IuseComplianceApiV1FindingEventsCreateState { /** * URL: */ -export const useComplianceApiV1FindingEventsCreate = ( - request: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsRequest, +export const useComplianceApiV1FindingEventsSingleDetail = ( + findingId: string, + id: string, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -1693,17 +1615,18 @@ export const useComplianceApiV1FindingEventsCreate = ( api.instance = AxiosAPI const [state, setState] = - useState({ + useState({ isLoading: true, isExecuted: false, }) const [lastInput, setLastInput] = useState( - JSON.stringify([request, params, autoExecute]) + JSON.stringify([findingId, id, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsRequest, + reqfindingId: string, + reqid: string, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -1727,7 +1650,11 @@ export const useComplianceApiV1FindingEventsCreate = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1FindingEventsCreate(reqrequest, reqparamsSignal) + .apiV1FindingEventsSingleDetail( + reqfindingId, + reqid, + reqparamsSignal + ) .then((resp) => { setState({ ...state, @@ -1763,8 +1690,8 @@ export const useComplianceApiV1FindingEventsCreate = ( } } - if (JSON.stringify([request, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([request, params, autoExecute])) + if (JSON.stringify([findingId, id, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([findingId, id, params, autoExecute])) } useEffect(() => { @@ -1772,7 +1699,7 @@ export const useComplianceApiV1FindingEventsCreate = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, request, params) + sendRequest(newController, findingId, id, params) } }, [lastInput]) @@ -1784,17 +1711,18 @@ export const useComplianceApiV1FindingEventsCreate = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, request, params) + sendRequest(newController, findingId, id, params) } const sendNowWithParams = ( - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsRequest, + reqfindingId: string, + reqid: string, reqparams: RequestParams ) => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqrequest, reqparams) + sendRequest(newController, reqfindingId, reqid, reqparams) } return { @@ -1807,10 +1735,10 @@ export const useComplianceApiV1FindingEventsCreate = ( } } -interface IuseComplianceApiV1FindingEventsCountListState { +interface IuseComplianceApiV1FindingsCreateState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiCountFindingEventsResponse + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingsResponse // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -1818,18 +1746,8 @@ interface IuseComplianceApiV1FindingEventsCountListState { /** * URL: */ -export const useComplianceApiV1FindingEventsCountList = ( - query?: { - conformanceStatus?: ('failed' | 'passed')[] - - benchmarkID?: string[] - - stateActive?: boolean[] - - startTime?: number - - endTime?: number - }, +export const useComplianceApiV1FindingsCreate = ( + request: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingsRequest, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -1840,30 +1758,17 @@ export const useComplianceApiV1FindingEventsCountList = ( const api = new Api() api.instance = AxiosAPI - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) + const [state, setState] = useState({ + isLoading: true, + isExecuted: false, + }) const [lastInput, setLastInput] = useState( - JSON.stringify([query, params, autoExecute]) + JSON.stringify([request, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqquery: - | { - conformanceStatus?: ('failed' | 'passed')[] - - benchmarkID?: string[] - - stateActive?: boolean[] - - startTime?: number - - endTime?: number - } - | undefined, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingsRequest, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -1887,7 +1792,7 @@ export const useComplianceApiV1FindingEventsCountList = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1FindingEventsCountList(reqquery, reqparamsSignal) + .apiV1FindingsCreate(reqrequest, reqparamsSignal) .then((resp) => { setState({ ...state, @@ -1923,8 +1828,8 @@ export const useComplianceApiV1FindingEventsCountList = ( } } - if (JSON.stringify([query, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([query, params, autoExecute])) + if (JSON.stringify([request, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([request, params, autoExecute])) } useEffect(() => { @@ -1932,7 +1837,7 @@ export const useComplianceApiV1FindingEventsCountList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, query, params) + sendRequest(newController, request, params) } }, [lastInput]) @@ -1944,29 +1849,17 @@ export const useComplianceApiV1FindingEventsCountList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, query, params) + sendRequest(newController, request, params) } const sendNowWithParams = ( - reqquery: - | { - conformanceStatus?: ('failed' | 'passed')[] - - benchmarkID?: string[] - - stateActive?: boolean[] - - startTime?: number - - endTime?: number - } - | undefined, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingsRequest, reqparams: RequestParams ) => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqquery, reqparams) + sendRequest(newController, reqrequest, reqparams) } return { @@ -1979,10 +1872,11 @@ export const useComplianceApiV1FindingEventsCountList = ( } } -interface IuseComplianceApiV1FindingEventsFiltersCreateState { + +interface IuseComplianceApiV1FindingsEventsDetailState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEventFiltersWithMetadata + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsByFindingIDResponse // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -1990,8 +1884,8 @@ interface IuseComplianceApiV1FindingEventsFiltersCreateState { /** * URL: */ -export const useComplianceApiV1FindingEventsFiltersCreate = ( - request: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEventFilters, +export const useComplianceApiV1FindingsEventsDetail = ( + id: string, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -2003,17 +1897,17 @@ export const useComplianceApiV1FindingEventsFiltersCreate = ( api.instance = AxiosAPI const [state, setState] = - useState({ + useState({ isLoading: true, isExecuted: false, }) const [lastInput, setLastInput] = useState( - JSON.stringify([request, params, autoExecute]) + JSON.stringify([id, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEventFilters, + reqid: string, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -2037,7 +1931,7 @@ export const useComplianceApiV1FindingEventsFiltersCreate = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1FindingEventsFiltersCreate(reqrequest, reqparamsSignal) + .apiV1FindingsEventsDetail(reqid, reqparamsSignal) .then((resp) => { setState({ ...state, @@ -2073,8 +1967,8 @@ export const useComplianceApiV1FindingEventsFiltersCreate = ( } } - if (JSON.stringify([request, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([request, params, autoExecute])) + if (JSON.stringify([id, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([id, params, autoExecute])) } useEffect(() => { @@ -2082,7 +1976,7 @@ export const useComplianceApiV1FindingEventsFiltersCreate = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, request, params) + sendRequest(newController, id, params) } }, [lastInput]) @@ -2094,17 +1988,14 @@ export const useComplianceApiV1FindingEventsFiltersCreate = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, request, params) + sendRequest(newController, id, params) } - const sendNowWithParams = ( - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEventFilters, - reqparams: RequestParams - ) => { + const sendNowWithParams = (reqid: string, reqparams: RequestParams) => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqrequest, reqparams) + sendRequest(newController, reqid, reqparams) } return { @@ -2117,10 +2008,10 @@ export const useComplianceApiV1FindingEventsFiltersCreate = ( } } -interface IuseComplianceApiV1FindingEventsSingleDetailState { +interface IuseComplianceApiV1FindingsFiltersCreateState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEvent + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingFiltersWithMetadata // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -2128,9 +2019,8 @@ interface IuseComplianceApiV1FindingEventsSingleDetailState { /** * URL: */ -export const useComplianceApiV1FindingEventsSingleDetail = ( - findingId: string, - id: string, +export const useComplianceApiV1FindingsFiltersCreate = ( + request: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingFilters, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -2142,18 +2032,17 @@ export const useComplianceApiV1FindingEventsSingleDetail = ( api.instance = AxiosAPI const [state, setState] = - useState({ + useState({ isLoading: true, isExecuted: false, }) const [lastInput, setLastInput] = useState( - JSON.stringify([findingId, id, params, autoExecute]) + JSON.stringify([request, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqfindingId: string, - reqid: string, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingFilters, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -2177,11 +2066,7 @@ export const useComplianceApiV1FindingEventsSingleDetail = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1FindingEventsSingleDetail( - reqfindingId, - reqid, - reqparamsSignal - ) + .apiV1FindingsFiltersCreate(reqrequest, reqparamsSignal) .then((resp) => { setState({ ...state, @@ -2217,8 +2102,8 @@ export const useComplianceApiV1FindingEventsSingleDetail = ( } } - if (JSON.stringify([findingId, id, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([findingId, id, params, autoExecute])) + if (JSON.stringify([request, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([request, params, autoExecute])) } useEffect(() => { @@ -2226,7 +2111,7 @@ export const useComplianceApiV1FindingEventsSingleDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, findingId, id, params) + sendRequest(newController, request, params) } }, [lastInput]) @@ -2238,18 +2123,17 @@ export const useComplianceApiV1FindingEventsSingleDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, findingId, id, params) + sendRequest(newController, request, params) } const sendNowWithParams = ( - reqfindingId: string, - reqid: string, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingFilters, reqparams: RequestParams ) => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqfindingId, reqid, reqparams) + sendRequest(newController, reqrequest, reqparams) } return { @@ -2262,10 +2146,12 @@ export const useComplianceApiV1FindingEventsSingleDetail = ( } } -interface IuseComplianceApiV1FindingsCreateState { + + +interface IuseComplianceApiV1FindingsResourceCreateState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingsResponse + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetSingleResourceFindingResponse // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -2273,8 +2159,8 @@ interface IuseComplianceApiV1FindingsCreateState { /** * URL: */ -export const useComplianceApiV1FindingsCreate = ( - request: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingsRequest, +export const useComplianceApiV1FindingsResourceCreate = ( + request: GithubComKaytuIoKaytuEnginePkgComplianceApiGetSingleResourceFindingRequest, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -2285,17 +2171,18 @@ export const useComplianceApiV1FindingsCreate = ( const api = new Api() api.instance = AxiosAPI - const [state, setState] = useState({ - isLoading: true, - isExecuted: false, - }) + const [state, setState] = + useState({ + isLoading: true, + isExecuted: false, + }) const [lastInput, setLastInput] = useState( JSON.stringify([request, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingsRequest, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetSingleResourceFindingRequest, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -2319,7 +2206,7 @@ export const useComplianceApiV1FindingsCreate = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1FindingsCreate(reqrequest, reqparamsSignal) + .apiV1FindingsResourceCreate(reqrequest, reqparamsSignal) .then((resp) => { setState({ ...state, @@ -2380,7 +2267,7 @@ export const useComplianceApiV1FindingsCreate = ( } const sendNowWithParams = ( - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingsRequest, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetSingleResourceFindingRequest, reqparams: RequestParams ) => { controller.abort() @@ -2399,10 +2286,10 @@ export const useComplianceApiV1FindingsCreate = ( } } -interface IuseComplianceApiV1FindingsCountListState { +interface IuseComplianceApiV1FindingsSingleDetailState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiCountFindingsResponse + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiFinding // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -2410,12 +2297,8 @@ interface IuseComplianceApiV1FindingsCountListState { /** * URL: */ -export const useComplianceApiV1FindingsCountList = ( - query?: { - conformanceStatus?: ('failed' | 'passed')[] - - stateActive?: boolean[] - }, +export const useComplianceApiV1FindingsSingleDetail = ( + id: string, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -2427,23 +2310,17 @@ export const useComplianceApiV1FindingsCountList = ( api.instance = AxiosAPI const [state, setState] = - useState({ + useState({ isLoading: true, isExecuted: false, }) const [lastInput, setLastInput] = useState( - JSON.stringify([query, params, autoExecute]) + JSON.stringify([id, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqquery: - | { - conformanceStatus?: ('failed' | 'passed')[] - - stateActive?: boolean[] - } - | undefined, + reqid: string, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -2467,7 +2344,7 @@ export const useComplianceApiV1FindingsCountList = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1FindingsCountList(reqquery, reqparamsSignal) + .apiV1FindingsSingleDetail(reqid, reqparamsSignal) .then((resp) => { setState({ ...state, @@ -2503,8 +2380,8 @@ export const useComplianceApiV1FindingsCountList = ( } } - if (JSON.stringify([query, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([query, params, autoExecute])) + if (JSON.stringify([id, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([id, params, autoExecute])) } useEffect(() => { @@ -2512,7 +2389,7 @@ export const useComplianceApiV1FindingsCountList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, query, params) + sendRequest(newController, id, params) } }, [lastInput]) @@ -2524,1265 +2401,14 @@ export const useComplianceApiV1FindingsCountList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, query, params) - } - - const sendNowWithParams = ( - reqquery: - | { - conformanceStatus?: ('failed' | 'passed')[] - - stateActive?: boolean[] - } - | undefined, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqquery, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1FindingsEventsDetailState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsByFindingIDResponse - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1FindingsEventsDetail = ( - id: string, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([id, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqid: string, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1FindingsEventsDetail(reqid, reqparamsSignal) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if (JSON.stringify([id, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([id, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, id, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, id, params) - } - - const sendNowWithParams = (reqid: string, reqparams: RequestParams) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqid, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1FindingsFiltersCreateState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingFiltersWithMetadata - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1FindingsFiltersCreate = ( - request: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingFilters, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([request, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingFilters, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1FindingsFiltersCreate(reqrequest, reqparamsSignal) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if (JSON.stringify([request, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([request, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, request, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, request, params) - } - - const sendNowWithParams = ( - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingFilters, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqrequest, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1FindingsKpiListState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiFindingKPIResponse - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1FindingsKpiList = ( - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = useState( - { - isLoading: true, - isExecuted: false, - } - ) - const [lastInput, setLastInput] = useState( - JSON.stringify([params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1FindingsKpiList(reqparamsSignal) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if (JSON.stringify([params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, params) - } - - const sendNowWithParams = (reqparams: RequestParams) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1FindingsResourceCreateState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetSingleResourceFindingResponse - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1FindingsResourceCreate = ( - request: GithubComKaytuIoKaytuEnginePkgComplianceApiGetSingleResourceFindingRequest, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([request, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetSingleResourceFindingRequest, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1FindingsResourceCreate(reqrequest, reqparamsSignal) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if (JSON.stringify([request, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([request, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, request, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, request, params) - } - - const sendNowWithParams = ( - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiGetSingleResourceFindingRequest, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqrequest, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1FindingsSingleDetailState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiFinding - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1FindingsSingleDetail = ( - id: string, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([id, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqid: string, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1FindingsSingleDetail(reqid, reqparamsSignal) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if (JSON.stringify([id, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([id, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, id, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, id, params) - } - - const sendNowWithParams = (reqid: string, reqparams: RequestParams) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqid, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1FindingsTopDetailState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetTopFieldResponse - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1FindingsTopDetail = ( - field: - | 'resourceType' - | 'integrationID' - | 'resourceID' - | 'service' - | 'controlID', - count: number, - query?: { - integrationID?: string[] - - notConnectionId?: string[] - - connectionGroup?: string[] - - connector?: ('' | 'AWS' | 'Azure')[] - - benchmarkId?: string[] - - controlId?: string[] - - severities?: ('none' | 'low' | 'medium' | 'high' | 'critical')[] - - conformanceStatus?: ('failed' | 'passed')[] - - stateActive?: boolean[] - }, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([field, count, query, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqfield: - | 'resourceType' - | 'integrationID' - | 'resourceID' - | 'service' - | 'controlID', - reqcount: number, - reqquery: - | { - integrationID?: string[] - - notConnectionId?: string[] - - connectionGroup?: string[] - - connector?: ('' | 'AWS' | 'Azure')[] - - benchmarkId?: string[] - - controlId?: string[] - - severities?: ( - | 'none' - | 'low' - | 'medium' - | 'high' - | 'critical' - )[] - - conformanceStatus?: ('failed' | 'passed')[] - - stateActive?: boolean[] - } - | undefined, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1FindingsTopDetail( - reqfield, - reqcount, - reqquery, - reqparamsSignal - ) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if ( - JSON.stringify([field, count, query, params, autoExecute]) !== lastInput - ) { - setLastInput(JSON.stringify([field, count, query, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, field, count, query, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, field, count, query, params) - } - - const sendNowWithParams = ( - reqfield: - | 'resourceType' - | 'integrationID' - | 'resourceID' - | 'service' - | 'controlID', - reqcount: number, - reqquery: - | { - integrationID?: string[] - - notConnectionId?: string[] - - connectionGroup?: string[] - - connector?: ('' | 'AWS' | 'Azure')[] - - benchmarkId?: string[] - - controlId?: string[] - - severities?: ( - | 'none' - | 'low' - | 'medium' - | 'high' - | 'critical' - )[] - - conformanceStatus?: ('failed' | 'passed')[] - - stateActive?: boolean[] - } - | undefined, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqfield, reqcount, reqquery, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1FindingsAccountsDetailState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetAccountsFindingsSummaryResponse - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1FindingsAccountsDetail = ( - benchmarkId: string, - query?: { - connectionId?: string[] - - connectionGroup?: string[] - }, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([benchmarkId, query, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqbenchmarkId: string, - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - } - | undefined, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1FindingsAccountsDetail( - reqbenchmarkId, - reqquery, - reqparamsSignal - ) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if ( - JSON.stringify([benchmarkId, query, params, autoExecute]) !== lastInput - ) { - setLastInput(JSON.stringify([benchmarkId, query, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, query, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, query, params) - } - - const sendNowWithParams = ( - reqbenchmarkId: string, - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - } - | undefined, - reqparams: RequestParams - ) => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, reqbenchmarkId, reqquery, reqparams) - } - - return { - response, - isLoading, - isExecuted, - error, - sendNow, - sendNowWithParams, - } -} - -interface IuseComplianceApiV1FindingsServicesDetailState { - isLoading: boolean - isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetServicesFindingsSummaryResponse - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error?: any -} - -/** - * URL: - */ -export const useComplianceApiV1FindingsServicesDetail = ( - benchmarkId: string, - query?: { - connectionId?: string[] - - connectionGroup?: string[] - }, - params: RequestParams = {}, - autoExecute = true, - overwriteWorkspace: string | undefined = undefined -) => { - const workspace = useParams<{ ws: string }>().ws - const [controller, setController] = useState(new AbortController()) - - const api = new Api() - api.instance = AxiosAPI - - const [state, setState] = - useState({ - isLoading: true, - isExecuted: false, - }) - const [lastInput, setLastInput] = useState( - JSON.stringify([benchmarkId, query, params, autoExecute]) - ) - - const sendRequest = ( - abortCtrl: AbortController, - reqbenchmarkId: string, - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - } - | undefined, - reqparams: RequestParams - ) => { - if (!api.instance.defaults.headers.common.Authorization) { - return - } - - setState({ - ...state, - error: undefined, - isLoading: true, - isExecuted: true, - }) - try { - if (overwriteWorkspace) { - setWorkspace(overwriteWorkspace) - } else if (workspace !== undefined && workspace.length > 0) { - setWorkspace(workspace) - } else { - setWorkspace('main') - } - - const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } - api.compliance - .apiV1FindingsServicesDetail( - reqbenchmarkId, - reqquery, - reqparamsSignal - ) - .then((resp) => { - setState({ - ...state, - error: undefined, - response: resp.data, - isLoading: false, - isExecuted: true, - }) - }) - .catch((err) => { - if ( - err.name === 'AbortError' || - err.name === 'CanceledError' - ) { - // Request was aborted - } else { - setState({ - ...state, - error: err, - response: undefined, - isLoading: false, - isExecuted: true, - }) - } - }) - } catch (err) { - setState({ - ...state, - error: err, - isLoading: false, - isExecuted: true, - }) - } - } - - if ( - JSON.stringify([benchmarkId, query, params, autoExecute]) !== lastInput - ) { - setLastInput(JSON.stringify([benchmarkId, query, params, autoExecute])) - } - - useEffect(() => { - if (autoExecute) { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, query, params) - } - }, [lastInput]) - - const { response } = state - const { isLoading } = state - const { isExecuted } = state - const { error } = state - const sendNow = () => { - controller.abort() - const newController = new AbortController() - setController(newController) - sendRequest(newController, benchmarkId, query, params) - } - - const sendNowWithParams = ( - reqbenchmarkId: string, - reqquery: - | { - connectionId?: string[] - - connectionGroup?: string[] - } - | undefined, - reqparams: RequestParams - ) => { + sendRequest(newController, id, params) + } + + const sendNowWithParams = (reqid: string, reqparams: RequestParams) => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqbenchmarkId, reqquery, reqparams) + sendRequest(newController, reqid, reqparams) } return { @@ -3795,7 +2421,7 @@ export const useComplianceApiV1FindingsServicesDetail = ( } } -interface IuseComplianceApiV1FindingsCountDetailState { +interface IuseComplianceApiV1FindingsTopDetailState { isLoading: boolean isExecuted: boolean response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetTopFieldResponse @@ -3806,21 +2432,32 @@ interface IuseComplianceApiV1FindingsCountDetailState { /** * URL: */ -export const useComplianceApiV1FindingsCountDetail = ( - benchmarkId: string, - field: 'resourceType' | 'integrationID' | 'resourceID' | 'service', +export const useComplianceApiV1FindingsTopDetail = ( + field: + | 'resourceType' + | 'integrationID' + | 'resourceID' + | 'service' + | 'controlID', + count: number, query?: { - connectionId?: string[] + integrationID?: string[] - connectionGroup?: string[] + notConnectionId?: string[] - resourceCollection?: string[] + connectionGroup?: string[] connector?: ('' | 'AWS' | 'Azure')[] + benchmarkId?: string[] + + controlId?: string[] + severities?: ('none' | 'low' | 'medium' | 'high' | 'critical')[] conformanceStatus?: ('failed' | 'passed')[] + + stateActive?: boolean[] }, params: RequestParams = {}, autoExecute = true, @@ -3833,28 +2470,37 @@ export const useComplianceApiV1FindingsCountDetail = ( api.instance = AxiosAPI const [state, setState] = - useState({ + useState({ isLoading: true, isExecuted: false, }) const [lastInput, setLastInput] = useState( - JSON.stringify([benchmarkId, field, query, params, autoExecute]) + JSON.stringify([field, count, query, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqbenchmarkId: string, - reqfield: 'resourceType' | 'integrationID' | 'resourceID' | 'service', + reqfield: + | 'resourceType' + | 'integrationID' + | 'resourceID' + | 'service' + | 'controlID', + reqcount: number, reqquery: | { - connectionId?: string[] + integrationID?: string[] - connectionGroup?: string[] + notConnectionId?: string[] - resourceCollection?: string[] + connectionGroup?: string[] connector?: ('' | 'AWS' | 'Azure')[] + benchmarkId?: string[] + + controlId?: string[] + severities?: ( | 'none' | 'low' @@ -3864,6 +2510,8 @@ export const useComplianceApiV1FindingsCountDetail = ( )[] conformanceStatus?: ('failed' | 'passed')[] + + stateActive?: boolean[] } | undefined, reqparams: RequestParams @@ -3889,9 +2537,9 @@ export const useComplianceApiV1FindingsCountDetail = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1FindingsCountDetail( - reqbenchmarkId, + .apiV1FindingsTopDetail( reqfield, + reqcount, reqquery, reqparamsSignal ) @@ -3931,12 +2579,9 @@ export const useComplianceApiV1FindingsCountDetail = ( } if ( - JSON.stringify([benchmarkId, field, query, params, autoExecute]) !== - lastInput + JSON.stringify([field, count, query, params, autoExecute]) !== lastInput ) { - setLastInput( - JSON.stringify([benchmarkId, field, query, params, autoExecute]) - ) + setLastInput(JSON.stringify([field, count, query, params, autoExecute])) } useEffect(() => { @@ -3944,7 +2589,7 @@ export const useComplianceApiV1FindingsCountDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, benchmarkId, field, query, params) + sendRequest(newController, field, count, query, params) } }, [lastInput]) @@ -3956,22 +2601,31 @@ export const useComplianceApiV1FindingsCountDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, benchmarkId, field, query, params) + sendRequest(newController, field, count, query, params) } const sendNowWithParams = ( - reqbenchmarkId: string, - reqfield: 'resourceType' | 'integrationID' | 'resourceID' | 'service', + reqfield: + | 'resourceType' + | 'integrationID' + | 'resourceID' + | 'service' + | 'controlID', + reqcount: number, reqquery: | { - connectionId?: string[] + integrationID?: string[] - connectionGroup?: string[] + notConnectionId?: string[] - resourceCollection?: string[] + connectionGroup?: string[] connector?: ('' | 'AWS' | 'Azure')[] + benchmarkId?: string[] + + controlId?: string[] + severities?: ( | 'none' | 'low' @@ -3981,6 +2635,8 @@ export const useComplianceApiV1FindingsCountDetail = ( )[] conformanceStatus?: ('failed' | 'passed')[] + + stateActive?: boolean[] } | undefined, reqparams: RequestParams @@ -3988,13 +2644,7 @@ export const useComplianceApiV1FindingsCountDetail = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest( - newController, - reqbenchmarkId, - reqfield, - reqquery, - reqparams - ) + sendRequest(newController, reqfield, reqcount, reqquery, reqparams) } return { @@ -4007,10 +2657,10 @@ export const useComplianceApiV1FindingsCountDetail = ( } } -interface IuseComplianceApiV1MetadataTagComplianceListState { +interface IuseComplianceApiV1FindingsAccountsDetailState { isLoading: boolean isExecuted: boolean - response?: Record + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetAccountsFindingsSummaryResponse // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -4018,7 +2668,13 @@ interface IuseComplianceApiV1MetadataTagComplianceListState { /** * URL: */ -export const useComplianceApiV1MetadataTagComplianceList = ( +export const useComplianceApiV1FindingsAccountsDetail = ( + benchmarkId: string, + query?: { + connectionId?: string[] + + connectionGroup?: string[] + }, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -4030,16 +2686,24 @@ export const useComplianceApiV1MetadataTagComplianceList = ( api.instance = AxiosAPI const [state, setState] = - useState({ + useState({ isLoading: true, isExecuted: false, }) const [lastInput, setLastInput] = useState( - JSON.stringify([params, autoExecute]) + JSON.stringify([benchmarkId, query, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, + reqbenchmarkId: string, + reqquery: + | { + connectionId?: string[] + + connectionGroup?: string[] + } + | undefined, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -4063,7 +2727,11 @@ export const useComplianceApiV1MetadataTagComplianceList = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1MetadataTagComplianceList(reqparamsSignal) + .apiV1FindingsAccountsDetail( + reqbenchmarkId, + reqquery, + reqparamsSignal + ) .then((resp) => { setState({ ...state, @@ -4099,8 +2767,10 @@ export const useComplianceApiV1MetadataTagComplianceList = ( } } - if (JSON.stringify([params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([params, autoExecute])) + if ( + JSON.stringify([benchmarkId, query, params, autoExecute]) !== lastInput + ) { + setLastInput(JSON.stringify([benchmarkId, query, params, autoExecute])) } useEffect(() => { @@ -4108,7 +2778,7 @@ export const useComplianceApiV1MetadataTagComplianceList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, params) + sendRequest(newController, benchmarkId, query, params) } }, [lastInput]) @@ -4120,14 +2790,24 @@ export const useComplianceApiV1MetadataTagComplianceList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, params) + sendRequest(newController, benchmarkId, query, params) } - const sendNowWithParams = (reqparams: RequestParams) => { + const sendNowWithParams = ( + reqbenchmarkId: string, + reqquery: + | { + connectionId?: string[] + + connectionGroup?: string[] + } + | undefined, + reqparams: RequestParams + ) => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqparams) + sendRequest(newController, reqbenchmarkId, reqquery, reqparams) } return { @@ -4140,10 +2820,10 @@ export const useComplianceApiV1MetadataTagComplianceList = ( } } -interface IuseComplianceApiV1QueriesSyncListState { +interface IuseComplianceApiV1FindingsServicesDetailState { isLoading: boolean isExecuted: boolean - response?: void + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiGetServicesFindingsSummaryResponse // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -4151,9 +2831,12 @@ interface IuseComplianceApiV1QueriesSyncListState { /** * URL: */ -export const useComplianceApiV1QueriesSyncList = ( +export const useComplianceApiV1FindingsServicesDetail = ( + benchmarkId: string, query?: { - configzGitURL?: string + connectionId?: string[] + + connectionGroup?: string[] }, params: RequestParams = {}, autoExecute = true, @@ -4165,21 +2848,23 @@ export const useComplianceApiV1QueriesSyncList = ( const api = new Api() api.instance = AxiosAPI - const [state, setState] = useState( - { + const [state, setState] = + useState({ isLoading: true, isExecuted: false, - } - ) + }) const [lastInput, setLastInput] = useState( - JSON.stringify([query, params, autoExecute]) + JSON.stringify([benchmarkId, query, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, + reqbenchmarkId: string, reqquery: | { - configzGitURL?: string + connectionId?: string[] + + connectionGroup?: string[] } | undefined, reqparams: RequestParams @@ -4205,7 +2890,11 @@ export const useComplianceApiV1QueriesSyncList = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1QueriesSyncList(reqquery, reqparamsSignal) + .apiV1FindingsServicesDetail( + reqbenchmarkId, + reqquery, + reqparamsSignal + ) .then((resp) => { setState({ ...state, @@ -4241,8 +2930,10 @@ export const useComplianceApiV1QueriesSyncList = ( } } - if (JSON.stringify([query, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([query, params, autoExecute])) + if ( + JSON.stringify([benchmarkId, query, params, autoExecute]) !== lastInput + ) { + setLastInput(JSON.stringify([benchmarkId, query, params, autoExecute])) } useEffect(() => { @@ -4250,7 +2941,7 @@ export const useComplianceApiV1QueriesSyncList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, query, params) + sendRequest(newController, benchmarkId, query, params) } }, [lastInput]) @@ -4262,13 +2953,16 @@ export const useComplianceApiV1QueriesSyncList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, query, params) + sendRequest(newController, benchmarkId, query, params) } const sendNowWithParams = ( + reqbenchmarkId: string, reqquery: | { - configzGitURL?: string + connectionId?: string[] + + connectionGroup?: string[] } | undefined, reqparams: RequestParams @@ -4276,7 +2970,7 @@ export const useComplianceApiV1QueriesSyncList = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqquery, reqparams) + sendRequest(newController, reqbenchmarkId, reqquery, reqparams) } return { @@ -4289,10 +2983,12 @@ export const useComplianceApiV1QueriesSyncList = ( } } -interface IuseComplianceApiV1ResourceFindingsCreateState { + + +interface IuseComplianceApiV1QueriesSyncListState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgComplianceApiListResourceFindingsResponse + response?: void // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -4300,8 +2996,10 @@ interface IuseComplianceApiV1ResourceFindingsCreateState { /** * URL: */ -export const useComplianceApiV1ResourceFindingsCreate = ( - request: GithubComKaytuIoKaytuEnginePkgComplianceApiListResourceFindingsRequest, +export const useComplianceApiV1QueriesSyncList = ( + query?: { + configzGitURL?: string + }, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -4312,18 +3010,23 @@ export const useComplianceApiV1ResourceFindingsCreate = ( const api = new Api() api.instance = AxiosAPI - const [state, setState] = - useState({ + const [state, setState] = useState( + { isLoading: true, isExecuted: false, - }) + } + ) const [lastInput, setLastInput] = useState( - JSON.stringify([request, params, autoExecute]) + JSON.stringify([query, params, autoExecute]) ) const sendRequest = ( abortCtrl: AbortController, - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiListResourceFindingsRequest, + reqquery: + | { + configzGitURL?: string + } + | undefined, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -4347,7 +3050,7 @@ export const useComplianceApiV1ResourceFindingsCreate = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV1ResourceFindingsCreate(reqrequest, reqparamsSignal) + .apiV1QueriesSyncList(reqquery, reqparamsSignal) .then((resp) => { setState({ ...state, @@ -4383,8 +3086,8 @@ export const useComplianceApiV1ResourceFindingsCreate = ( } } - if (JSON.stringify([request, params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([request, params, autoExecute])) + if (JSON.stringify([query, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([query, params, autoExecute])) } useEffect(() => { @@ -4392,7 +3095,7 @@ export const useComplianceApiV1ResourceFindingsCreate = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, request, params) + sendRequest(newController, query, params) } }, [lastInput]) @@ -4404,17 +3107,21 @@ export const useComplianceApiV1ResourceFindingsCreate = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, request, params) + sendRequest(newController, query, params) } const sendNowWithParams = ( - reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiListResourceFindingsRequest, + reqquery: + | { + configzGitURL?: string + } + | undefined, reqparams: RequestParams ) => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(newController, reqrequest, reqparams) + sendRequest(newController, reqquery, reqparams) } return { @@ -4427,10 +3134,10 @@ export const useComplianceApiV1ResourceFindingsCreate = ( } } -interface IuseInventoryApiV3InvenoryCategoryList { +interface IuseComplianceApiV1ResourceFindingsCreateState { isLoading: boolean isExecuted: boolean - response?: GithubComKaytuIoKaytuEnginePkgInventoryApiInventoryCategoriesResponse + response?: GithubComKaytuIoKaytuEnginePkgComplianceApiListResourceFindingsResponse // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } @@ -4438,8 +3145,8 @@ interface IuseInventoryApiV3InvenoryCategoryList { /** * URL: */ -export const useInventoryApiV3AllBenchmarksControls = ( - query: string[] | undefined, +export const useComplianceApiV1ResourceFindingsCreate = ( + request: GithubComKaytuIoKaytuEnginePkgComplianceApiListResourceFindingsRequest, params: RequestParams = {}, autoExecute = true, overwriteWorkspace: string | undefined = undefined @@ -4450,17 +3157,18 @@ export const useInventoryApiV3AllBenchmarksControls = ( const api = new Api() api.instance = AxiosAPI - const [state, setState] = useState({ - isLoading: true, - isExecuted: false, - }) + const [state, setState] = + useState({ + isLoading: true, + isExecuted: false, + }) const [lastInput, setLastInput] = useState( - JSON.stringify([query, params, autoExecute]) + JSON.stringify([request, params, autoExecute]) ) const sendRequest = ( - reqquery: string[] | undefined, abortCtrl: AbortController, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiListResourceFindingsRequest, reqparams: RequestParams ) => { if (!api.instance.defaults.headers.common.Authorization) { @@ -4484,7 +3192,7 @@ export const useInventoryApiV3AllBenchmarksControls = ( const reqparamsSignal = { ...reqparams, signal: abortCtrl.signal } api.compliance - .apiV3ComplianceControlCategoryList(reqquery, reqparamsSignal) + .apiV1ResourceFindingsCreate(reqrequest, reqparamsSignal) .then((resp) => { setState({ ...state, @@ -4520,8 +3228,8 @@ export const useInventoryApiV3AllBenchmarksControls = ( } } - if (JSON.stringify([params, autoExecute]) !== lastInput) { - setLastInput(JSON.stringify([params, autoExecute])) + if (JSON.stringify([request, params, autoExecute]) !== lastInput) { + setLastInput(JSON.stringify([request, params, autoExecute])) } useEffect(() => { @@ -4529,7 +3237,7 @@ export const useInventoryApiV3AllBenchmarksControls = ( controller.abort() const newController = new AbortController() setController(newController) - sendRequest(query, newController, params) + sendRequest(newController, request, params) } }, [lastInput]) @@ -4537,21 +3245,21 @@ export const useInventoryApiV3AllBenchmarksControls = ( const { isLoading } = state const { isExecuted } = state const { error } = state - const sendNow = (reqquery: string[]) => { + const sendNow = () => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(reqquery, newController, params) + sendRequest(newController, request, params) } const sendNowWithParams = ( - reqquery: string[] | undefined, + reqrequest: GithubComKaytuIoKaytuEnginePkgComplianceApiListResourceFindingsRequest, reqparams: RequestParams ) => { controller.abort() const newController = new AbortController() setController(newController) - sendRequest(reqquery, newController, reqparams) + sendRequest(newController, reqrequest, reqparams) } return { @@ -4563,3 +3271,12 @@ export const useInventoryApiV3AllBenchmarksControls = ( sendNowWithParams, } } + +interface IuseInventoryApiV3InvenoryCategoryList { + isLoading: boolean + isExecuted: boolean + response?: GithubComKaytuIoKaytuEnginePkgInventoryApiInventoryCategoriesResponse + // eslint-disable-next-line @typescript-eslint/no-explicit-any + error?: any +} + From 14904225b3d2b81ca556f43550173521e0aee28c Mon Sep 17 00:00:00 2001 From: Mohamad Choupan Date: Fri, 3 Jan 2025 19:37:10 +0330 Subject: [PATCH 3/4] feat: remove unused files part3 main files --- services/web-ui/src/api/compliance.gen.ts | 17 - .../src/components/Layout/Sidebar/index.tsx | 27 +- .../SingleConnection/index.tsx | 367 ----- .../TopDetails/CloudAccounts/index.tsx | 161 --- .../TopDetails/Controls/index.tsx | 201 --- .../TopDetails/Services/index.tsx | 144 -- .../BenchmarkSummary/TopDetails/index.tsx | 58 - .../Compliance/BenchmarkSummary/index.tsx | 238 ---- .../Findings/ControlsWithFailure/index.tsx | 2 +- .../NewBenchmarkSummary/Settings/index.tsx | 71 +- .../Compliance/NewBenchmarkSummary/index.tsx | 335 +++-- .../Overview/ComplianceSection/index.tsx | 192 --- .../Overview/SummarySection/index.tsx | 75 - .../src/pages/Governance/Overview/index.tsx | 101 -- .../src/pages/Insights/Details/index.tsx | 899 ------------ .../pages/Insights/ScoreCategory/index.tsx | 1269 ----------------- .../pages/Insights/ScoreCategory/style.css | 6 - .../pages/Insights/ScoreOverview/index.tsx | 627 -------- services/web-ui/src/router/index.tsx | 51 +- 19 files changed, 170 insertions(+), 4671 deletions(-) delete mode 100644 services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/SingleConnection/index.tsx delete mode 100644 services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/CloudAccounts/index.tsx delete mode 100644 services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/Controls/index.tsx delete mode 100644 services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/Services/index.tsx delete mode 100644 services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/index.tsx delete mode 100644 services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/index.tsx delete mode 100644 services/web-ui/src/pages/Governance/Overview/ComplianceSection/index.tsx delete mode 100644 services/web-ui/src/pages/Governance/Overview/SummarySection/index.tsx delete mode 100644 services/web-ui/src/pages/Governance/Overview/index.tsx delete mode 100644 services/web-ui/src/pages/Insights/Details/index.tsx delete mode 100644 services/web-ui/src/pages/Insights/ScoreCategory/index.tsx delete mode 100644 services/web-ui/src/pages/Insights/ScoreCategory/style.css delete mode 100644 services/web-ui/src/pages/Insights/ScoreOverview/index.tsx diff --git a/services/web-ui/src/api/compliance.gen.ts b/services/web-ui/src/api/compliance.gen.ts index 5c0b87578..26c878f30 100755 --- a/services/web-ui/src/api/compliance.gen.ts +++ b/services/web-ui/src/api/compliance.gen.ts @@ -2,31 +2,23 @@ import { useEffect, useState } from 'react' import { useParams } from 'react-router-dom' import { Api, - GithubComKaytuIoKaytuEnginePkgComplianceApiListBenchmarksSummaryResponse, - GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkTrendDatapoint, GithubComKaytuIoKaytuEnginePkgComplianceApiFindingFiltersWithMetadata, GithubComKaytuIoKaytuEnginePkgComplianceApiGetAccountsFindingsSummaryResponse, GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkAssignedEntities, GithubComKaytuIoKaytuEnginePkgComplianceApiControlSummary, - GithubComKaytuIoKaytuEnginePkgComplianceApiFindingKPIResponse, - GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkAssignment, GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkEvaluationSummary, GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsResponse, GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingsResponse, - GithubComKaytuIoKaytuEnginePkgComplianceApiCountFindingsResponse, GithubComKaytuIoKaytuEnginePkgComplianceApiListResourceFindingsRequest, GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEventFilters, GithubComKaytuIoKaytuEnginePkgComplianceApiGetSingleResourceFindingRequest, GithubComKaytuIoKaytuEnginePkgComplianceApiGetSingleResourceFindingResponse, GithubComKaytuIoKaytuEnginePkgComplianceApiGetTopFieldResponse, GithubComKaytuIoKaytuEnginePkgComplianceApiListResourceFindingsResponse, - GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkRemediation, - GithubComKaytuIoKaytuEnginePkgComplianceApiControlTrendDatapoint, GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsRequest, GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEventFiltersWithMetadata, GithubComKaytuIoKaytuEnginePkgComplianceApiFindingEvent, GithubComKaytuIoKaytuEnginePkgComplianceApiFinding, - GithubComKaytuIoKaytuEnginePkgComplianceApiAssignedBenchmark, GithubComKaytuIoKaytuEnginePkgComplianceApiCountFindingEventsResponse, GithubComKaytuIoKaytuEnginePkgComplianceApiGetFindingEventsByFindingIDResponse, GithubComKaytuIoKaytuEnginePkgComplianceApiFindingFilters, @@ -184,13 +176,6 @@ export const useComplianceApiV1AssignmentsBenchmarkDetail = ( } } - - - - - - - interface IuseComplianceApiV1BenchmarksControlsDetailState { isLoading: boolean isExecuted: boolean @@ -366,8 +351,6 @@ export const useComplianceApiV1BenchmarksControlsDetail = ( } } - - interface IuseComplianceApiV3ControlListFilters { isLoading: boolean isExecuted: boolean diff --git a/services/web-ui/src/components/Layout/Sidebar/index.tsx b/services/web-ui/src/components/Layout/Sidebar/index.tsx index 10fa1dec7..31333eac4 100644 --- a/services/web-ui/src/components/Layout/Sidebar/index.tsx +++ b/services/web-ui/src/components/Layout/Sidebar/index.tsx @@ -34,7 +34,6 @@ import { useInventoryApiV2AnalyticsCountList, useInventoryApiV2AnalyticsSpendCountList, } from '../../../api/inventory.gen' -import { useComplianceApiV1FindingsCountList } from '../../../api/compliance.gen' import { useIntegrationApiV1ConnectionsCountList } from '../../../api/integration.gen' import { numericDisplay } from '../../../utilities/numericDisplay' import AnimatedAccordion from '../../AnimatedAccordion' @@ -74,31 +73,7 @@ export default function Sidebar({ currentPage }: ISidebar) { const { isAuthenticated, getAccessTokenSilently } = useAuth() const [collapsed, setCollapsed] = useAtom(sideBarCollapsedAtom) const preview = useAtomValue(previewAtom) - // const { - // response: spendCount, - // isLoading: spendCountIsLoading, - // error: spendCountErr, - // sendNow: sendSpend, - // } = useInventoryApiV2AnalyticsSpendCountList({}, false, workspace) - // const { - // response: assetCount, - // isLoading: assetsIsLoading, - // error: assetCountErr, - // sendNow: sendAssets, - // } = useInventoryApiV2AnalyticsCountList({}, false, workspace) - // const { - // response: findingsCount, - // isLoading: findingsIsLoading, - // error: findingsErr, - // sendNow: sendFindings, - // // } = useComplianceApiV1FindingsCountList({}, {}, false, workspace) - // const { - // response: connectionCount, - // isExecuted: connectionsIsExecuted, - // isLoading: connectionsIsLoading, - // error: connectionsErr, - // sendNow: sendConnections, - // } = useIntegrationApiV1ConnectionsCountList({}, {}, false, workspace) + const searchParams = useAtomValue(searchAtom) const setOldUrl = useSetAtom(oldUrlAtom) diff --git a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/SingleConnection/index.tsx b/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/SingleConnection/index.tsx deleted file mode 100644 index 2ec79484e..000000000 --- a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/SingleConnection/index.tsx +++ /dev/null @@ -1,367 +0,0 @@ -import { - Button, - Card, - Flex, - Grid, - List, - ListItem, - Tab, - TabGroup, - TabList, - TabPanel, - TabPanels, - Text, - Title, -} from '@tremor/react' -import { useParams } from 'react-router-dom' -import clipboardCopy from 'clipboard-copy' -import { ChevronRightIcon, Square2StackIcon } from '@heroicons/react/24/outline' -import { useEffect, useState } from 'react' -import { useAtomValue, useSetAtom } from 'jotai' -import { - IServerSideDatasource, - RowClickedEvent, - SortModelItem, - IServerSideGetRowsParams, -} from 'ag-grid-community' -import { useIntegrationApiV1ConnectionsSummariesList } from '../../../../../api/integration.gen' -import Spinner from '../../../../../components/Spinner' -import { dateTimeDisplay } from '../../../../../utilities/dateDisplay' -import DrawerPanel from '../../../../../components/DrawerPanel' -import { RenderObject } from '../../../../../components/RenderObject' -import { isDemoAtom, notificationAtom } from '../../../../../store' -import { - useComplianceApiV1AssignmentsConnectionDetail, - useComplianceApiV1BenchmarksSummaryDetail, - useComplianceApiV1FindingsCreate, -} from '../../../../../api/compliance.gen' -import Table from '../../../../../components/Table' -import { columns } from '../../../Findings/FindingsWithFailure' -import Breakdown from '../../../../../components/Breakdown' -import FindingDetail from '../../../Findings/FindingsWithFailure/Detail' -import { benchmarkChecks } from '../../../../../components/Cards/ComplianceCard' -import { policyColumns } from '../TopDetails/Controls' -import TopHeader from '../../../../../components/Layout/Header' - -export default function SingleComplianceConnection() { - const [openDrawer, setOpenDrawer] = useState(false) - const { connectionId, resourceId } = useParams() - const setNotification = useSetAtom(notificationAtom) - const isDemo = useAtomValue(isDemoAtom) - const [sortModel, setSortModel] = useState([]) - const [openFinding, setOpenFinding] = useState(false) - const [finding, setFinding] = useState(undefined) - - const query = { - ...(connectionId && { - connectionId: [connectionId.replace('account_', '')], - }), - ...(resourceId && { - resourceCollection: [resourceId], - }), - } - const { response: accountInfo, isLoading: accountInfoLoading } = - useIntegrationApiV1ConnectionsSummariesList({ - ...query, - pageSize: 1, - needCost: false, - }) - const con = accountInfo?.connections?.at(0) - - const { response: benchmarkList } = - useComplianceApiV1AssignmentsConnectionDetail( - connectionId?.replace('account_', '') || '' - ) - const [benchmark, setBenchmark] = useState( - benchmarkList?.filter((bm) => bm.status)[0].benchmarkId?.id - ) - const { - response: benchmarkDetail, - isLoading: detailLoading, - sendNow: updateDetail, - } = useComplianceApiV1BenchmarksSummaryDetail( - benchmark || '', - { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - connectionID: [connection?.replace('account_', '') || ''], - }, - {}, - false - ) - - const { - response: findings, - isLoading, - sendNowWithParams: updateFindings, - } = useComplianceApiV1FindingsCreate({ - filters: { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - connectionID: [connection?.replace('account_', '') || ''], - }, - sort: sortModel.length - ? [{ [sortModel[0].colId]: sortModel[0].sort }] - : [], - }) - - useEffect(() => { - if (benchmark) { - updateDetail() - } - }, [benchmark]) - - const getData = (sort: SortModelItem[]) => { - setSortModel(sort) - updateFindings( - { - filters: { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - connectionID: [connection?.replace('account_', '') || ''], - }, - sort: sort.length ? [{ [sort[0].colId]: sort[0].sort }] : [], - }, - {} - ) - } - - const datasource: IServerSideDatasource = { - getRows: (params: IServerSideGetRowsParams) => { - if (params.request.sortModel.length > 0) { - if (sortModel.length > 0) { - if ( - params.request.sortModel[0].colId !== - sortModel[0].colId || - params.request.sortModel[0].sort !== sortModel[0].sort - ) { - getData([params.request.sortModel[0]]) - } - } else { - getData([params.request.sortModel[0]]) - } - } else if (sortModel.length > 0) { - getData([]) - } - if (findings) { - params.success({ - rowData: findings?.findings || [], - rowCount: findings?.totalCount || 0, - }) - } else { - params.fail() - } - }, - } - - return ( - <> - - - - - - - Connection details - - {accountInfoLoading ? ( - - ) : ( - - - Cloud Provider - - {con?.connector} - - - - Discovered name - - - - setOpenDrawer(false)} - > - - - - - - - - - {/* eslint-disable-next-line react/jsx-no-useless-fragment */} - <> - {benchmarkList - ?.filter((bm) => bm.status) - ?.map((bm) => ( - - setBenchmark(bm.benchmarkId?.id || '') - } - > - {bm.benchmarkId?.title} - - ))} - Findings - - - - {benchmarkList - ?.filter((bm) => bm.status) - ?.map((bm) => ( - - { - if (detailLoading) { - e.api.showLoadingOverlay() - } - }} - columns={policyColumns} - // rowData={policies} - /> - - ))} - -
{ - setFinding(event.data) - setOpenFinding(true) - }} - onGridReady={(e) => { - if (isLoading) { - e.api.showLoadingOverlay() - } - }} - serverSideDatasource={datasource} - loading={isLoading} - /> - - - - setOpenFinding(false)} - onRefresh={() => window.location.reload()} - /> - - ) -} diff --git a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/CloudAccounts/index.tsx b/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/CloudAccounts/index.tsx deleted file mode 100644 index 1d9216c85..000000000 --- a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/CloudAccounts/index.tsx +++ /dev/null @@ -1,161 +0,0 @@ -import { GridOptions, ValueFormatterParams } from 'ag-grid-community' -import { useAtomValue } from 'jotai' -import { useComplianceApiV1FindingsAccountsDetail } from '../../../../../../api/compliance.gen' -import Table, { IColumn } from '../../../../../../components/Table' -import { dateTimeDisplay } from '../../../../../../utilities/dateDisplay' -import { isDemoAtom } from '../../../../../../store' -import { IFilter } from '../../../../../../utilities/urlstate' - -interface IFinder { - id: string | undefined - connections: IFilter - resourceId: string | undefined -} - -const rowGenerator = (data: any) => { - const temp: any = [] - if (data && data?.accounts) { - const holder = data?.accounts - for (let i = 0; i < holder.length; i += 1) { - temp.push({ ...holder[i], ...holder[i].SeveritiesCount }) - } - } - return temp -} - -const columns = (isDemo: boolean) => { - const temp: IColumn[] = [ - { - field: 'accountName', - headerName: 'Account name', - type: 'string', - sortable: true, - filter: true, - resizable: true, - flex: 1, - cellRenderer: (param: ValueFormatterParams) => ( - {param.value} - ), - }, - { - field: 'accountId', - headerName: 'Account ID', - type: 'string', - sortable: true, - filter: true, - resizable: true, - flex: 1, - cellRenderer: (param: ValueFormatterParams) => ( - {param.value} - ), - }, - { - field: 'severitiesCount.critical', - headerName: 'Critical', - type: 'number', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - }, - { - field: 'severitiesCount.high', - headerName: 'High', - type: 'number', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - }, - { - field: 'severitiesCount.medium', - headerName: 'Medium', - type: 'number', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - }, - { - field: 'severitiesCount.low', - headerName: 'Low', - type: 'number', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - }, - { - field: 'securityScore', - headerName: 'Security score', - type: 'string', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - valueFormatter: (param: ValueFormatterParams) => { - return `${param.value ? Number(param.value).toFixed(2) : '0'}%` - }, - }, - { - field: 'lastCheckTime', - headerName: 'Last checked', - type: 'datetime', - sortable: true, - filter: true, - resizable: true, - flex: 1, - hide: true, - valueFormatter: (param: ValueFormatterParams) => { - return param.value ? dateTimeDisplay(param.value) : '' - }, - }, - ] - return temp -} - -export default function CloudAccounts({ - id, - connections, - resourceId, -}: IFinder) { - const isDemo = useAtomValue(isDemoAtom) - - const { response: findings, isLoading } = - useComplianceApiV1FindingsAccountsDetail(id || '', { - connectionId: connections.connections, - connectionGroup: connections.connectionGroup, - ...(resourceId && { - resourceCollection: [resourceId], - }), - }) - - const options: GridOptions = { - enableGroupEdit: true, - columnTypes: { - dimension: { - enableRowGroup: true, - enablePivot: true, - }, - }, - rowGroupPanelShow: 'always', - groupAllowUnbalanced: true, - } - - return ( -
{ - if (isLoading) { - e.api.showLoadingOverlay() - } - }} - loading={isLoading} - /> - ) -} diff --git a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/Controls/index.tsx b/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/Controls/index.tsx deleted file mode 100644 index 5eeb8a783..000000000 --- a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/Controls/index.tsx +++ /dev/null @@ -1,201 +0,0 @@ -import { useAtomValue } from 'jotai' -import { useNavigate, useSearchParams } from 'react-router-dom' -import { ICellRendererParams } from 'ag-grid-community' -import { Flex } from '@tremor/react' -import { useComplianceApiV1FindingsTopDetail } from '../../../../../../api/compliance.gen' -import Table, { IColumn } from '../../../../../../components/Table' -import { GithubComKaytuIoKaytuEnginePkgComplianceApiTopFieldRecord } from '../../../../../../api/api' -import { severityBadge } from '../../../../Controls' -import { - searchAtom, - useFilterState, -} from '../../../../../../utilities/urlstate' - -interface IFinder { - id: string | undefined -} - -export const policyColumns: IColumn[] = [ - { - headerName: 'Title', - field: 'title', - type: 'string', - sortable: true, - filter: true, - resizable: true, - }, - { - headerName: 'Control ID', - field: 'id', - width: 170, - type: 'string', - hide: true, - sortable: true, - filter: true, - resizable: true, - }, - { - headerName: 'Severity', - field: 'severity', - width: 120, - type: 'string', - sortable: true, - filter: true, - resizable: true, - cellRenderer: (params: ICellRendererParams) => ( - - {severityBadge(params.data?.severity)} - - ), - }, - // { - // headerName: 'Outcome', - // field: 'status', - // width: 100, - // type: 'string', - // sortable: true, - // filter: true, - // resizable: true, - // cellRenderer: ( - // params: ICellRendererParams - // ) => { - // return ( - // - // {renderStatus(params.data?.passed || false)} - // - // ) - // }, - // }, - // { - // headerName: 'Failed resources %', - // field: 'failedResourcesCount', - // type: 'string', - // width: 150, - // valueFormatter: ( - // params: ValueFormatterParams - // ) => - // `${numberDisplay( - // ((params.data?.failedResourcesCount || 0) / - // (params.data?.totalResourcesCount || 0)) * - // 100 || 0 - // )} %`, - // resizable: true, - // }, - // { - // headerName: 'Failed accounts %', - // field: 'failedConnectionCount', - // hide: true, - // type: 'string', - // width: 150, - // valueFormatter: ( - // params: ValueFormatterParams - // ) => - // `${numberDisplay( - // ((params.data?.failedConnectionCount || 0) / - // (params.data?.totalConnectionCount || 0)) * - // 100 || 0 - // )} %`, - // resizable: true, - // }, - // { - // headerName: 'Last checked', - // field: 'evaluatedAt', - // type: 'date', - // sortable: true, - // hide: true, - // filter: true, - // resizable: true, - // valueFormatter: (param: ValueFormatterParams) => { - // return param.value ? dateTimeDisplay(param.value) : '' - // }, - // }, -] - -export const topControls = ( - input: - | GithubComKaytuIoKaytuEnginePkgComplianceApiTopFieldRecord[] - | undefined -) => { - const data = [] - if (input) { - for (let i = 0; i < input.length; i += 1) { - let sev = '' - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - if (input[i].Control?.severity === 'critical') sev = '5. critical' - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - if (input[i].Control?.severity === 'high') sev = '4. high' - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - if (input[i].Control?.severity === 'medium') sev = '3. medium' - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - if (input[i].Control?.severity === 'low') sev = '2. low' - if ( - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - input[i].Control?.severity === 'none' || - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - input[i].Control?.severity === '' - ) - sev = '1. none' - - data.push({ - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - ...input[i].Control, - count: input[i].count, - totalCount: input[i].totalCount, - resourceCount: input[i].resourceCount, - resourceTotalCount: input[i].resourceTotalCount, - sev, - }) - } - } - return data -} - -export default function Controls({ id }: IFinder) { - const { value: selectedConnections } = useFilterState() - const navigate = useNavigate() - const searchParams = useAtomValue(searchAtom) - - const topQuery = { - ...(id && { benchmarkId: [id] }), - ...(selectedConnections.provider && { - connector: [selectedConnections.provider], - }), - ...(selectedConnections.connections && { - connectionId: selectedConnections.connections, - }), - ...(selectedConnections.connectionGroup && { - connectionGroup: selectedConnections.connectionGroup, - }), - } - const { response: controls, isLoading } = - useComplianceApiV1FindingsTopDetail('controlID', 10000, topQuery) - - return ( -
- navigate(`${String(event.data.id)}?${searchParams}`) - } - /> - ) -} diff --git a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/Services/index.tsx b/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/Services/index.tsx deleted file mode 100644 index bd45778c2..000000000 --- a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/Services/index.tsx +++ /dev/null @@ -1,144 +0,0 @@ -import { GridOptions, ValueFormatterParams } from 'ag-grid-community' -import { useComplianceApiV1FindingsServicesDetail } from '../../../../../../api/compliance.gen' -import Table, { IColumn } from '../../../../../../components/Table' -import { dateTimeDisplay } from '../../../../../../utilities/dateDisplay' -import { IFilter } from '../../../../../../utilities/urlstate' - -interface IFinder { - id: string | undefined - connections: IFilter - resourceId: string | undefined -} - -const rowGenerator = (data: any) => { - const temp: any = [] - if (data && data?.services) { - const holder = data?.services - for (let i = 0; i < holder.length; i += 1) { - temp.push({ ...holder[i], ...holder[i].SeveritiesCount }) - } - } - return temp -} - -const columns: IColumn[] = [ - { - field: 'serviceName', - headerName: 'Resource name', - type: 'string', - sortable: true, - filter: true, - resizable: true, - flex: 1, - }, - { - field: 'serviceLabel', - headerName: 'Resource label', - type: 'string', - sortable: true, - filter: true, - resizable: true, - flex: 1, - }, - { - field: 'severitiesCount.critical', - headerName: 'Critical', - type: 'number', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - }, - { - field: 'severitiesCount.high', - headerName: 'High', - type: 'number', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - }, - { - field: 'severitiesCount.medium', - headerName: 'Medium', - type: 'number', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - }, - { - field: 'severitiesCount.low', - headerName: 'Low', - type: 'number', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - }, - { - field: 'securityScore', - headerName: 'Security score', - type: 'string', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - valueFormatter: (param: ValueFormatterParams) => { - return `${param.value ? Number(param.value).toFixed(2) : '0'}%` - }, - }, - { - field: 'lastCheckTime', - headerName: 'Last checked', - type: 'datetime', - sortable: true, - filter: true, - resizable: true, - flex: 1, - hide: true, - valueFormatter: (param: ValueFormatterParams) => { - return param.value ? dateTimeDisplay(param.value) : '' - }, - }, -] - -export default function Services({ id, connections, resourceId }: IFinder) { - const { response: findings, isLoading } = - useComplianceApiV1FindingsServicesDetail(id || '', { - connectionId: connections.connections, - connectionGroup: connections.connectionGroup, - ...(resourceId && { - resourceCollection: [resourceId], - }), - }) - - const options: GridOptions = { - enableGroupEdit: true, - columnTypes: { - dimension: { - enableRowGroup: true, - enablePivot: true, - }, - }, - rowGroupPanelShow: 'always', - groupAllowUnbalanced: true, - } - - return ( -
{ - if (isLoading) { - e.api.showLoadingOverlay() - } - }} - loading={isLoading} - /> - ) -} diff --git a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/index.tsx b/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/index.tsx deleted file mode 100644 index d15a1f962..000000000 --- a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/TopDetails/index.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import DrawerPanel from '../../../../../components/DrawerPanel' -import CloudAccounts from './CloudAccounts' -import Services from './Services' -import Controls from './Controls' -import { IFilter } from '../../../../../utilities/urlstate' - -interface ITop { - open: boolean - onClose: () => void - id: string | undefined - type: 'services' | 'accounts' | 'controls' - connections: IFilter - resourceId: string | undefined -} -export default function TopDetails({ - id, - type, - connections, - resourceId, - open, - onClose, -}: ITop) { - const renderDetail = () => { - switch (type) { - case 'accounts': - return ( - - ) - case 'services': - return ( - - ) - case 'controls': - return - default: - return ( - - ) - } - } - return ( - - {renderDetail()} - - ) -} diff --git a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/index.tsx b/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/index.tsx deleted file mode 100644 index c917dca9f..000000000 --- a/services/web-ui/src/pages/Governance/Compliance/BenchmarkSummary/index.tsx +++ /dev/null @@ -1,238 +0,0 @@ -import { useParams } from 'react-router-dom' -import { Card, Flex, Grid, Text, Title } from '@tremor/react' -import { useEffect, useState } from 'react' -import { - useComplianceApiV1BenchmarksSummaryDetail, - useComplianceApiV1BenchmarksTrendDetail, - useComplianceApiV1FindingEventsCountList, -} from '../../../../api/compliance.gen' -import { useScheduleApiV1ComplianceTriggerUpdate } from '../../../../api/schedule.gen' -import Spinner from '../../../../components/Spinner' -import Controls from '../../Controls' -import TopHeader from '../../../../components/Layout/Header' -import { - defaultTime, - useFilterState, - useUrlDateRangeState, -} from '../../../../utilities/urlstate' -import BenchmarkChart from '../../../../components/Benchmark/Chart' -import { toErrorMessage } from '../../../../types/apierror' -import SummaryCard from '../../../../components/Cards/SummaryCard' - -export default function BenchmarkSummary() { - const { ws } = useParams() - const { value: activeTimeRange } = useUrlDateRangeState( - defaultTime(ws || '') - ) - const { benchmarkId } = useParams() - const { value: selectedConnections } = useFilterState() - const [assignments, setAssignments] = useState(0) - const [recall, setRecall] = useState(false) - - const topQuery = { - ...(benchmarkId && { benchmarkId: [benchmarkId] }), - ...(selectedConnections.provider && { - connector: [selectedConnections.provider], - }), - ...(selectedConnections.connections && { - connectionId: selectedConnections.connections, - }), - ...(selectedConnections.connectionGroup && { - connectionGroup: selectedConnections.connectionGroup, - }), - } - - const { - response: benchmarkDetail, - isLoading, - sendNow: updateDetail, - } = useComplianceApiV1BenchmarksSummaryDetail(String(benchmarkId)) - const { sendNowWithParams: triggerEvaluate, isExecuted } = - useScheduleApiV1ComplianceTriggerUpdate( - { - benchmark_id: [], - connection_id: [], - }, - {}, - false - ) - - const { - response: benchmarkKPIStart, - isLoading: benchmarkKPIStartLoading, - sendNow: benchmarkKPIStartSend, - } = useComplianceApiV1BenchmarksSummaryDetail(String(benchmarkId), { - ...topQuery, - timeAt: activeTimeRange.start.unix(), - }) - const { - response: benchmarkKPIEnd, - isLoading: benchmarkKPIEndLoading, - sendNow: benchmarkKPIEndSend, - } = useComplianceApiV1BenchmarksSummaryDetail(String(benchmarkId), { - ...topQuery, - timeAt: activeTimeRange.end.unix(), - }) - - const hideKPIs = - (benchmarkKPIEnd?.conformanceStatusSummary?.failed || 0) + - (benchmarkKPIEnd?.conformanceStatusSummary?.passed || 0) + - (benchmarkKPIStart?.conformanceStatusSummary?.failed || 0) + - (benchmarkKPIStart?.conformanceStatusSummary?.passed || 0) === - 0 - - const { - response: trend, - isLoading: trendLoading, - error: trendError, - sendNow: sendTrend, - } = useComplianceApiV1BenchmarksTrendDetail(String(benchmarkId), { - ...topQuery, - startTime: activeTimeRange.start.unix(), - endTime: activeTimeRange.end.unix(), - }) - - useEffect(() => { - if (isExecuted || recall) { - updateDetail() - } - }, [isExecuted, recall]) - - return ( - <> - - {isLoading ? ( - - ) : ( - <> - - - - {benchmarkDetail?.title} - -
- - {benchmarkDetail?.description} - - - {benchmarkDetail?.description} - -
-
- -
- - {hideKPIs ? ( - '' - ) : ( - - - - - - - - - {/* */} - - )} - {trend === null ? ( - '' - ) : ( - sendTrend()} - /> - )} - - - - )} - - ) -} diff --git a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Findings/ControlsWithFailure/index.tsx b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Findings/ControlsWithFailure/index.tsx index 9a06d0cb3..91b90da40 100644 --- a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Findings/ControlsWithFailure/index.tsx +++ b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Findings/ControlsWithFailure/index.tsx @@ -9,7 +9,7 @@ import { TypesFindingSeverity, } from '../../../../../../api/api' import Table, { IColumn } from '../../../../../../components/Table' -import { topControls } from '../../../../Compliance/BenchmarkSummary/TopDetails/Controls' +import { topControls } from '../../TopDetails/Controls' import { severityBadge } from '../../../../Controls' import { DateRange, searchAtom } from '../../../../../../utilities/urlstate' diff --git a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Settings/index.tsx b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Settings/index.tsx index b0c9c88b4..8befaf0ce 100644 --- a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Settings/index.tsx +++ b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/Settings/index.tsx @@ -17,8 +17,6 @@ import DrawerPanel from '../../../../../components/DrawerPanel' import Table, { IColumn } from '../../../../../components/Table' import { useComplianceApiV1AssignmentsBenchmarkDetail, - useComplianceApiV1AssignmentsConnectionCreate, - useComplianceApiV1AssignmentsConnectionDelete, useComplianceApiV1BenchmarksSettingsCreate, } from '../../../../../api/compliance.gen' import Spinner from '../../../../../components/Spinner' @@ -48,59 +46,6 @@ interface ISettings { reload: () => void } -const columns: (isDemo: boolean) => IColumn[] = (isDemo) => [ - { - width: 120, - sortable: true, - filter: true, - enableRowGroup: true, - type: 'string', - field: 'connector', - }, - { - field: 'providerConnectionName', - headerName: 'Connection Name', - type: 'string', - sortable: true, - filter: true, - resizable: true, - flex: 1, - cellRenderer: (param: ValueFormatterParams) => ( - {param.value} - ), - }, - { - field: 'providerConnectionID', - headerName: 'Connection ID', - type: 'string', - sortable: true, - filter: true, - resizable: true, - flex: 1, - cellRenderer: (param: ValueFormatterParams) => ( - {param.value} - ), - }, - { - headerName: 'Enable', - sortable: true, - type: 'string', - filter: true, - resizable: true, - flex: 0.5, - cellRenderer: (params: any) => { - return ( - - - - ) - }, - }, -] interface ITransferState { connectionID: string @@ -116,10 +61,7 @@ export default function Settings({ reload, }: ISettings) { const [firstLoading, setFirstLoading] = useState(true) - const [transfer, setTransfer] = useState({ - connectionID: '', - status: false, - }) + const [allEnable, setAllEnable] = useState(autoAssign) const [enableStatus,setEnableStatus] = useState('') const [banner, setBanner] = useState(autoAssign) @@ -213,16 +155,7 @@ export default function Settings({ // setFirstLoading(false) }, []) - useEffect(() => { - if (enableExecuted && !enableLoading) { - setTransfer({ connectionID: '', status: false }) - // refreshList() - } - if (disableExecuted && !disableLoading) { - setTransfer({ connectionID: '', status: false }) - // refreshList() - } - }, [enableExecuted, disableExecuted, enableLoading, disableLoading]) + const GetEnabled = () => { setLoading(true) diff --git a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/index.tsx b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/index.tsx index 978d8e261..e8c0b8ace 100644 --- a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/index.tsx +++ b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/index.tsx @@ -27,7 +27,6 @@ import DateRangePicker from '@cloudscape-design/components/date-range-picker' import { useEffect, useState } from 'react' import { useComplianceApiV1BenchmarksSummaryDetail, - useComplianceApiV1BenchmarksTrendDetail, useComplianceApiV1FindingEventsCountList, } from '../../../../api/compliance.gen' import { useScheduleApiV1ComplianceTriggerUpdate } from '../../../../api/schedule.gen' @@ -164,7 +163,7 @@ export default function NewBenchmarkSummary() { return item.Critical }), type: 'line', - } + }, ], } return opt @@ -274,18 +273,7 @@ export default function NewBenchmarkSummary() { (benchmarkKPIStart?.conformanceStatusSummary?.passed || 0) === 0 - const { - response: trend, - isLoading: trendLoading, - error: trendError, - sendNow: sendTrend, - } = useComplianceApiV1BenchmarksTrendDetail(String(benchmarkId), { - ...topQuery, - startTime: activeTimeRange.start.unix(), - endTime: activeTimeRange.end.unix(), - }) const GetEnabled = () => { - let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL @@ -334,7 +322,6 @@ export default function NewBenchmarkSummary() { }) } const GetChart = () => { - let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL @@ -381,10 +368,11 @@ export default function NewBenchmarkSummary() { 'Non Compliant': item.compliance_results_summary?.non_incidents, High: item.incidents_severity_breakdown.highCount, - Medium: - item.incidents_severity_breakdown.mediumCount, + Medium: item.incidents_severity_breakdown + .mediumCount, Low: item.incidents_severity_breakdown.lowCount, - Critical: item.incidents_severity_breakdown.criticalCount, + Critical: + item.incidents_severity_breakdown.criticalCount, } return temp_data } @@ -400,8 +388,7 @@ export default function NewBenchmarkSummary() { console.log(err) }) } - const RunBenchmark = (c: any[],b: boolean) => { - + const RunBenchmark = (c: any[], b: boolean) => { let url = '' if (window.location.origin === 'http://localhost:3000') { url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL @@ -485,7 +472,7 @@ export default function NewBenchmarkSummary() { } }, [enable]) const find_tabs = () => { - const tabs =[] + const tabs = [] tabs.push({ label: 'Controls', id: 'second', @@ -494,7 +481,7 @@ export default function NewBenchmarkSummary() {
@@ -510,52 +497,53 @@ export default function NewBenchmarkSummary() { disabledReason: 'This is available when the Framework has at least one assignments.', }) - if(!['baseline_efficiency', - 'baseline_reliability', - 'baseline_security', - 'baseline_supportability'].includes(benchmarkDetail?.id)){ - tabs.push({ - label: 'Settings', - id: 'fourth', - content: ( - setAssignments(e)} - autoAssign={benchmarkDetail?.autoAssign} - tracksDriftEvents={ - benchmarkDetail?.tracksDriftEvents - } - isAutoResponse={(x) => setRecall(true)} - reload={() => updateDetail()} - /> - ), - disabled: false, - }) - } + if ( + ![ + 'baseline_efficiency', + 'baseline_reliability', + 'baseline_security', + 'baseline_supportability', + ].includes(benchmarkDetail?.id) + ) { tabs.push({ - label: 'Run History', - id: 'fifth', + label: 'Settings', + id: 'fourth', content: ( - { - triggerEvaluate( - { - benchmark_id: [benchmarkId || ''], - connection_id: c, - }, - {} - ) - }} + response={(e) => setAssignments(e)} + autoAssign={benchmarkDetail?.autoAssign} + tracksDriftEvents={benchmarkDetail?.tracksDriftEvents} + isAutoResponse={(x) => setRecall(true)} + reload={() => updateDetail()} /> ), - // disabled: true, - // disabledReason: 'COMING SOON', + disabled: false, }) - return tabs - + } + tabs.push({ + label: 'Run History', + id: 'fifth', + content: ( + { + triggerEvaluate( + { + benchmark_id: [benchmarkId || ''], + connection_id: c, + }, + {} + ) + }} + /> + ), + // disabled: true, + // disabledReason: 'COMING SOON', + }) + return tabs } return ( @@ -833,7 +821,7 @@ export default function NewBenchmarkSummary() { */} {/* {chart && enable && ( */} - {false && ( + {false && ( <> {/* +// {/* {hideKPIs ? ( +// '' +// ) : ( +// +// +// - // { - // label: 'Summary', - // id: 'first', - // content: ( - // - // {/* {hideKPIs ? ( - // '' - // ) : ( - // - // - // - - // +// - // - // - // )} */} - // {trend === null ? ( - // '' - // ) : ( - // // sendTrend()} - // // /> - // +// +// +// )} */} +// {trend === null ? ( +// '' +// ) : ( +// // sendTrend()} +// // /> +// diff --git a/services/web-ui/src/pages/Governance/Overview/ComplianceSection/index.tsx b/services/web-ui/src/pages/Governance/Overview/ComplianceSection/index.tsx deleted file mode 100644 index ced6853f6..000000000 --- a/services/web-ui/src/pages/Governance/Overview/ComplianceSection/index.tsx +++ /dev/null @@ -1,192 +0,0 @@ -import { - Button, - Card, - Flex, - Grid, - ProgressCircle, - Subtitle, - Text, - Title, -} from '@tremor/react' -import { useNavigate, useParams } from 'react-router-dom' -import { ChevronRightIcon } from '@heroicons/react/20/solid' -import { useAtomValue } from 'jotai' -import { useComplianceApiV1BenchmarksSummaryList } from '../../../../api/compliance.gen' -import { - errorHandlingWithErrorMessage, - getErrorMessage, - toErrorMessage, -} from '../../../../types/apierror' -import { searchAtom } from '../../../../utilities/urlstate' -import { getConnectorsIcon } from '../../../../components/Cards/ConnectorCard' - -function CorrespondingColor(value: number) { - if (value < 25) return 'rose' - if (value >= 25 && value < 50) return 'amber' - if (value >= 50) return 'emerald' - return 'slate' -} - -function ValueCalculator(bs: any) { - return ( - ((bs?.controlsSeverityStatus?.total?.passed || 0) / - (bs?.controlsSeverityStatus?.total?.total || 1)) * - 100 - ) -} - -export default function Compliance() { - const workspace = useParams<{ ws: string }>().ws - const navigate = useNavigate() - const searchParams = useAtomValue(searchAtom) - - const { - response: benchmarks, - isLoading, - error, - sendNow: refresh, - } = useComplianceApiV1BenchmarksSummaryList() - - const sorted = [...(benchmarks?.benchmarkSummary || [])].filter((b) => { - const ent = Object.entries(b.tags || {}) - return ( - ent.filter( - (v) => - v[0] === 'kaytu_benchmark_type' && v[1][0] === 'compliance' - ).length > 0 - ) - }) - sorted.sort((a, b) => { - const bScore = - (b?.controlsSeverityStatus?.total?.passed || 0) / - (b?.controlsSeverityStatus?.total?.total || 1) - const aScore = - (a?.controlsSeverityStatus?.total?.passed || 0) / - (a?.controlsSeverityStatus?.total?.total || 1) - - const aZero = (a?.controlsSeverityStatus?.total?.total || 0) === 0 - const bZero = (b?.controlsSeverityStatus?.total?.total || 0) === 0 - - if ((aZero && bZero) || aScore === bScore) { - return 0 - } - if (aZero) { - return 1 - } - if (bZero) { - return -1 - } - return aScore > bScore ? 1 : -1 - }) - - return ( - - {' '} - - - Benchmarks - - - {isLoading || getErrorMessage(error).length > 0 ? ( - - {[1, 2, 3, 4].map((i) => { - return ( - - - -
- -
-
- - - ) - })} - - ) : ( - - {sorted?.map( - (bs, i) => - i < 4 && ( - - navigate( - `/compliance/${bs.id}?${searchParams}` - ) - } - className="p-3 cursor-pointer dark:ring-gray-500 hover:shadow-md" - > - - - {bs?.tags?.kaytu_logo - ? bs?.tags?.kaytu_logo.map( - (logo) => ( -
- {logo} -
- ) - ) - : getConnectorsIcon( - bs?.connectors || [] - )} -
-
- - - {bs.title} - - {(bs.controlsSeverityStatus?.total - ?.total || 0) > 0 && ( - - {( - ValueCalculator(bs) || 0 - ).toFixed(0)} - <span className="font-medium text-xs ml-0.5"> - % - </span> - - )} -
- ) - )} - - {errorHandlingWithErrorMessage( - refresh, - toErrorMessage(error) - )} -
- )} - - - ) -} diff --git a/services/web-ui/src/pages/Governance/Overview/SummarySection/index.tsx b/services/web-ui/src/pages/Governance/Overview/SummarySection/index.tsx deleted file mode 100644 index 458c830b4..000000000 --- a/services/web-ui/src/pages/Governance/Overview/SummarySection/index.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { Badge, Card, Flex, Text, Title } from '@tremor/react' -import { ArrowDownFill } from '../../../../icons/icons' -import LightBadge from '../../../../components/LightBadge' -import { useComplianceApiV1ControlsSummaryList } from '../../../../api/compliance.gen' - -export default function SummarySection() { - const { response, isLoading, isExecuted, error } = - useComplianceApiV1ControlsSummaryList() - - const total = new Map() - const passed = new Map() - response?.forEach((i) => { - Object.entries(i.control?.tags || {}) - .filter((v) => v[0] === 'score_tags') - .flatMap((v) => v[1]) - .forEach((v) => { - if (i.passed) { - passed.set(v, (passed.get(v) || 0) + 1) - } - total.set(v, (total.get(v) || 0) + 1) - }) - }) - - const SummaryList = [ - { - title: 'Cloud Accounts with MFA ', - value: 45, - change: 10, - }, - { - title: 'Subnets with Unrestricted Traffic', - value: 23, - change: -10, - }, - { title: 'Unrecoverable KeyVaults', value: 31, change: 0 }, - { title: 'Problematic IAM Roles', value: 19, change: -25 }, - { title: 'Non-SSO Users', value: 28, change: 15 }, - { title: 'Cloud Access without MFA', value: 116, change: 80 }, - { title: 'Missing Audit Logs', value: 6, change: -5 }, - ] /* .map((i) => { - return { - title: i.title, - value: passed.get(i.title)||0, - score: (passed.get(i.title) || 0) / (total.get(i.title) || 1), - } - }) */ - - return ( - - Summary - - {SummaryList.map((i) => ( - - {i.title} - - - {i.value} - - - - - - - ))} - - - ) -} diff --git a/services/web-ui/src/pages/Governance/Overview/index.tsx b/services/web-ui/src/pages/Governance/Overview/index.tsx deleted file mode 100644 index 8d4e6ad93..000000000 --- a/services/web-ui/src/pages/Governance/Overview/index.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import { Badge, Card, Col, Flex, Grid, Text, Title } from '@tremor/react' -import TopHeader from '../../../components/Layout/Header' -import ComplianceSection from './ComplianceSection' -import SummarySection from './SummarySection' -import AdvancedKPIGroup from '../../../components/KPIGroup/AdvancedKPIGroup' -import SimpleKPIGroup from '../../../components/KPIGroup/SimpleKPIGroup' -import { IKPISingleItem } from '../../../components/KPIGroup/KPISingleItem' - -export default function SecurityOverview() { - const CloudAccessKPIs: IKPISingleItem[] = [ - { title: 'Users with Non-Compliant MFA', value: 45, change: 13 }, - { title: 'Non-Compliant API Keys', value: 87, change: 50 }, - { title: 'Duplicate Access', value: 37, change: -25 }, - { title: 'Users with Excessive Permissions', value: 94, change: -5 }, - ] - const NetworkKPIs: IKPISingleItem[] = [ - { title: 'Load Balancers with no WAF', value: 89, change: 33 }, - { title: 'VMs on Public Subnet', value: 34, change: 0 }, - { title: 'Insecure Certificate', value: 61, change: 5 }, - { - title: 'VM with FTP/SMTP/RDP/SSH Open', - value: 19, - change: -10, - }, - ] - - const DataKPIs: IKPISingleItem[] = [ - { title: 'Unencrypted Storage', value: 29, change: 10 }, - { title: 'Systems with no backup', value: 63, change: -15 }, - { title: 'Internet Accessible Databases', value: 26, change: 0 }, - { - title: 'Storage with no Authentication', - value: 22, - change: 25, - }, - ] - - const WebAndAppKPIs: IKPISingleItem[] = [ - { title: 'Users with Non-Compliant MFA', value: 12, change: 12 }, - { title: 'Non-Compliant API Keys', value: 12, change: 12 }, - ] - - return ( - <> - - - -
- - - - - - - - - - - - - - - - - - - - ) -} diff --git a/services/web-ui/src/pages/Insights/Details/index.tsx b/services/web-ui/src/pages/Insights/Details/index.tsx deleted file mode 100644 index 299aaa2b5..000000000 --- a/services/web-ui/src/pages/Insights/Details/index.tsx +++ /dev/null @@ -1,899 +0,0 @@ -import { Link, useNavigate, useParams } from 'react-router-dom' -import { useSetAtom } from 'jotai' -import { useEffect, useState } from 'react' -import { - Button, - Card, - Flex, - Grid, - Tab, - TabGroup, - TabList, - Text, - Title, - Badge, - Metric, - Icon, - TabPanels, - TabPanel, -} from '@tremor/react' -import MarkdownPreview from '@uiw/react-markdown-preview' -import Editor from 'react-simple-code-editor' -import { highlight, languages } from 'prismjs' -import { - DocumentDuplicateIcon, - DocumentTextIcon, - CommandLineIcon, - Square2StackIcon, - ClockIcon, - CodeBracketIcon, - Cog8ToothIcon, - BookOpenIcon, - PencilIcon, -} from '@heroicons/react/24/outline' -import clipboardCopy from 'clipboard-copy' -import { ChevronRightIcon } from '@heroicons/react/20/solid' -import { notificationAtom, queryAtom } from '../../../store' -import { dateTimeDisplay } from '../../../utilities/dateDisplay' -import { - useComplianceApiV1BenchmarksSummaryDetail, - useComplianceApiV1ControlsSummaryDetail, -} from '../../../api/compliance.gen' -import Spinner from '../../../components/Spinner' -import Modal from '../../../components/Modal' -import TopHeader from '../../../components/Layout/Header' -import { useFilterState } from '../../../utilities/urlstate' -import SummaryCard from '../../../components/Cards/SummaryCard' -import EaseOfSolutionChart from '../../../components/EaseOfSolutionChart' -import ImpactedResources from '../../Governance/Controls/ControlSummary/Tabs/ImpactedResources' -import ImpactedAccounts from '../../Governance/Controls/ControlSummary/Tabs/ImpactedAccounts' -import { severityBadge } from '../../Governance/Controls' -import { - GithubComKaytuIoKaytuEnginePkgComplianceApiConformanceStatus, - SourceType, -} from '../../../api/api' -import DrawerPanel from '../../../components/DrawerPanel' -import { numberDisplay } from '../../../utilities/numericDisplay' -import { useMetadataApiV1QueryParameterList } from '../../../api/metadata.gen' -import { - useScheduleApiV1ComplianceReEvaluateUpdate, - useScheduleApiV1ComplianceTriggerUpdate, -} from '../../../api/schedule.gen' - -export default function ScoreDetails() { - const { id, ws } = useParams() - const { value: selectedConnections } = useFilterState() - const navigate = useNavigate() - - const [doc, setDoc] = useState('') - const [docTitle, setDocTitle] = useState('') - const [modalData, setModalData] = useState('') - const setNotification = useSetAtom(notificationAtom) - const setQuery = useSetAtom(queryAtom) - const [hideTabs, setHideTabs] = useState(false) - const [selectedTabIndex, setSelectedTabIndex] = useState(0) - - const { response: controlDetail, isLoading } = - useComplianceApiV1ControlsSummaryDetail(String(id), { - connectionId: selectedConnections.connections, - }) - - const { - response: parameters, - isLoading: parametersLoading, - isExecuted, - sendNow: refresh, - } = useMetadataApiV1QueryParameterList() - - const benchmarkID = controlDetail?.benchmarks?.at(0)?.id || '' - - const { - error: reevaluateError, - isLoading: isReevaluateLoading, - isExecuted: isReevaluateExecuted, - sendNow: ReEvaluate, - } = useScheduleApiV1ComplianceTriggerUpdate( - { - benchmark_id: [benchmarkID], - connection_id: [], - }, - {}, - false - ) - - const { - response: benchmarkDetail, - isLoading: benchmarkDetailsLoading, - isExecuted: benchmarkDetailsExecuted, - sendNow: refreshBenchmark, - } = useComplianceApiV1BenchmarksSummaryDetail( - benchmarkID, - {}, - {}, - benchmarkID !== '' - ) - - useEffect(() => { - if (isReevaluateExecuted && !isReevaluateLoading) { - refreshBenchmark() - } - }, [isReevaluateLoading]) - - const isJobRunning = - benchmarkDetail?.lastJobStatus !== 'FAILED' && - benchmarkDetail?.lastJobStatus !== 'SUCCEEDED' && - (benchmarkDetail?.lastJobStatus || '') !== '' - - const reEvaluateButtonLoading = - (isReevaluateExecuted && isReevaluateLoading) || - (benchmarkDetailsExecuted && benchmarkDetailsLoading) || - (benchmarkDetailsExecuted && isJobRunning) - - const costSaving = controlDetail?.costOptimization || 0 - - const customizableQuery = - (controlDetail?.control?.query?.parameters?.length || 0) > 0 || - (controlDetail?.control?.query?.queryToExecute || '').includes('{{') - - const [conformanceFilter, setConformanceFilter] = useState< - | GithubComKaytuIoKaytuEnginePkgComplianceApiConformanceStatus[] - | undefined - >(undefined) - const conformanceFilterIdx = () => { - if ( - conformanceFilter?.length === 1 && - conformanceFilter[0] === - GithubComKaytuIoKaytuEnginePkgComplianceApiConformanceStatus.ConformanceStatusFailed - ) { - return 1 - } - if ( - conformanceFilter?.length === 1 && - conformanceFilter[0] === - GithubComKaytuIoKaytuEnginePkgComplianceApiConformanceStatus.ConformanceStatusFailed - ) { - return 2 - } - return 0 - } - - return ( - <> - - {isLoading || parametersLoading ? ( - - - - ) : ( - <> - - - - {controlDetail?.control?.title} - - {severityBadge(controlDetail?.control?.severity)} - - - -
- - {controlDetail?.control?.description} - - - - { - controlDetail?.control - ?.description - } - - -
- - - -
- -
- - - - - - { - clipboardCopy( - controlDetail?.control?.id || '' - ) - }} - > - - - Control ID: {controlDetail?.control?.id} - - - - - - Last updated:{' '} - {(controlDetail?.evaluatedAt || 0) <= 0 - ? 'Never' - : dateTimeDisplay( - controlDetail?.evaluatedAt - )} - - - - {controlDetail?.control?.query?.parameters?.map( - (item) => { - return ( - { - navigate( - `compliance/library/parameters&key=${item.key}` - ) - }} - > - - - {item.key}:{' '} - {parameters?.queryParameters - ?.filter( - (p) => - p.key === - item.key - ) - .map( - (p) => p.value || '' - ) || 'Not defined'} - - - ) - } - )} - - - - setModalData('')} - > - Query - - - 1} - highlight={(text) => - highlight(text, languages.sql, 'sql') - } - value={modalData} - className="w-full bg-white dark:bg-gray-900 dark:text-gray-50 font-mono text-sm" - style={{ - minHeight: '200px', - }} - placeholder="-- write your SQL query here" - /> - - - Customizable Parameters: - {controlDetail?.control?.query?.parameters?.map( - (param) => { - return - {param.key} - } - )} - - - Click here to change parameters - - - - - - - - - - - - - - - {costSaving !== 0 && ( - - )} - - - - {numberDisplay( - (controlDetail?.totalResourcesCount || - 0) - - (controlDetail?.failedResourcesCount || - 0), - 0 - )} - - - of{' '} - {numberDisplay( - controlDetail?.totalResourcesCount || - 0, - 0 - )} - - - } - isElement - onClick={() => { - setSelectedTabIndex(0) - }} - cardClickable - /> - - - - {numberDisplay( - controlDetail?.failedResourcesCount || - 0, - 0 - )} - - - of{' '} - {numberDisplay( - controlDetail?.totalResourcesCount || - 0, - 0 - )} - - - } - isElement - onClick={() => { - setSelectedTabIndex(0) - }} - cardClickable - /> - { - setSelectedTabIndex(1) - }} - cardClickable - /> - - - {(controlDetail?.control?.manualRemediation && - controlDetail?.control?.manualRemediation.length > 0) || - (controlDetail?.control?.cliRemediation && - controlDetail?.control?.cliRemediation.length > 0) || - (controlDetail?.control?.programmaticRemediation && - controlDetail?.control?.programmaticRemediation.length > - 0) || - (controlDetail?.control?.guardrailRemediation && - controlDetail?.control?.guardrailRemediation.length > - 0) ? ( - - - - - - - - 0} - onClose={() => setDoc('')} - > - { - if ( - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - node.tagName === 'a' && - parent && - /^h(1|2|3|4|5|6)/.test( - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - parent.tagName - ) - ) { - // eslint-disable-next-line no-param-reassign - parent.children = - parent.children.slice(1) - } - }} - /> - - - Remediation - - - - { - if ( - controlDetail?.control - ?.manualRemediation && - controlDetail?.control - ?.manualRemediation - .length - ) { - setDoc( - controlDetail - ?.control - ?.manualRemediation - ) - setDocTitle( - 'Manual remediation' - ) - } - }} - > - - - - - Manual - - - - - - Step by Step Guided solution - to resolve instances of - non-compliance - - - { - if ( - controlDetail?.control - ?.cliRemediation && - controlDetail?.control - ?.cliRemediation - .length - ) { - setDoc( - controlDetail - ?.control - ?.cliRemediation - ) - setDocTitle( - 'Command line (CLI) remediation' - ) - } - }} - > - - - - - Command line (CLI) - - - - - - Guided steps to resolve the - issue utilizing CLI - - - { - if ( - controlDetail?.control - ?.guardrailRemediation && - controlDetail?.control - ?.guardrailRemediation - .length - ) { - setDoc( - controlDetail - ?.control - ?.guardrailRemediation - ) - setDocTitle( - 'Guard rails remediation' - ) - } - }} - > - - - - - Guard rails - - - - - - Resolve and ensure - compliance, at scale - utilizing solutions where - possible - - - { - if ( - controlDetail?.control - ?.programmaticRemediation && - controlDetail?.control - ?.programmaticRemediation - .length - ) { - setDoc( - controlDetail - ?.control - ?.programmaticRemediation - ) - setDocTitle( - 'Programmatic remediation' - ) - } - }} - > - - - - - Programmatic - - - - - - Scripts that help you - resolve the issue, at scale - - - -
-
- - - - - ) : null} - - {!hideTabs && ( - - -
- - Impacted resources - Impacted accounts - {/* Findings */} - -
- - - Confomance Status filter: - - { - switch (tabIndex) { - case 1: - setConformanceFilter([ - GithubComKaytuIoKaytuEnginePkgComplianceApiConformanceStatus.ConformanceStatusFailed, - ]) - break - case 2: - setConformanceFilter([ - GithubComKaytuIoKaytuEnginePkgComplianceApiConformanceStatus.ConformanceStatusPassed, - ]) - break - default: - setConformanceFilter( - undefined - ) - } - }} - > - - All - Failed - Passed - - - -
- - - {selectedTabIndex === 0 && ( - - )} - - - {selectedTabIndex === 1 && ( - - )} - - {/* - {selectedTabIndex === 2 && ( - - )} - */} - -
- )} - - )} - - ) -} diff --git a/services/web-ui/src/pages/Insights/ScoreCategory/index.tsx b/services/web-ui/src/pages/Insights/ScoreCategory/index.tsx deleted file mode 100644 index d13d19c36..000000000 --- a/services/web-ui/src/pages/Insights/ScoreCategory/index.tsx +++ /dev/null @@ -1,1269 +0,0 @@ -// @ts-noCheck -import { useCallback, useEffect, useState } from 'react' -import { - Button, - Card, - Flex, - Text, - Switch, - TextInput, - Accordion, - AccordionHeader, - AccordionBody, - LineChart, - Grid, - Col -} from '@tremor/react' -import Table from '@cloudscape-design/components/table' -import Box from '@cloudscape-design/components/box' -import SpaceBetween from '@cloudscape-design/components/space-between' -import TextFilter from '@cloudscape-design/components/text-filter' -import Header from '@cloudscape-design/components/header' -import Badge from '@cloudscape-design/components/badge' -import KButton from '@cloudscape-design/components/button' -import PropertyFilter from '@cloudscape-design/components/property-filter' - -import { useAtomValue, useSetAtom } from 'jotai' -import { - CommandLineIcon, - BookOpenIcon, - CodeBracketIcon, - Cog8ToothIcon, - MagnifyingGlassIcon, - ChevronDownIcon, - ChevronRightIcon, - ChevronDoubleLeftIcon, - FunnelIcon, - CloudIcon, -} from '@heroicons/react/24/outline' -import { - GridOptions, - IAggFuncParams, - ICellRendererParams, - RowClickedEvent, - ValueFormatterParams, -} from 'ag-grid-community' -import { useNavigate } from 'react-router-dom' -import Link from '@cloudscape-design/components/link' -import { - useInventoryApiV3AllBenchmarksControls, -} from '../../../api/compliance.gen' -import { - GithubComKaytuIoKaytuEnginePkgComplianceApiControlSummary, - GithubComKaytuIoKaytuEnginePkgControlApiListV2ResponseItem, -} from '../../../api/api' -import TopHeader from '../../../components/Layout/Header' -import { - searchAtom, - useFilterState, - useURLParam, - useURLState, -} from '../../../utilities/urlstate' -import { getConnectorIcon } from '../../../components/Cards/ConnectorCard' -import { severityBadge } from '../../Governance/Controls' -import { - exactPriceDisplay, - numberDisplay, -} from '../../../utilities/numericDisplay' -import { useInventoryApiV3AllQueryCategory } from '../../../api/inventory.gen' -import { Api } from '../../../api/api' -import AxiosAPI from '../../../api/ApiConfig' -import ButtonDropdown from '@cloudscape-design/components/button-dropdown' -import Pagination from '@cloudscape-design/components/pagination' -import CollectionPreferences from '@cloudscape-design/components/collection-preferences' -import KFilter from '../../../components/Filter' -import { - BreadcrumbGroup, - Container, - ContentLayout, - DateRangePicker, - ExpandableSection, - -} from '@cloudscape-design/components' -import KGrid from '@cloudscape-design/components/grid' -import './style.css' -import Filter from '../../Governance/Compliance/NewBenchmarkSummary/Filter' -import Evaluate from '../../Governance/Compliance/NewBenchmarkSummary/Evaluate' -import axios from 'axios' -import { notificationAtom } from '../../../store' -import ReactEcharts from 'echarts-for-react' -import { numericDisplay } from '../../../utilities/numericDisplay' - -interface IRecord - extends GithubComKaytuIoKaytuEnginePkgComplianceApiControlSummary { - serviceName: string - tags: string[] - passedResourcesCount?: number -} - -interface IDetailCellRenderer { - data: IRecord -} - -// const DetailCellRenderer = ({ data }: IDetailCellRenderer) => { -// const searchParams = useAtomValue(searchAtom) -// return ( -// -// {data.control?.description} -// -// -// -// -// ) -// } - -export default function ScoreCategory() { - const { value: selectedConnections } = useFilterState() - const [category, setCategory] = useURLParam('score_category', '') - const [listofTables, setListOfTables] = useState([]) - const [selectedBread, setSelectedBread] = useState() - const [tree, setTree] = useState() - - const [selectedServiceNames, setSelectedServiceNames] = useURLState< - string[] - >( - [], - (v) => { - const res = new Map() - res.set('serviceNames', v) - return res - }, - (v) => { - return v.get('serviceNames') || [] - } - ) - const [queries, setQueries] = useState({ - tokens: [], - operation: 'and', - }) - - const navigate = useNavigate() - const searchParams = useAtomValue(searchAtom) - const [hideZero, setHideZero] = useState(true) - const [quickFilterValue, setQuickFilterValue] = useState('') - const [openSearch, setOpenSearch] = useState(true) - const [loading, setLoading] = useState(true) - const [page, setPage] = useState(0) - const [rows, setRows] = useState< - GithubComKaytuIoKaytuEnginePkgControlApiListV2ResponseItem[] - >([]) - const [totalPage, setTotalPage] = useState(0) - const [totalCount, setTotalCount] = useState(0) - - const [filters, setFilters] = useState([]) - const [filterOption, setFilterOptions] = useState([]) - const [benchmarkDetail, setBenchmarkDetail] = useState() - const [sort, setSort] = useState('incidents') - const [sortOrder, setSortOrder] = useState(true) - const [selected, setSelected] = useState() - const [isLoading, setIsLoading] = useState(false) - const [treePage, setTreePage] = useState(0) - const [treeTotal, setTreeTotal] = useState(0) - const [treeTotalPages, setTreeTotalPages] = useState(0) - - const [searchCategory, setSearchCategory] = useState('') - const categories = [ - 'security', - 'cost_optimization', - 'operational_excellence', - 'reliability', - 'performance_efficiency', - ] - - const navigateToInsightsDetails = (id: string) => { - navigate(`${id}?${searchParams}`) - } - - const GetControls = (flag: boolean, id: string | undefined) => { - setLoading(true) - const api = new Api() - api.instance = AxiosAPI - const benchmarks = category - - let body = { - list_of_tables: listofTables, - root_benchmark: flag ? [id] : [`sre_${category.toLowerCase()}`], - cursor: page, - severity: query?.severity, - per_page: 10, - finding_summary: true, - sort_by: sort, - sort_order: sortOrder ? 'desc' : 'asc', - } - if (listofTables.length == 0) { - // @ts-ignore - delete body['list_of_tables'] - } - api.compliance - .apiV2ControlList(body) - .then((resp) => { - setTotalPage(Math.ceil(resp.data.total_count / 10)) - setTotalCount(resp.data.total_count) - if (resp.data.items) { - setRows(resp.data.items) - } - setLoading(false) - }) - .catch((err) => { - setLoading(false) - setRows([]) - }) - } - const query = { - benchmarks: [`sre_${category}`, `sre_${category}`], - } - const { response: categoriesAll, isLoading: categoryLoading } = - // @ts-ignore - useInventoryApiV3AllBenchmarksControls(query) - const GetTree = () => { - let url = '' - if (window.location.origin === 'http://localhost:3000') { - url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL - } else { - url = window.location.origin - } - // @ts-ignore - const token = JSON.parse(localStorage.getItem('openg_auth')).token - - const config = { - headers: { - Authorization: `Bearer ${token}`, - }, - } - axios - .get( - `${url}/main/compliance/api/v3/benchmarks/sre_${category.toLowerCase()}/nested`, - config - ) - .then((res) => { - const temp = [] - - if (res.data.children) { - // temp.push({ - // text: res.data.title, - // href: res.data.id, - // type: 'link', - // }) - res.data.children.map((item) => { - let childs = { - text: truncate(item.title), - href: item.id, - type: item.children - ? 'expandable-link-group' - : 'link', - } - if (item.children && item.children.length > 0) { - let child_item = [] - item.children.map((sub_item) => { - child_item.push({ - text: truncate(sub_item.title), - href: sub_item.id, - type: 'link', - parentId: item.id, - parentTitle: item.title, - }) - }) - childs['items'] = child_item - } - temp.push(childs) - }) - // setTree(res.data.children) - } else { - // temp.push({ - // text: res.data.title, - // href: res.data.id, - // type: 'link', - // }) - } - setTreeTotalPages(Math.ceil(temp.length / 12)) - setTreeTotal(temp.length) - setTreePage(0) - setTree(temp) - }) - .catch((err) => { - console.log(err) - }) - } - useEffect(() => { - GetControls(false) - GetTree() - }, []) - useEffect(() => { - if (selected) { - setPage(0) - GetControls(true, selected) - } - }, [selected]) - useEffect(() => { - if (selected) { - GetControls(true, selected) - } else { - GetControls(false) - } - }, [page]) - useEffect(() => { - if (selected) { - GetControls(true, selected) - } else { - GetControls(false) - } - }, [sort, sortOrder]) - // useEffect(() => { - // let temp = {} - - // queries?.tokenGroups?.map((item) => { - // // @ts-ignore - // if (temp[item.propertyKey] && temp[item.propertyKey].length > 0) { - // temp[item.propertyKey].push(item.value.toLowerCase()) - // } else { - // temp[item.propertyKey] = [] - // temp[item.propertyKey].push(item.value.toLowerCase()) - // } - // }) - // setQuery(temp) - // }, [queries]) - - // useEffect(() => { - // if (selected) { - // GetControls(true, selected) - // } else { - // GetControls(false) - // } - // }, [query]) - useEffect(() => { - // @ts-ignore - const temp = [] - // @ts-ignore - if (queries) { - // @ts-ignore - console.log(queries) - // @ts-ignore - queries?.tokens?.map((item) => { - // @ts-ignore - temp.push(item.value) - }) - } - // @ts-ignore - - setListOfTables(temp) - }, [queries]) - useEffect(() => { - // @ts-ignore - const temp = [] - // @ts-ignore - - const temp_options = [] - - categoriesAll?.categories.map((cat) => { - temp_options.push({ - key: cat?.category.replace(/\s/g, ''), - operators: ['='], - propertyLabel: `${cat?.category}`, - groupValuesLabel: `${cat?.category} values`, - }) - cat.tables?.map((subcat) => { - temp.push({ - propertyKey: cat?.category.replace(/\s/g, ''), - value: subcat?.table, - }) - }) - }) - // @ts-ignore - - setFilterOptions(temp_options) - // @ts-ignore - - setFilters(temp) - }, [categoriesAll]) - const today = new Date() - const lastWeek = new Date( - today.getFullYear(), - today.getMonth(), - today.getDate() - 7 - ) - const setNotification = useSetAtom(notificationAtom) - - const [value, setValue] = useState({ - type: 'absolute', - startDate: lastWeek.toUTCString(), - endDate: today.toUTCString(), - }) - const RunBenchmark = (c: any[]) => { - - let url = '' - if (window.location.origin === 'http://localhost:3000') { - url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL - } else { - url = window.location.origin - } - const body = { - integration_info: c.map((c) => { - return { - integration_id: c.value, - } - }), - } - // @ts-ignore - const token = JSON.parse(localStorage.getItem('openg_auth')).token - - const config = { - headers: { - Authorization: `Bearer ${token}`, - }, - } - // console.log(config) - axios - .post( - `${url}/main/schedule/api/v3/compliance/benchmark/sre_${category}/run`, - body, - config - ) - .then((res) => { - setNotification({ - text: `Run is Done You Job id is ${res.data.job_id}`, - type: 'success', - }) - }) - .catch((err) => { - console.log(err) - }) - } - const GetBenchmarks = () => { - setIsLoading(true) - let url = '' - if (window.location.origin === 'http://localhost:3000') { - url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL - } else { - url = window.location.origin - } - // @ts-ignore - const token = JSON.parse(localStorage.getItem('openg_auth')).token - - const config = { - headers: { - Authorization: `Bearer ${token}`, - }, - } - const body = { - benchmarks: [`sre_${category.toLowerCase()}`], - } - axios - .post( - `${url}/main/compliance/api/v3/compliance/summary/benchmark`, - body, - config - ) - .then((res) => { - // const temp = [] - setIsLoading(false) - setBenchmarkDetail(res.data[0]) - }) - .catch((err) => { - setIsLoading(false) - - console.log(err) - }) - } - const truncate = (text: string | undefined) => { - if (text) { - return text.length > 600 ? text.substring(0, 600) + '...' : text - } - } - const [chart, setChart] = useState() - const [enable, setEnable] = useState(false) - - const GetChart = () => { - - let url = '' - if (window.location.origin === 'http://localhost:3000') { - url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL - } else { - url = window.location.origin - } - // @ts-ignore - const token = JSON.parse(localStorage.getItem('openg_auth')).token - - const config = { - headers: { - Authorization: `Bearer ${token}`, - }, - } - axios - .post( - `${url}/main/compliance/api/v3/benchmarks/${`sre_${category.toLowerCase()}`}/trend`, - {}, - config - ) - .then((res) => { - const temp = res.data - const temp_chart = temp?.datapoints?.map((item) => { - if (item.findings_summary) { - const temp_data = { - date: new Date(item.timestamp) - .toLocaleDateString('en-US', { - month: 'short', - day: 'numeric', - hour: 'numeric', - minute: 'numeric', - hour12: !1, - }) - .split(',') - .join('\n'), - // Total: - // item?.findings_summary?.incidents + - // item?.findings_summary?.non_incidents, - Incidents: item.findings_summary?.incidents, - 'Non-Compliant': - item.findings_summary?.non_incidents, - } - return temp_data - } - }) - const new_chart = temp_chart.filter((item) => { - if (item) { - return item - } - }) - setChart(new_chart) - }) - .catch((err) => { - console.log(err) - }) - } - const GetEnabled = () => { - - let url = '' - if (window.location.origin === 'http://localhost:3000') { - url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL - } else { - url = window.location.origin - } - // @ts-ignore - const token = JSON.parse(localStorage.getItem('openg_auth')).token - - const config = { - headers: { - Authorization: `Bearer ${token}`, - }, - } - axios - .get( - `${url}/main/compliance/api/v3/benchmark/sre_${category.toLowerCase()}/assignments`, - config - ) - .then((res) => { - if ( - res.data.status == 'enabled' || - res.data.status == 'auto-enable' - ) { - setEnable(true) - // setTab(0) - } else { - setEnable(false) - // setTab(1) - } - // if (res.data) { - // if (res.data.items.length > 0) { - // setEnable(true) - // } else { - // setEnable(false) - // } - // } else { - // setEnable(false) - // } - }) - .catch((err) => { - console.log(err) - }) - } - const options = () => { - const confine = true - const opt = { - tooltip: { - confine, - trigger: 'axis', - axisPointer: { - type: 'line', - label: { - formatter: (param: any) => { - let total = 0 - if (param.seriesData && param.seriesData.length) { - for ( - let i = 0; - i < param.seriesData.length; - i += 1 - ) { - total += param.seriesData[i].data - } - } - - return `${param.value} (Total: ${total.toFixed(2)})` - }, - // backgroundColor: '#6a7985', - }, - }, - valueFormatter: (value: number | string) => { - return numericDisplay(value) - }, - order: 'valueDesc', - }, - grid: { - left: 45, - right: 0, - top: 20, - bottom: 40, - }, - xAxis: { - type: 'category', - data: chart?.map((item) => { - return item.date - }), - }, - yAxis: { - type: 'value', - }, - series: [ - { - name: 'Incidents', - data: chart?.map((item) => { - return item.Incidents - }), - type: 'line', - }, - { - name: 'Non Compliant', - - data: chart?.map((item) => { - return item['Non-Compliant'] - }), - type: 'line', - }, - ], - } - return opt - } - useEffect(() => { - // @ts-ignore - GetBenchmarks() - GetTree() - GetEnabled() - - }, []) - useEffect(() => { - // @ts-ignore - if(enable){ - GetChart() - - } - }, [enable]) - return ( - <> - {/* */} - - - { - // setAccount(e.connector) - }} - // id={id} - /> - {} - // setValue(detail.value) - } - value={undefined} - disabled={true} - relativeOptions={[ - { - key: 'previous-5-minutes', - amount: 5, - unit: 'minute', - type: 'relative', - }, - { - key: 'previous-30-minutes', - amount: 30, - unit: 'minute', - type: 'relative', - }, - { - key: 'previous-1-hour', - amount: 1, - unit: 'hour', - type: 'relative', - }, - { - key: 'previous-6-hours', - amount: 6, - unit: 'hour', - type: 'relative', - }, - ]} - isValidRange={(range) => { - if (range.type === 'absolute') { - const [startDateWithoutTime] = - range.startDate.split('T') - const [endDateWithoutTime] = - range.endDate.split('T') - if ( - !startDateWithoutTime || - !endDateWithoutTime - ) { - return { - valid: false, - errorMessage: - 'The selected date range is incomplete. Select a start and end date for the date range.', - } - } - if ( - new Date(range.startDate) - - new Date(range.endDate) > - 0 - ) { - return { - valid: false, - errorMessage: - 'The selected date range is invalid. The start date must be before the end date.', - } - } - } - return { valid: true } - }} - i18nStrings={{}} - absoluteFormat="long-localized" - hideTimeOffset - placeholder="Last 7 days" - /> - - - ) : ( - '' - ) - } - header={ -
- - -
- - - {benchmarkDetail?.benchmark_title} - - - -
- - {/* @ts-ignore */} - {truncate( - benchmarkDetail?.description - )} - - - - { - benchmarkDetail?.description - } - - -
-
- - - { - RunBenchmark(c) - }} - /> - -
-
-
-
- } - >
- - {chart && enable && ( - <> - - {/* console.log(v)} - /> */} - {}} - /> - - - )} - -
- { - event.preventDefault() - setSelected(event.detail.href) - }} - items={selectedBread} - ariaLabel="Breadcrumbs" - /> - - {tree && tree.length > 0 && ( - - - <> - { - event.preventDefault() - setSelected(event.detail.href) - const temp = [] - - if (event.detail.parentId) { - temp.push({ - text: controls?.benchmark - ?.title, - href: id, - }) - temp.push({ - text: event.detail - .parentTitle, - href: event.detail.parentId, - }) - temp.push({ - text: event.detail.text, - href: event.detail.href, - }) - } else { - temp.push({ - text: controls?.benchmark - ?.title, - href: id, - }) - if ( - event.detail.text !== - controls?.benchmark?.title - ) { - temp.push({ - text: event.detail.text, - href: event.detail.href, - }) - } - } - setSelectedBread(temp) - }} - items={tree?.slice( - treePage * 12, - (treePage + 1) * 12 - )} - /> - - - setTreePage(detail.currentPageIndex - 1) - } - /> - - - )} - 0 ? 9 : 12}> - {' '} - {filters && - filters.length > 0 && - filterOption && - filterOption.length > 0 && ( - <> -
{ - console.log(event) - setSort( - event.detail.sortingColumn - .sortingField - ) - setSortOrder(!sortOrder) - }} - sortingColumn={sort} - sortingDescending={sortOrder} - renderAriaLive={({ - firstIndex, - lastIndex, - totalItemsCount, - }) => - `Displaying items ${firstIndex} to ${lastIndex} of ${totalItemsCount}` - } - columnDefinitions={[ - { - id: 'id', - header: 'ID', - cell: (item) => item.id, - sortingField: 'id', - isRowHeader: true, - }, - { - id: 'title', - header: 'Title', - cell: (item) => ( - { - navigateToInsightsDetails( - item.id - ) - }} - > - {item.title} - - ), - sortingField: 'title', - // minWidth: 400, - maxWidth: 200, - }, - { - id: 'connector', - header: 'Connector', - cell: (item) => item.connector, - }, - { - id: 'query', - header: 'Primary Table', - cell: (item) => - item?.query?.primary_table, - }, - { - id: 'severity', - header: 'Severity', - sortingField: 'severity', - cell: (item) => ( - - {item.severity - .charAt(0) - .toUpperCase() + - item.severity.slice( - 1 - )} - - ), - maxWidth: 100, - }, - { - id: 'query.parameters', - header: 'Has Parametrs', - cell: (item) => ( - // @ts-ignore - <> - {item.query?.parameters - .length > 0 - ? 'True' - : 'False'} - - ), - }, - { - id: 'incidents', - header: 'Incidents', - sortingField: 'incidents', - - cell: (item) => ( - // @ts-ignore - <> - {/**@ts-ignore */} - {item?.findings_summary - ?.incident_count - ? item - ?.findings_summary - ?.incident_count - : 0} - - ), - // minWidth: 50, - maxWidth: 100, - }, - { - id: 'passing_resources', - header: 'Non Incidents ', - cell: (item) => ( - // @ts-ignore - <> - {item?.findings_summary - ?.non_incident_count - ? item - ?.findings_summary - ?.non_incident_count - : 0} - - ), - maxWidth: 100, - }, - { - id: 'noncompliant_resources', - header: 'Non-Compliant Resources', - sortingField: 'noncompliant_resources', - cell: (item) => ( - // @ts-ignore - <> - {item?.findings_summary - ?.noncompliant_resources - ? item - ?.findings_summary - ?.noncompliant_resources - : 0} - - ), - maxWidth: 100, - }, - { - id: 'waste', - header: 'Waste', - cell: (item) => ( - // @ts-ignore - <> - {item?.findings_summary - ?.cost_optimization - ? item - ?.findings_summary - ?.cost_optimization - : 0} - - ), - maxWidth: 100, - }, - { - id: 'action', - header: 'Action', - cell: (item) => ( - // @ts-ignore - { - navigateToInsightsDetails( - item.id - ) - }} - variant="inline-link" - ariaLabel={`Open Detail`} - > - Open - - ), - }, - ]} - columnDisplay={[ - { id: 'id', visible: false }, - { id: 'title', visible: true }, - { - id: 'connector', - visible: false, - }, - { id: 'query', visible: false }, - { - id: 'severity', - visible: true, - }, - { - id: 'incidents', - visible: false, - }, - { - id: 'passing_resources', - visible: false, - }, - { - id: 'noncompliant_resources', - visible: enable, - }, - { - id: 'waste', - visible: - category == 'Efficiency' && - enable - ? true - : false, - }, - - // { id: 'action', visible: true }, - ]} - enableKeyboardNavigation - items={rows} - loading={loading} - loadingText="Loading resources" - // stickyColumns={{ first: 0, last: 1 }} - // stripedRows - trackBy="id" - empty={ - - - No resources - - - - } - filter={ - { - // @ts-ignore - setQueries(detail) - }} - // countText="5 matches" - enableTokenGroups - expandToViewport - filteringAriaLabel="Control Categories" - // @ts-ignore - // filteringOptions={filters} - filteringPlaceholder="Control Categories" - // @ts-ignore - filteringOptions={filters} - filteringProperties={ - filterOption - } - // filteringProperties={ - // filterOption - // } - /> - } - header={ -
- Controls{' '} - - ({totalCount}) - -
- } - pagination={ - - setPage( - detail.currentPageIndex - ) - } - pagesCount={totalPage} - /> - } - /> - - )} - - - - - ) -} diff --git a/services/web-ui/src/pages/Insights/ScoreCategory/style.css b/services/web-ui/src/pages/Insights/ScoreCategory/style.css deleted file mode 100644 index 67b79e377..000000000 --- a/services/web-ui/src/pages/Insights/ScoreCategory/style.css +++ /dev/null @@ -1,6 +0,0 @@ -.awsui-context-content-header{ - border-radius: 12px!important; -} -.awsui_header-background_5gtk3_1i4vc_163{ - border-radius: 12px!important; -} \ No newline at end of file diff --git a/services/web-ui/src/pages/Insights/ScoreOverview/index.tsx b/services/web-ui/src/pages/Insights/ScoreOverview/index.tsx deleted file mode 100644 index 8a8249ba4..000000000 --- a/services/web-ui/src/pages/Insights/ScoreOverview/index.tsx +++ /dev/null @@ -1,627 +0,0 @@ -// @ts-nocheck -import dayjs from 'dayjs' -import { - Flex, - Text, - Title, - Subtitle, - Metric, - Badge, - ProgressCircle, - Button, - Card, - Grid, -} from '@tremor/react' -import { useSetAtom } from 'jotai' -import { useEffect, useState } from 'react' -import { ArrowPathIcon, DocumentTextIcon } from '@heroicons/react/24/outline' -import { useScheduleApiV1ComplianceTriggerUpdate } from '../../../api/schedule.gen' -import { notificationAtom } from '../../../store' -import ScoreCategoryCard from '../../../components/Cards/ScoreCategoryCard' -import TopHeader from '../../../components/Layout/Header' -import { - GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkEvaluationSummary, - GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkStatusResult, - SourceType, -} from '../../../api/api' -import { useFilterState } from '../../../utilities/urlstate' -import { getErrorMessage, toErrorMessage } from '../../../types/apierror' -import Modal from '../../../components/Modal' -import axios from 'axios' - -const severityColor = [ - { - name: 'critical', - title: 'Critical Risk', - color: 'rose', - }, - { - name: 'high', - title: 'High Risk', - color: 'orange', - }, - { - name: 'medium', - title: 'Medium Risk', - color: 'amber', - }, - { - name: 'low', - title: 'Low Risk', - color: 'yellow', - }, - { - name: 'none', - title: 'None', - color: 'gray', - }, - { - name: 'passed', - title: 'Passed', - color: 'emerald', - }, -] - -function fixSort(t: string) { - return t - .replaceAll('s', 'a') - .replaceAll('S', 'a') - .replaceAll('c', 'b') - .replaceAll('C', 'b') - .replaceAll('o', 'c') - .replaceAll('O', 'c') - .replaceAll('r', 'd') - .replaceAll('R', 'd') - .replaceAll('E', 'e') -} - -interface MR { - category: string - title: string - summary: GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkEvaluationSummary[] -} -const CATEGORY = { - sre_efficiency: 'Efficiency', - sre_reliability: 'Reliability', - sre_supportability: 'Supportability', -} - -export default function ScoreOverview() { - const { value: selectedConnections } = useFilterState() - const setNotification = useSetAtom(notificationAtom) - const [openConfirm, setOpenConfirm] = useState(false) - const [response,setResponse] = useState(); - const [isLoading, setIsLoading] = useState(false) - - - const { - sendNowWithParams: triggerEvaluate, - isExecuted, - error, - isLoading: triggerIsLoading, - } = useScheduleApiV1ComplianceTriggerUpdate( - { - benchmark_id: [], - }, - {}, - false - ) - const GetBenchmarks = (benchmarks: string[]) => { - setIsLoading(true) - let url = '' - if (window.location.origin === 'http://localhost:3000') { - url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL - } else { - url = window.location.origin - } - // @ts-ignore - const token = JSON.parse(localStorage.getItem('openg_auth')).token - - const config = { - headers: { - Authorization: `Bearer ${token}`, - }, - } - const body = { - benchmarks: benchmarks, - } - axios - .post( - `${url}/main/compliance/api/v3/compliance/summary/benchmark`, - body, - config - ) - .then((res) => { - // const temp = [] - setIsLoading(false) - setResponse(res.data) - }) - .catch((err) => { - setIsLoading(false) - - console.log(err) - }) - } - - useEffect(() => { - if (isExecuted && !triggerIsLoading) { - const err = getErrorMessage(error) - if (err === '') { - setNotification({ - text: 'Evaluation triggered', - type: 'success', - position: 'bottomLeft', - }) - } else { - setNotification({ - text: `Evaluation trigger failed due to ${err}`, - type: 'error', - position: 'bottomLeft', - }) - } - } - }, [triggerIsLoading]) - useEffect(() => { - GetBenchmarks([ - 'sre_efficiency', - 'sre_reliability', - 'sre_supportability', - ]) - }, []) - - - return ( - <> - {/* */} - - -
-
-

- SRE Center -

-

- Assess your enterprise against SRE best practices - and the Well-Architected Framework. -

-
- -
- -
-

- - {/* Extend link to entire card */} - - Documentation - -

-

- Learn how to use and customize SRE Framework -

-
-
-
-
-
-
-
-
- {/*

- Available Dashboards -

*/} -
- {/* */} - {/* */} -
-
-
- - {isLoading || !response - ? [1, 2, 3,].map((i) => ( - - - -
- - - - -
- - - )) - : response - .sort((a, b) => { - if ( - a.benchmark_title === - 'SRE Supportability' && - b.benchmark_title === - 'SRE Efficiency' - ) { - return -1 - } - if ( - a.benchmark_title === - 'SRE Efficiency' && - b.benchmark_title === - 'SRE Supportability' - ) { - return 1 - } - if ( - a.benchmark_title === - 'SRE Reliability' && - b.benchmark_title === - 'SRE Efficiency' - ) { - return -1 - } - if ( - a.benchmark_title === - 'SRE Efficiency' && - b.benchmark_title === - 'SRE Reliability' - ) { - return 1 - } - if ( - a.benchmark_title === - 'SRE Supportability' && - b.benchmark_title === - 'SRE Reliability' - ) { - return -1 - } - return 0 - }) - .map((item) => { - return ( - - ) - })} - -
-
-
-
-
- - - setOpenConfirm(false)}> - Do you want to run evaluation on all accounts? - - - - - - - ) -} -{/** - - - - - - - What is SCORE? - - SCORE is a comprehensive evaluation suite that - assesses your infrastructure against leading - cloud vendor recommendations, ensuring optimal - alignment with industry standards and best - practices. - - setOpenConfirm(true)} - > - - - {evaluating ? 'Evaluating' : 'Evaluate Now'} - - - Last Evaluated: {lastEvaluatedAt} - -
- - - - {isLoading ? ( -
- ) : ( - - {securityScore.toFixed(1)}% - - )} - - Compliant - - - - -
- - -
- {isLoading ? ( -
- ) : ( - - {total} - - )} - insight evaluations performed across - - all - - cloud accounts -
- - - - - - {isLoading ? ( -
- ) : ( - total - passed - )} - - - - Failed Checks - - - - - - - - - {isLoading ? ( -
- ) : ( - passed - )} - - - Passed Checks - - - - - - - - {Object.entries(severityMap || {}).map( - (item) => ( - - - v.name === - item[0] - ) - .at(0)?.color - } - className="w-full" - > - {item[1]} - - {item[0]} - - ) - )} - - - - - - - {isLoading - ? [1, 2, 3, 4, 5].map((i) => ( - - - -
- - - - -
- - - )) - : categories().map((item) => { - return ( - - c.controlsSeverityStatus - ?.total || {} - ) - )} - costOptimization={ - item.category === 'cost_optimization' - ? item.summary - .map( - (b) => - b.costOptimization || - 0 - ) - .reduce( - (prev, curr) => - prev + curr, - 0 - ) - : 0 - } - value={item.summary - .map( - (c) => - c.controlsSeverityStatus - ?.total?.passed || 0 - ) - .reduce( - (prev, curr) => prev + curr, - 0 - )} - kpiText="Issues" - category={item.category} - varient="default" - /> - ) - })} - - - */} \ No newline at end of file diff --git a/services/web-ui/src/router/index.tsx b/services/web-ui/src/router/index.tsx index 603ac98a4..fdd7f2348 100644 --- a/services/web-ui/src/router/index.tsx +++ b/services/web-ui/src/router/index.tsx @@ -8,12 +8,10 @@ import Workspaces from '../pages/Workspaces' import Logout from '../pages/Logout' import Integrations from '../pages/Integrations' import Compliance from '../pages/Governance/Compliance' -import BenchmarkSummary from '../pages/Governance/Compliance/BenchmarkSummary' import Overview from '../pages/Overview' import Stack from '../pages/Stack' import Single from '../pages/Assets/Single' import SingleSpend from '../pages/Spend/Single' -import SingleComplianceConnection from '../pages/Governance/Compliance/BenchmarkSummary/SingleConnection' // import Boostrap from '../pages/Workspaces/Bootstrap' import ResourceCollection from '../pages/ResourceCollection' import ResourceCollectionDetail from '../pages/ResourceCollection/Detail' @@ -26,10 +24,6 @@ import Layout from '../components/Layout' import RequestDemo from '../pages/RequestDemo' import AssetAccounts from '../pages/Assets/Account' import AssetMetrics from '../pages/Assets/Metric' -import ScoreOverview from '../pages/Insights/ScoreOverview' -import ScoreCategory from '../pages/Insights/ScoreCategory' -import ScoreDetails from '../pages/Insights/Details' -import SecurityOverview from '../pages/Governance/Overview' import WorkloadOptimizer from '../pages/WorkloadOptimizer' import RequestAccess from '../pages/Integrations/RequestAccess' import SettingsJobs from '../pages/Settings/Jobs' @@ -211,21 +205,7 @@ const authRoutes = [ path: '/dashboard/spend/spend-details/:id/:metric', element: , }, - { - key: 'score', - path: '/score', - element: , - }, - { - key: 'score category', - path: '/score/:category', - element: , - }, - { - key: 'score details', - path: '/score/:category/:id', - element: , - }, + { key: 'integrations', path: '/integrations', @@ -278,11 +258,7 @@ const authRoutes = [ path: '/settings/access', element: , }, - { - key: 'security overview', - path: '/security-overview', - element: , - }, + { key: 'Compliance', path: '/compliance', @@ -314,11 +290,7 @@ const authRoutes = [ path: '/compliance/:benchmarkId/:controlId', element: , }, - { - key: 'benchmark single connection', - path: '/compliance/:benchmarkId/:connectionId', - element: , - }, + { key: 'benchmark single connection', path: '/compliance/:benchmarkId/report/:id', @@ -360,11 +332,7 @@ const authRoutes = [ path: '/incidents/:controlId', element: , }, - { - key: 'service advisor summary', - path: '/service-advisor/:id', - element: , - }, + { key: 'home', path: '/', @@ -400,16 +368,7 @@ const authRoutes = [ path: '/resource-collection/:resourceId', element: , }, - { - key: 'benchmark summary', - path: '/resource-collection/:resourceId/:id', - element: , - }, - { - key: 'benchmark single connection', - path: '/resource-collection/:resourceId/:id/:connection', - element: , - }, + // { // key: 'resource collection assets metrics', // path: '/:ws/resource-collection/:resourceId/assets-details', From c77ef92553ce080625cbf88bd5abe1cebe7a50f5 Mon Sep 17 00:00:00 2001 From: Mohamad Choupan Date: Fri, 3 Jan 2025 19:40:33 +0330 Subject: [PATCH 4/4] feat: remove unused files part4 main files --- services/web-ui/src/api/compliance.gen.ts | 13 - .../SingleConnection/index.tsx | 367 ---------- .../Overview/Governance/Findings/index.tsx | 150 ---- .../src/pages/Overview/Governance/index.tsx | 1 - .../pages/ResourceCollection/Detail/index.tsx | 664 ------------------ .../src/pages/ResourceCollection/index.tsx | 128 ---- services/web-ui/src/router/index.tsx | 13 +- 7 files changed, 1 insertion(+), 1335 deletions(-) delete mode 100644 services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/SingleConnection/index.tsx delete mode 100644 services/web-ui/src/pages/Overview/Governance/Findings/index.tsx delete mode 100644 services/web-ui/src/pages/ResourceCollection/Detail/index.tsx delete mode 100644 services/web-ui/src/pages/ResourceCollection/index.tsx diff --git a/services/web-ui/src/api/compliance.gen.ts b/services/web-ui/src/api/compliance.gen.ts index 26c878f30..58acb1367 100755 --- a/services/web-ui/src/api/compliance.gen.ts +++ b/services/web-ui/src/api/compliance.gen.ts @@ -33,8 +33,6 @@ import { import AxiosAPI, { setWorkspace } from './ApiConfig' - - interface IuseComplianceApiV1AssignmentsBenchmarkDetailState { isLoading: boolean isExecuted: boolean @@ -959,9 +957,6 @@ export const useComplianceApiV1BenchmarksSummaryDetail = ( } } - - - interface IuseComplianceApiV1ControlsSummaryDetailState { isLoading: boolean isExecuted: boolean @@ -1123,8 +1118,6 @@ export const useComplianceApiV1ControlsSummaryDetail = ( } } - - interface IuseComplianceApiV1FindingEventsCreateState { isLoading: boolean isExecuted: boolean @@ -1855,7 +1848,6 @@ export const useComplianceApiV1FindingsCreate = ( } } - interface IuseComplianceApiV1FindingsEventsDetailState { isLoading: boolean isExecuted: boolean @@ -2129,8 +2121,6 @@ export const useComplianceApiV1FindingsFiltersCreate = ( } } - - interface IuseComplianceApiV1FindingsResourceCreateState { isLoading: boolean isExecuted: boolean @@ -2966,8 +2956,6 @@ export const useComplianceApiV1FindingsServicesDetail = ( } } - - interface IuseComplianceApiV1QueriesSyncListState { isLoading: boolean isExecuted: boolean @@ -3262,4 +3250,3 @@ interface IuseInventoryApiV3InvenoryCategoryList { // eslint-disable-next-line @typescript-eslint/no-explicit-any error?: any } - diff --git a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/SingleConnection/index.tsx b/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/SingleConnection/index.tsx deleted file mode 100644 index 2ec79484e..000000000 --- a/services/web-ui/src/pages/Governance/Compliance/NewBenchmarkSummary/SingleConnection/index.tsx +++ /dev/null @@ -1,367 +0,0 @@ -import { - Button, - Card, - Flex, - Grid, - List, - ListItem, - Tab, - TabGroup, - TabList, - TabPanel, - TabPanels, - Text, - Title, -} from '@tremor/react' -import { useParams } from 'react-router-dom' -import clipboardCopy from 'clipboard-copy' -import { ChevronRightIcon, Square2StackIcon } from '@heroicons/react/24/outline' -import { useEffect, useState } from 'react' -import { useAtomValue, useSetAtom } from 'jotai' -import { - IServerSideDatasource, - RowClickedEvent, - SortModelItem, - IServerSideGetRowsParams, -} from 'ag-grid-community' -import { useIntegrationApiV1ConnectionsSummariesList } from '../../../../../api/integration.gen' -import Spinner from '../../../../../components/Spinner' -import { dateTimeDisplay } from '../../../../../utilities/dateDisplay' -import DrawerPanel from '../../../../../components/DrawerPanel' -import { RenderObject } from '../../../../../components/RenderObject' -import { isDemoAtom, notificationAtom } from '../../../../../store' -import { - useComplianceApiV1AssignmentsConnectionDetail, - useComplianceApiV1BenchmarksSummaryDetail, - useComplianceApiV1FindingsCreate, -} from '../../../../../api/compliance.gen' -import Table from '../../../../../components/Table' -import { columns } from '../../../Findings/FindingsWithFailure' -import Breakdown from '../../../../../components/Breakdown' -import FindingDetail from '../../../Findings/FindingsWithFailure/Detail' -import { benchmarkChecks } from '../../../../../components/Cards/ComplianceCard' -import { policyColumns } from '../TopDetails/Controls' -import TopHeader from '../../../../../components/Layout/Header' - -export default function SingleComplianceConnection() { - const [openDrawer, setOpenDrawer] = useState(false) - const { connectionId, resourceId } = useParams() - const setNotification = useSetAtom(notificationAtom) - const isDemo = useAtomValue(isDemoAtom) - const [sortModel, setSortModel] = useState([]) - const [openFinding, setOpenFinding] = useState(false) - const [finding, setFinding] = useState(undefined) - - const query = { - ...(connectionId && { - connectionId: [connectionId.replace('account_', '')], - }), - ...(resourceId && { - resourceCollection: [resourceId], - }), - } - const { response: accountInfo, isLoading: accountInfoLoading } = - useIntegrationApiV1ConnectionsSummariesList({ - ...query, - pageSize: 1, - needCost: false, - }) - const con = accountInfo?.connections?.at(0) - - const { response: benchmarkList } = - useComplianceApiV1AssignmentsConnectionDetail( - connectionId?.replace('account_', '') || '' - ) - const [benchmark, setBenchmark] = useState( - benchmarkList?.filter((bm) => bm.status)[0].benchmarkId?.id - ) - const { - response: benchmarkDetail, - isLoading: detailLoading, - sendNow: updateDetail, - } = useComplianceApiV1BenchmarksSummaryDetail( - benchmark || '', - { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - connectionID: [connection?.replace('account_', '') || ''], - }, - {}, - false - ) - - const { - response: findings, - isLoading, - sendNowWithParams: updateFindings, - } = useComplianceApiV1FindingsCreate({ - filters: { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - connectionID: [connection?.replace('account_', '') || ''], - }, - sort: sortModel.length - ? [{ [sortModel[0].colId]: sortModel[0].sort }] - : [], - }) - - useEffect(() => { - if (benchmark) { - updateDetail() - } - }, [benchmark]) - - const getData = (sort: SortModelItem[]) => { - setSortModel(sort) - updateFindings( - { - filters: { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - connectionID: [connection?.replace('account_', '') || ''], - }, - sort: sort.length ? [{ [sort[0].colId]: sort[0].sort }] : [], - }, - {} - ) - } - - const datasource: IServerSideDatasource = { - getRows: (params: IServerSideGetRowsParams) => { - if (params.request.sortModel.length > 0) { - if (sortModel.length > 0) { - if ( - params.request.sortModel[0].colId !== - sortModel[0].colId || - params.request.sortModel[0].sort !== sortModel[0].sort - ) { - getData([params.request.sortModel[0]]) - } - } else { - getData([params.request.sortModel[0]]) - } - } else if (sortModel.length > 0) { - getData([]) - } - if (findings) { - params.success({ - rowData: findings?.findings || [], - rowCount: findings?.totalCount || 0, - }) - } else { - params.fail() - } - }, - } - - return ( - <> - - - - - - - Connection details - - {accountInfoLoading ? ( - - ) : ( - - - Cloud Provider - - {con?.connector} - - - - Discovered name - - - - setOpenDrawer(false)} - > - - - - - - - - - {/* eslint-disable-next-line react/jsx-no-useless-fragment */} - <> - {benchmarkList - ?.filter((bm) => bm.status) - ?.map((bm) => ( - - setBenchmark(bm.benchmarkId?.id || '') - } - > - {bm.benchmarkId?.title} - - ))} - Findings - - - - {benchmarkList - ?.filter((bm) => bm.status) - ?.map((bm) => ( - -
{ - if (detailLoading) { - e.api.showLoadingOverlay() - } - }} - columns={policyColumns} - // rowData={policies} - /> - - ))} - -
{ - setFinding(event.data) - setOpenFinding(true) - }} - onGridReady={(e) => { - if (isLoading) { - e.api.showLoadingOverlay() - } - }} - serverSideDatasource={datasource} - loading={isLoading} - /> - - - - setOpenFinding(false)} - onRefresh={() => window.location.reload()} - /> - - ) -} diff --git a/services/web-ui/src/pages/Overview/Governance/Findings/index.tsx b/services/web-ui/src/pages/Overview/Governance/Findings/index.tsx deleted file mode 100644 index 34232c0f8..000000000 --- a/services/web-ui/src/pages/Overview/Governance/Findings/index.tsx +++ /dev/null @@ -1,150 +0,0 @@ -import { Button, Divider, Flex, Text, Title } from '@tremor/react' -import { ChevronRightIcon } from '@heroicons/react/20/solid' -import { useNavigate, useParams } from 'react-router-dom' -import { useAtomValue } from 'jotai' -import { useComplianceApiV1ControlsSummaryList } from '../../../../api/compliance.gen' -import { TypesFindingSeverity } from '../../../../api/api' -import { severityBadge } from '../../../Governance/Controls' -import { getErrorMessage } from '../../../../types/apierror' -import { searchAtom } from '../../../../utilities/urlstate' - -export default function Findings() { - const workspace = useParams<{ ws: string }>().ws - const navigate = useNavigate() - const searchParams = useAtomValue(searchAtom) - const { - response, - isLoading, - error, - sendNow: refresh, - } = useComplianceApiV1ControlsSummaryList() - - const critical = Array.isArray(response) - ? response?.filter( - (item) => - item.control?.severity === - TypesFindingSeverity.FindingSeverityCritical && - item.passed === false - ) || [] - : [] - - const high = Array.isArray(response) - ? response?.filter( - (item) => - item.control?.severity === - TypesFindingSeverity.FindingSeverityHigh && - item.passed === false - ) || [] - : [] - - const medium = Array.isArray(response) - ? response?.filter( - (item) => - item.control?.severity === - TypesFindingSeverity.FindingSeverityMedium && - item.passed === false - ) || [] - : [] - - const controls = critical.concat(high).concat(medium).slice(0, 3) - - return ( - <> - - Problematic Controls - - - - {isLoading || getErrorMessage(error).length > 0 - ? [1, 2, 3].map((i, idx, arr) => { - return ( - <> - -
- -
-
- - - {idx + 1 < arr.length && ( - - )} - - ) - }) - : controls.map((item, idx, arr) => { - return ( - <> - - navigate( - `/incidents/${item.control?.id}?${searchParams}` - ) - } - > - - - {item.control?.title} - - - # of failed resources:{' '} - {item.failedResourcesCount} - - - {severityBadge(item.control?.severity)} - - {idx + 1 < arr.length && ( - - )} - - ) - })} - - {error && ( - - - Failed to load component - {getErrorMessage(error)} - - - - )} - - ) -} diff --git a/services/web-ui/src/pages/Overview/Governance/index.tsx b/services/web-ui/src/pages/Overview/Governance/index.tsx index 3819c39e8..b3b76ffd5 100644 --- a/services/web-ui/src/pages/Overview/Governance/index.tsx +++ b/services/web-ui/src/pages/Overview/Governance/index.tsx @@ -1,7 +1,6 @@ import { Button, Card, CategoryBar, Col, Flex, Grid, Icon, Title } from '@tremor/react' import { ChevronRightIcon, ShieldCheckIcon } from '@heroicons/react/24/outline' import Compliance from './Compliance' -import Findings from './Findings' import { useNavigate, useParams } from 'react-router-dom' export default function Governance() { diff --git a/services/web-ui/src/pages/ResourceCollection/Detail/index.tsx b/services/web-ui/src/pages/ResourceCollection/Detail/index.tsx deleted file mode 100644 index a7eaadab7..000000000 --- a/services/web-ui/src/pages/ResourceCollection/Detail/index.tsx +++ /dev/null @@ -1,664 +0,0 @@ -import { useNavigate, useParams, useSearchParams } from 'react-router-dom' -import { - Badge, - BarList, - Button, - Callout, - Card, - Col, - Flex, - Grid, - List, - ListItem, - Select, - Tab, - TabGroup, - TabList, - TabPanel, - TabPanels, - Text, - Title, -} from '@tremor/react' -import { useAtomValue } from 'jotai' -import { useEffect, useMemo, useState } from 'react' -import { - ChevronDownIcon, - ChevronRightIcon, - ChevronUpIcon, -} from '@heroicons/react/24/outline' -import { ICellRendererParams } from 'ag-grid-community' -import { - useInventoryApiV2AnalyticsTrendList, - useInventoryApiV2ResourceCollectionDetail, - useInventoryApiV2ResourceCollectionLandscapeDetail, -} from '../../../api/inventory.gen' -import Spinner from '../../../components/Spinner' -import { - useComplianceApiV1AssignmentsResourceCollectionDetail, - useComplianceApiV1BenchmarksSummaryList, -} from '../../../api/compliance.gen' -import { - GithubComKaytuIoKaytuEnginePkgComplianceApiAssignedBenchmark, - GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkEvaluationSummary, - GithubComKaytuIoKaytuEngineServicesIntegrationApiEntityListConnectionsSummaryResponse, -} from '../../../api/api' -import Chart from '../../../components/Chart' -import { - camelCaseToLabel, - capitalizeFirstLetter, -} from '../../../utilities/labelMaker' -import { dateDisplay, dateTimeDisplay } from '../../../utilities/dateDisplay' -import Table, { IColumn } from '../../../components/Table' -import { - checkGranularity, - generateItems, -} from '../../../utilities/dateComparator' -import SummaryCard from '../../../components/Cards/SummaryCard' -import { numberDisplay } from '../../../utilities/numericDisplay' -import { BarChartIcon, LineChartIcon } from '../../../icons/icons' -import { generateVisualMap, resourceTrendChart } from '../../Assets' -import { useIntegrationApiV1ConnectionsSummariesList } from '../../../api/integration.gen' -import Landscape from '../../../components/Landscape' -import Tag from '../../../components/Tag' -import DrawerPanel from '../../../components/DrawerPanel' -import { getConnectorIcon } from '../../../components/Cards/ConnectorCard' -import { benchmarkChecks } from '../../../components/Cards/ComplianceCard' -import TopHeader from '../../../components/Layout/Header' -import { options } from '../../Assets/Metric/Table' -import { - defaultTime, - searchAtom, - useUrlDateRangeState, -} from '../../../utilities/urlstate' - -// const pieData = ( -// input: -// | GithubComKaytuIoKaytuEnginePkgComplianceApiGetBenchmarksSummaryResponse -// | undefined -// ) => { -// const data: any[] = [] -// if (input && input.totalChecks) { -// // eslint-disable-next-line array-callback-return -// Object.entries(input.totalChecks).map(([key, value]) => { -// data.push({ name: camelCaseToLabel(key), value }) -// }) -// } -// return data.reverse() -// } - -const barData = ( - input: - | GithubComKaytuIoKaytuEngineServicesIntegrationApiEntityListConnectionsSummaryResponse - | undefined -) => { - const data: any[] = [] - if (input && input.connections) { - // eslint-disable-next-line array-callback-return - input.connections.map((c, i) => { - if (i < 5) { - data.push({ - name: c.providerConnectionName, - value: c.resourceCount || 0, - }) - } - }) - } - return data -} - -const complianceColumns: IColumn[] = [ - { - width: 140, - field: 'connectors', - headerName: 'Cloud provider', - sortable: true, - filter: true, - enableRowGroup: true, - type: 'string', - }, - { - field: 'title', - headerName: 'Benchmark title', - sortable: true, - filter: true, - enableRowGroup: true, - type: 'string', - cellRenderer: ( - param: ICellRendererParams< - | GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkEvaluationSummary - | undefined - > - ) => - param.value && ( - - {param.value} - - {param.data?.tags?.category?.map((cat) => ( - - {cat} - - ))} - {param.data?.tags?.kaytu_category?.map((cat) => ( - - {cat} - - ))} - {!!param.data?.tags?.cis && ( - - CIS - - )} - {!!param.data?.tags?.hipaa && ( - - Hipaa - - )} - - - ), - }, - { - headerName: 'Security score', - width: 150, - sortable: true, - filter: true, - enableRowGroup: true, - type: 'number', - cellRenderer: ( - param: ICellRendererParams< - | GithubComKaytuIoKaytuEnginePkgComplianceApiBenchmarkEvaluationSummary - | undefined - > - ) => - param.data && - `${( - ((param.data?.conformanceStatusSummary?.passed || 0) / - (benchmarkChecks(param.data).total || 1)) * - 100 - ).toFixed(2)} %`, - }, - { - width: 120, - field: 'status', - headerName: 'Status', - sortable: true, - filter: true, - enableRowGroup: true, - rowGroup: true, - type: 'string', - }, -] - -// const bmList = ( -// assignmentList: -// | GithubComKaytuIoKaytuEnginePkgComplianceApiAssignedBenchmark[] -// | undefined, -// summaryList: -// | GithubComKaytuIoKaytuEnginePkgComplianceApiGetBenchmarksSummaryResponse -// | undefined -// ) => { -// const rows = [] -// if (assignmentList && summaryList) { -// for (let i = 0; i < assignmentList.length; i += 1) { -// const benchmark = summaryList.benchmarkSummary?.find( -// (bm) => bm.id === assignmentList[i].benchmarkId?.id -// ) -// if (assignmentList[i].status) { -// rows.push({ -// ...assignmentList[i].benchmarkId, -// ...benchmark, -// status: 'Assigned', -// }) -// } else { -// rows.push({ -// ...assignmentList[i].benchmarkId, -// ...benchmark, -// status: 'Not assigned', -// }) -// } -// } -// } -// return rows -// } - -export default function ResourceCollectionDetail() { - const { ws } = useParams() - const { resourceId } = useParams() - const { value: activeTimeRange } = useUrlDateRangeState( - defaultTime(ws || '') - ) - const navigate = useNavigate() - const searchParams = useAtomValue(searchAtom) - const [openDrawer, setOpenDrawer] = useState(false) - const [showSummary, setShowSummary] = useState(false) - - const [selectedChart, setSelectedChart] = useState<'line' | 'bar'>('line') - const [selectedIndex, setSelectedIndex] = useState(0) - const [selectedGranularity, setSelectedGranularity] = useState< - 'monthly' | 'daily' | 'yearly' - >( - checkGranularity(activeTimeRange.start, activeTimeRange.end).daily - ? 'daily' - : 'monthly' - ) - useEffect(() => { - setSelectedGranularity( - checkGranularity(activeTimeRange.start, activeTimeRange.end).monthly - ? 'monthly' - : 'daily' - ) - }, [activeTimeRange]) - const [selectedDatapoint, setSelectedDatapoint] = useState(undefined) - - useEffect(() => { - if (selectedIndex === 0) setSelectedChart('line') - if (selectedIndex === 1) setSelectedChart('bar') - }, [selectedIndex]) - - const query = { - resourceCollection: [resourceId || ''], - startTime: activeTimeRange.start.unix(), - endTime: activeTimeRange.end.unix(), - } - - const { response: detail, isLoading: detailsLoading } = - useInventoryApiV2ResourceCollectionDetail(resourceId || '') - const { response: complianceKPI, isLoading: complianceKPILoading } = - useComplianceApiV1BenchmarksSummaryList({ - resourceCollection: [resourceId || ''], - }) - const { response } = useComplianceApiV1AssignmentsResourceCollectionDetail( - resourceId || '' - ) - const { response: accountInfo, isLoading: accountInfoLoading } = - useIntegrationApiV1ConnectionsSummariesList({ - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - ...query, - needCost: false, - sortBy: 'resource_count', - }) - const { response: resourceTrend, isLoading: resourceTrendLoading } = - useInventoryApiV2AnalyticsTrendList({ - ...query, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - granularity: selectedGranularity, - }) - const { response: landscape, isLoading: landscapeLoading } = - useInventoryApiV2ResourceCollectionLandscapeDetail(resourceId || '') - - // const rows = useMemo(() => bmList(response, complianceKPI), [response]) - - return ( - <> - - - - {detail?.name} - {detail?.description} - - - - {showSummary && ( - - - - {detailsLoading ? ( - - ) : ( - - - Connector - - {getConnectorIcon( - detail?.connectors - )} - - - - Resources - - {numberDisplay( - detail?.resource_count, - 0 - )} - - - - Services used - - {detail?.metric_count} - - - - Status - - {capitalizeFirstLetter( - detail?.status || '' - )} - - - - Last evaluation - - {dateTimeDisplay( - detail?.last_evaluated_at - )} - - - - Tags - - {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */} - {/* @ts-ignore */} - {Object.entries(detail?.tags).map( - ([name, value]) => ( - - ) - )} - - - - )} - - - - setOpenDrawer(false)} - > - - - Connector - - {getConnectorIcon( - detail?.connectors - )} - - - - Resources - - {numberDisplay( - detail?.resource_count, - 0 - )} - - - - Services used - - {detail?.metric_count} - - - - Status - - {capitalizeFirstLetter( - detail?.status || '' - )} - - - - Date created - - {dateTimeDisplay( - detail?.created_at - )} - - - - Last evaluation - - {dateTimeDisplay( - detail?.last_evaluated_at - )} - - - - Tags - - {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */} - {/* @ts-ignore */} - {Object.entries(detail?.tags).map( - ([name, value]) => ( - - ) - )} - - - - - - - - - - KPI - - Compliance - Infrastructure - - - - - {/* */} - - - - Top accounts - - - - - - - - )} - - - Landscape - Compliance - Infrastructure - - - - - - - {/*
{ - if (event.data) { - if (event.data.status === 'Assigned') { - navigate( - `${event.data.id}?${searchParams}` - ) - } else { - navigate( - `${event.data.id}/details#assignments?${searchParams}` - ) - } - } - }} - options={options} - /> */} - - - - - - - - - - - {generateItems( - activeTimeRange.start, - activeTimeRange.end, - capitalizeFirstLetter( - selectedGranularity - ), - selectedGranularity, - (v) => { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - setSelectedGranularity(v) - } - )} - - - - - - - - - - - - - - {resourceTrend - ?.filter( - (t) => - selectedDatapoint?.color === - '#E01D48' && - dateDisplay(t.date) === - selectedDatapoint?.name - ) - .map((t) => ( - - Checked{' '} - {numberDisplay( - t.totalSuccessfulDescribedConnectionCount, - 0 - )}{' '} - accounts out of{' '} - {numberDisplay( - t.totalConnectionCount, - 0 - )}{' '} - on {dateDisplay(t.date)} - - ))} - -
- Resources - - setSelectedDatapoint(p)} - /> - - - - - - ) -} diff --git a/services/web-ui/src/pages/ResourceCollection/index.tsx b/services/web-ui/src/pages/ResourceCollection/index.tsx deleted file mode 100644 index aa5e88d59..000000000 --- a/services/web-ui/src/pages/ResourceCollection/index.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import { Flex, TextInput } from '@tremor/react' -import { MagnifyingGlassIcon } from '@heroicons/react/24/outline' -import { useNavigate, useSearchParams } from 'react-router-dom' -import { useState } from 'react' -import { ICellRendererParams } from 'ag-grid-community' -import { useAtomValue } from 'jotai' -import Table, { IColumn } from '../../components/Table' -import { useInventoryApiV2ResourceCollectionList } from '../../api/inventory.gen' -import { GithubComKaytuIoKaytuEnginePkgComplianceApiControlSummary } from '../../api/api' -import Tag from '../../components/Tag' -import TopHeader from '../../components/Layout/Header' -import { searchAtom } from '../../utilities/urlstate' - -const resourceCollectionColumns: IColumn[] = [ - { - field: 'name', - headerName: 'Resource name', - type: 'string', - sortable: true, - filter: true, - resizable: true, - flex: 1, - }, - { - field: 'status', - headerName: 'Status', - type: 'string', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - }, - { - field: 'resource_count', - headerName: 'Resource count', - type: 'number', - sortable: true, - filter: true, - resizable: true, - flex: 0.5, - }, - { - field: 'tags', - headerName: 'Tags', - type: 'string', - sortable: true, - filter: true, - resizable: true, - flex: 1.5, - cellRenderer: ( - params: ICellRendererParams - ) => ( - - {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */} - {/* @ts-ignore */} - {Object.entries(params.value).map(([name, value]) => ( - - ))} - - ), - }, - { - field: 'created_at', - headerName: 'Creation date', - type: 'datetime', - sortable: true, - filter: true, - resizable: true, - flex: 1, - }, -] - -export default function ResourceCollection() { - const navigate = useNavigate() - const searchParams = useAtomValue(searchAtom) - const [search, setSearch] = useState('') - - const { response, isLoading } = useInventoryApiV2ResourceCollectionList() - - return ( - <> - -
- r.name - ?.toLowerCase() - .includes(search.toLowerCase()) - ) - .sort( - (a, b) => - (b.resource_count || 0) - - (a.resource_count || 0) - ) - : response?.sort( - (a, b) => - (b.resource_count || 0) - - (a.resource_count || 0) - ) - } - loading={isLoading} - onRowClicked={(e) => navigate(`${e.data.id}?${searchParams}`)} - fullWidth - > - - setSearch(e.target.value)} - icon={MagnifyingGlassIcon} - placeholder="Search resources..." - /> - {/* */} - -
- - ) -} diff --git a/services/web-ui/src/router/index.tsx b/services/web-ui/src/router/index.tsx index fdd7f2348..b36bb6527 100644 --- a/services/web-ui/src/router/index.tsx +++ b/services/web-ui/src/router/index.tsx @@ -13,8 +13,6 @@ import Stack from '../pages/Stack' import Single from '../pages/Assets/Single' import SingleSpend from '../pages/Spend/Single' // import Boostrap from '../pages/Workspaces/Bootstrap' -import ResourceCollection from '../pages/ResourceCollection' -import ResourceCollectionDetail from '../pages/ResourceCollection/Detail' import ControlDetail from '../pages/Governance/Controls/ControlSummary' import Findings from '../pages/Governance/Findings' import { SpendOverview } from '../pages/Spend/Overview' @@ -358,16 +356,7 @@ const authRoutes = [ // path: '/ws/new-ws', // element: , // }, - { - key: 'resource collection', - path: '/resource-collection', - element: , - }, - { - key: 'resource collection detail', - path: '/resource-collection/:resourceId', - element: , - }, + // { // key: 'resource collection assets metrics',