From 0704744318fca7e5b7a012d0ca6bf2e58d0050ce Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Mon, 12 Aug 2024 14:47:00 +0530 Subject: [PATCH 1/6] use the correct branch --- .github/workflows/prettier.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prettier.yaml b/.github/workflows/prettier.yaml index f9c9bbf8..6c5ca128 100644 --- a/.github/workflows/prettier.yaml +++ b/.github/workflows/prettier.yaml @@ -13,7 +13,7 @@ jobs: uses: actions/checkout@v3 with: # Make sure the actual branch is checked out when running on pull requests - ref: ${{ github.head_ref }} + ref: ${{ github.ref_name }} - name: Prettify code uses: creyD/prettier_action@v4.3 From 250a113a241db80457a724d685e3b380d0ffd9e6 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Mon, 12 Aug 2024 14:53:59 +0530 Subject: [PATCH 2/6] update --- .github/workflows/prettier.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/prettier.yaml b/.github/workflows/prettier.yaml index 6c5ca128..90b3b296 100644 --- a/.github/workflows/prettier.yaml +++ b/.github/workflows/prettier.yaml @@ -7,16 +7,12 @@ on: jobs: prettier: runs-on: ubuntu-latest - + environment: + name: ${{ github.ref_name }} steps: - name: Checkout uses: actions/checkout@v3 - with: - # Make sure the actual branch is checked out when running on pull requests - ref: ${{ github.ref_name }} - - name: Prettify code uses: creyD/prettier_action@v4.3 with: - # This part is also where you can pass other options, for example: prettier_options: --write **/*.{js,md} From efd0d020b9c2cf9021926ac8746cd6dd379838aa Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Mon, 12 Aug 2024 14:57:36 +0530 Subject: [PATCH 3/6] update --- .github/workflows/prettier.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prettier.yaml b/.github/workflows/prettier.yaml index 90b3b296..f3c04a38 100644 --- a/.github/workflows/prettier.yaml +++ b/.github/workflows/prettier.yaml @@ -15,4 +15,4 @@ jobs: - name: Prettify code uses: creyD/prettier_action@v4.3 with: - prettier_options: --write **/*.{js,md} + prettier_options: --write **/*.{ts,tsx,js,json} From 3c4b4c5c4bbd03aa653c6dd1aab42787c1c65614 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Mon, 12 Aug 2024 15:06:07 +0530 Subject: [PATCH 4/6] update --- .github/workflows/prettier.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prettier.yaml b/.github/workflows/prettier.yaml index f3c04a38..1f491384 100644 --- a/.github/workflows/prettier.yaml +++ b/.github/workflows/prettier.yaml @@ -7,11 +7,13 @@ on: jobs: prettier: runs-on: ubuntu-latest - environment: - name: ${{ github.ref_name }} + steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.ref_name }} - name: Prettify code uses: creyD/prettier_action@v4.3 with: From 8bd84124705b47f4435315d2a67d01fd227e0391 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Mon, 12 Aug 2024 15:09:32 +0530 Subject: [PATCH 5/6] update --- .github/workflows/prettier.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/prettier.yaml b/.github/workflows/prettier.yaml index 1f491384..d03f187b 100644 --- a/.github/workflows/prettier.yaml +++ b/.github/workflows/prettier.yaml @@ -1,6 +1,5 @@ name: Continuous Integration -# This action works with pull requests and pushes on: pull_request @@ -10,10 +9,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - fetch-depth: 0 - ref: ${{ github.ref_name }} + ref: ${{ github.head_ref }} - name: Prettify code uses: creyD/prettier_action@v4.3 with: From b197cb3dadd4194a5a3a1dcb5f535a06fa2e794d Mon Sep 17 00:00:00 2001 From: nitisht Date: Mon, 12 Aug 2024 09:47:55 +0000 Subject: [PATCH 6/6] Prettified Code! --- src/@types/parseable/api/about.ts | 4 +- src/@types/parseable/api/clusterInfo.ts | 2 +- src/@types/parseable/api/query.ts | 14 +-- src/@types/parseable/api/savedFilters.ts | 46 +++++----- src/@types/parseable/api/stream.ts | 26 +++--- src/api/about.ts | 11 ++- src/api/auth.ts | 3 +- src/api/cluster.ts | 2 +- src/api/llm.ts | 1 - src/api/logStream.ts | 6 +- src/assets/arrow.ts | 12 +-- src/assets/google/protobuf/timestamp.ts | 12 +-- src/components/Button/Retry.tsx | 7 +- src/components/Button/ToggleButton.tsx | 8 +- src/components/Empty/index.tsx | 2 +- src/components/Header/Dropdown.tsx | 4 +- src/components/Header/HelpModal.tsx | 14 ++- src/components/Header/RefreshInterval.tsx | 4 +- src/components/Header/ReloadUser.tsx | 10 +-- src/components/Header/StreamDropdown.tsx | 29 ++++--- src/components/Header/StreamingButton.tsx | 2 +- src/components/Header/UserDocs.tsx | 22 ++--- src/components/Header/index.tsx | 6 +- src/components/Misc/CreatableSelect.tsx | 17 ++-- src/components/Navbar/UserModal.tsx | 6 +- src/components/Navbar/index.tsx | 8 +- src/components/Navbar/infoModal.tsx | 4 +- src/components/Navbar/rolesHandler.ts | 4 +- src/constants/routes.ts | 4 +- src/constants/theme.ts | 2 +- src/constants/timeConstants.ts | 12 +-- src/hooks/useCacheToggle.tsx | 12 +-- src/hooks/useCurrentRoute.ts | 8 +- src/hooks/useGetStreamInfo.tsx | 4 +- src/hooks/useLoginForm.ts | 2 +- src/hooks/useRetentionEditor.tsx | 2 +- src/hooks/useRole.tsx | 4 +- src/hooks/useUser.tsx | 2 +- src/jq-web.d.ts | 2 +- src/main.tsx | 18 ++-- src/pages/AccessManagement/PrivilegeTR.tsx | 6 +- src/pages/AccessManagement/RoleTR.tsx | 2 +- src/pages/AccessManagement/Roles.tsx | 12 ++- src/pages/AccessManagement/Users.tsx | 26 +++--- src/pages/Errors/Bug.tsx | 2 +- src/pages/Errors/NotFound.tsx | 2 +- src/pages/Errors/OIDC.tsx | 2 +- src/pages/Login/index.tsx | 5 +- src/pages/Stream/Views/Explore/Footer.tsx | 33 ++++--- .../Stream/Views/Explore/LoadingViews.tsx | 12 +-- .../Stream/Views/Explore/StaticLogTable.tsx | 6 +- .../Stream/Views/Explore/useLogsFetcher.ts | 4 +- .../Stream/Views/LiveTail/LiveLogRow.tsx | 2 +- src/pages/Stream/Views/Manage/Alerts.tsx | 87 ++++++++++++------- src/pages/Stream/Views/Manage/Info.tsx | 2 +- src/pages/Stream/Views/Manage/Management.tsx | 7 +- src/pages/Stream/Views/Manage/Stats.tsx | 2 +- src/pages/Stream/components/Column.tsx | 6 +- .../Stream/components/PrimaryToolbar.tsx | 14 ++- .../components/Querier/FilterQueryBuilder.tsx | 2 +- .../components/Querier/QueryCodeEditor.tsx | 15 ++-- .../Stream/components/Querier/QueryEditor.tsx | 2 +- .../components/Querier/SaveFilterModal.tsx | 2 +- .../components/Querier/SavedFiltersModal.tsx | 5 +- src/pages/Stream/components/Querier/index.tsx | 2 +- src/pages/Stream/index.tsx | 2 +- src/pages/Stream/providers/FilterProvider.tsx | 22 ++--- src/pages/Stream/providers/LogsProvider.tsx | 13 +-- src/pages/Stream/providers/StreamProvider.tsx | 28 +++--- src/pages/Stream/utils.ts | 19 ++-- src/pages/Systems/index.tsx | 4 +- src/pages/Systems/utils.ts | 15 ++-- src/routes/AccessSpecificRoute.tsx | 2 +- src/routes/index.tsx | 2 +- src/utils/formatBytes.ts | 6 +- src/utils/initContext.tsx | 4 +- src/utils/notification.ts | 12 +-- src/utils/sanitiseSqlString.ts | 34 ++++---- 78 files changed, 422 insertions(+), 359 deletions(-) diff --git a/src/@types/parseable/api/about.ts b/src/@types/parseable/api/about.ts index 3f3adffe..8db499d7 100644 --- a/src/@types/parseable/api/about.ts +++ b/src/@types/parseable/api/about.ts @@ -15,6 +15,6 @@ export type AboutData = { oidcActive: boolean; cache: string; analytics: { - clarityTag: string; - } + clarityTag: string; + }; }; diff --git a/src/@types/parseable/api/clusterInfo.ts b/src/@types/parseable/api/clusterInfo.ts index 8710ccf9..e45f4935 100644 --- a/src/@types/parseable/api/clusterInfo.ts +++ b/src/@types/parseable/api/clusterInfo.ts @@ -41,4 +41,4 @@ export type IngestorQueryRecord = { parseable_lifetime_storage_size_staging: number; parseable_deleted_storage_size_data: number; parseable_deleted_storage_size_staging: number; -}; \ No newline at end of file +}; diff --git a/src/@types/parseable/api/query.ts b/src/@types/parseable/api/query.ts index 8e31e20d..0867f592 100644 --- a/src/@types/parseable/api/query.ts +++ b/src/@types/parseable/api/query.ts @@ -2,21 +2,21 @@ export type LogsQuery = { streamName: string; startTime: Date; endTime: Date; - access:string[]|null; + access: string[] | null; }; export enum SortOrder { ASCENDING = 1, - DESCENDING = -1 + DESCENDING = -1, } export type LogsSearch = { search: string; filters: Record; sort: { - key: string, - order: SortOrder - } + key: string; + order: SortOrder; + }; }; export type LogsData = { @@ -35,8 +35,8 @@ export type Log = { }; export type LogSelectedTimeRange = { - state : "fixed"| "custom"; - value : string; + state: 'fixed' | 'custom'; + value: string; }; export type UserRoles = { diff --git a/src/@types/parseable/api/savedFilters.ts b/src/@types/parseable/api/savedFilters.ts index d45dd3c8..6f6e5e73 100644 --- a/src/@types/parseable/api/savedFilters.ts +++ b/src/@types/parseable/api/savedFilters.ts @@ -1,32 +1,32 @@ -import { QueryType } from "@/pages/Stream/providers/FilterProvider"; +import { QueryType } from '@/pages/Stream/providers/FilterProvider'; export type SavedFilterType = { version: string; stream_name: string; - filter_name: string, - filter_id: string, - user_id: string; + filter_name: string; + filter_id: string; + user_id: string; query: { - filter_type: 'sql' | 'builder'; - filter_query?: string; - filter_builder?: QueryType - } - time_filter: null | { - from: string, - to: string - } -} + filter_type: 'sql' | 'builder'; + filter_query?: string; + filter_builder?: QueryType; + }; + time_filter: null | { + from: string; + to: string; + }; +}; export type CreateSavedFilterType = { stream_name: string; - filter_name: string; + filter_name: string; query: { - filter_type: 'sql' | 'builder'; - filter_query?: string; - filter_builder?: QueryType - } - time_filter: null | { - from: string, - to: string - } -} + filter_type: 'sql' | 'builder'; + filter_query?: string; + filter_builder?: QueryType; + }; + time_filter: null | { + from: string; + to: string; + }; +}; diff --git a/src/@types/parseable/api/stream.ts b/src/@types/parseable/api/stream.ts index be769182..81da5198 100644 --- a/src/@types/parseable/api/stream.ts +++ b/src/@types/parseable/api/stream.ts @@ -34,24 +34,26 @@ export type action = { }; export type StreamInfo = { - "created-at": string; - "first-event-at": string; + 'created-at': string; + 'first-event-at': string; cache_enabled: boolean; time_partition: string; static_schema_flag: boolean; - time_partition_limit: string, - custom_partition: string, -} + time_partition_limit: string; + custom_partition: string; +}; export type LogStreamRetention = Array; -export type HotTierConfig = { - size: string; - used_size: string; - available_size: string; - oldest_date_time_entry: string; -} | {}; +export type HotTierConfig = + | { + size: string; + used_size: string; + available_size: string; + oldest_date_time_entry: string; + } + | {}; export type UpdateHotTierConfig = { size: string; -} \ No newline at end of file +}; diff --git a/src/api/about.ts b/src/api/about.ts index 8fcb1258..cf106b6e 100644 --- a/src/api/about.ts +++ b/src/api/about.ts @@ -1,8 +1,7 @@ - -import { AboutData } from "@/@types/parseable/api/about"; -import { Axios } from "./axios"; -import { ABOUT_URL } from "./constants"; +import { AboutData } from '@/@types/parseable/api/about'; +import { Axios } from './axios'; +import { ABOUT_URL } from './constants'; export const getCurrentAbout = () => { - return Axios().get(ABOUT_URL); -} \ No newline at end of file + return Axios().get(ABOUT_URL); +}; diff --git a/src/api/auth.ts b/src/api/auth.ts index 367c7d4c..c5a60f59 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -1,6 +1,5 @@ import { Axios } from './axios'; -import { LOGIN_URL } from './constants'; - +import { LOGIN_URL } from './constants'; export const loginIn = (username: string, password: string) => { const credentials = btoa(`${username}:${password}`); diff --git a/src/api/cluster.ts b/src/api/cluster.ts index 146675dc..dfac2d6d 100644 --- a/src/api/cluster.ts +++ b/src/api/cluster.ts @@ -26,4 +26,4 @@ export const getClusterMetrics = () => { export const deleteIngestor = (ingestorUrl: string) => { return Axios().delete(INGESTOR_DELETE_URL(ingestorUrl)); -}; \ No newline at end of file +}; diff --git a/src/api/llm.ts b/src/api/llm.ts index 6c209113..4b232acf 100644 --- a/src/api/llm.ts +++ b/src/api/llm.ts @@ -1,7 +1,6 @@ import { Axios } from './axios'; import { LLM_QUERY_URL } from './constants'; - // LLM export const postLLM = (prompt: string, stream: string) => { return Axios().post(LLM_QUERY_URL, { diff --git a/src/api/logStream.ts b/src/api/logStream.ts index 708ab689..4b320daf 100644 --- a/src/api/logStream.ts +++ b/src/api/logStream.ts @@ -13,7 +13,7 @@ import { UPDATE_SAVED_FILTERS_URL, DELETE_SAVED_FILTERS_URL, CREATE_SAVED_FILTERS_URL, - LOG_STREAM_HOT_TIER + LOG_STREAM_HOT_TIER, } from './constants'; import { HotTierConfig, LogStreamData, LogStreamSchemaData } from '@/@types/parseable/api/stream'; @@ -79,7 +79,7 @@ export const getLogStreamInfo = (streamName: string) => { export const getHotTierInfo = (streamName: string) => { return Axios().get(LOG_STREAM_HOT_TIER(streamName)); -} +}; export const updateHotTierInfo = (streamName: string, data: any) => { return Axios().put(LOG_STREAM_HOT_TIER(streamName), data); @@ -87,4 +87,4 @@ export const updateHotTierInfo = (streamName: string, data: any) => { export const deleteHotTierInfo = (streamName: string) => { return Axios().delete(LOG_STREAM_HOT_TIER(streamName)); -}; \ No newline at end of file +}; diff --git a/src/assets/arrow.ts b/src/assets/arrow.ts index 7191303b..7e26a9ac 100644 --- a/src/assets/arrow.ts +++ b/src/assets/arrow.ts @@ -1666,12 +1666,12 @@ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefi export type DeepPartial = T extends Builtin ? T : T extends globalThis.Array - ? globalThis.Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial; + ? globalThis.Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; function toTimestamp(date: Date): Timestamp { const seconds = date.getTime() / 1_000; diff --git a/src/assets/google/protobuf/timestamp.ts b/src/assets/google/protobuf/timestamp.ts index c7bc99cd..ecefdc2a 100644 --- a/src/assets/google/protobuf/timestamp.ts +++ b/src/assets/google/protobuf/timestamp.ts @@ -172,12 +172,12 @@ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefi export type DeepPartial = T extends Builtin ? T : T extends globalThis.Array - ? globalThis.Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial; + ? globalThis.Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { diff --git a/src/components/Button/Retry.tsx b/src/components/Button/Retry.tsx index b5f9ac07..2d5ffa42 100644 --- a/src/components/Button/Retry.tsx +++ b/src/components/Button/Retry.tsx @@ -1,7 +1,7 @@ import { Button, ButtonProps, px } from '@mantine/core'; import { IconReload } from '@tabler/icons-react'; import { FC } from 'react'; -import classes from './Button.module.css' +import classes from './Button.module.css'; type RetryProps = ButtonProps & { onClick: () => void; @@ -13,7 +13,10 @@ export const RetryBtn: FC = (props) => { const { retryBtn } = classes; return ( - ); diff --git a/src/components/Button/ToggleButton.tsx b/src/components/Button/ToggleButton.tsx index 099d017c..c02e46a6 100644 --- a/src/components/Button/ToggleButton.tsx +++ b/src/components/Button/ToggleButton.tsx @@ -1,6 +1,6 @@ import { Button, ButtonProps } from '@mantine/core'; import { FC, ReactNode } from 'react'; -import classes from './Button.module.css' +import classes from './Button.module.css'; type ToggleButtonProps = ButtonProps & { onClick: () => void; @@ -8,16 +8,16 @@ type ToggleButtonProps = ButtonProps & { renderIcon?: () => ReactNode; label?: string; iconPosition?: 'left' | 'right'; - customClassName?: string | null; + customClassName?: string | null; }; export const ToggleButton: FC = (props) => { const { onClick, toggled, label = '', renderIcon, customClassName = '' } = props; const { toggleBtn, toggleBtnActive } = classes; - const iconPosition = props.iconPosition === 'right' ? 'rightSection' : 'leftSection' + const iconPosition = props.iconPosition === 'right' ? 'rightSection' : 'leftSection'; return ( diff --git a/src/components/Header/UserDocs.tsx b/src/components/Header/UserDocs.tsx index a72ca6bf..5ab935da 100644 --- a/src/components/Header/UserDocs.tsx +++ b/src/components/Header/UserDocs.tsx @@ -4,20 +4,20 @@ import type { FC } from 'react'; import styles from './styles/LogQuery.module.css'; const DocsUser: FC = () => { - const classes = styles; + const classes = styles; const { refreshNowBtn } = classes; return ( - - - + + + ); }; diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index ce7ae37e..4295ae30 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -1,5 +1,3 @@ -import PrimaryHeader from "./PrimaryHeader"; +import PrimaryHeader from './PrimaryHeader'; -export { - PrimaryHeader, -} \ No newline at end of file +export { PrimaryHeader }; diff --git a/src/components/Misc/CreatableSelect.tsx b/src/components/Misc/CreatableSelect.tsx index 0093798c..f2994314 100644 --- a/src/components/Misc/CreatableSelect.tsx +++ b/src/components/Misc/CreatableSelect.tsx @@ -8,7 +8,7 @@ type Props = { setValue: (val: string) => void; placeholder: string; error: string; - style?: Record + style?: Record; }; export function CreatableSelect(props: Props) { @@ -16,18 +16,18 @@ export function CreatableSelect(props: Props) { onDropdownClose: () => combobox.resetSelectedOption(), }); - const { data, setData, value, setValue, style = {}} = props; + const { data, setData, value, setValue, style = {} } = props; const [search, setSearch] = useState(''); const exactOptionMatch = data.some((item) => item === search); const filteredOptions = exactOptionMatch ? data : data.filter((item) => item.toLowerCase().includes(search.toLowerCase().trim())); - const canAddValueAsOption = !exactOptionMatch && search.trim().length > 0 - + const canAddValueAsOption = !exactOptionMatch && search.trim().length > 0; + const handleEnterKeyPress = (event: KeyboardEvent) => { if (event.key === 'Enter' && canAddValueAsOption) { - setData((prev) => [...prev, search]) + setData((prev) => [...prev, search]); setValue(search); combobox.closeDropdown(); } @@ -51,7 +51,7 @@ export function CreatableSelect(props: Props) { window.removeEventListener('keydown', handleEnterKeyPress); }; }, [canAddValueAsOption, search]); - + const options = filteredOptions.map((item) => ( {item} @@ -72,8 +72,7 @@ export function CreatableSelect(props: Props) { } combobox.closeDropdown(); - }} - > + }}> } @@ -98,7 +97,7 @@ export function CreatableSelect(props: Props) { {options} - { canAddValueAsOption ? ( + {canAddValueAsOption ? ( + Create {search} ) : ( diff --git a/src/components/Navbar/UserModal.tsx b/src/components/Navbar/UserModal.tsx index 9832cd80..ad58fc7e 100644 --- a/src/components/Navbar/UserModal.tsx +++ b/src/components/Navbar/UserModal.tsx @@ -10,13 +10,13 @@ const ModalTitle = () => { type UserModalProps = { opened: boolean; onClose: () => void; - userData: {[key: string]: string} -} + userData: { [key: string]: string }; +}; const UserModal = (props: UserModalProps) => { const username = Cookies.get('username'); - const [userRoles] = useAppStore(store => store.userRoles); + const [userRoles] = useAppStore((store) => store.userRoles); if (!userRoles) return null; return ( diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx index b9c65c39..ceebabd8 100644 --- a/src/components/Navbar/index.tsx +++ b/src/components/Navbar/index.tsx @@ -185,10 +185,10 @@ const Navbar: FC = () => { navAction.key === 'about' ? toggleInfoModal : navAction.key === 'user' - ? toggleUserModal - : navAction.key === 'logout' - ? signOutHandler - : () => {}; + ? toggleUserModal + : navAction.key === 'logout' + ? signOutHandler + : () => {}; return ( = (props) => { Usage Analytics - {analytics?.clarityTag ? 'Tracking (MS Clarity)' : 'Not Tracking'} + + {analytics?.clarityTag ? 'Tracking (MS Clarity)' : 'Not Tracking'} + diff --git a/src/components/Navbar/rolesHandler.ts b/src/components/Navbar/rolesHandler.ts index 189bec2f..5a9c3f37 100644 --- a/src/components/Navbar/rolesHandler.ts +++ b/src/components/Navbar/rolesHandler.ts @@ -1,4 +1,4 @@ -import { UserRoles } from "@/layouts/MainLayout/providers/AppProvider"; +import { UserRoles } from '@/layouts/MainLayout/providers/AppProvider'; const adminAccess = [ 'Ingest', @@ -18,7 +18,7 @@ const adminAccess = [ 'DeleteUser', 'PutRoles', 'GetRole', - 'Cluster' + 'Cluster', ]; const editorAccess = [ 'Ingest', diff --git a/src/constants/routes.ts b/src/constants/routes.ts index 105dd952..a006d61f 100644 --- a/src/constants/routes.ts +++ b/src/constants/routes.ts @@ -9,9 +9,9 @@ export const EXPLORE_ROUTE = '/:streamName/explore'; export const USERS_MANAGEMENT_ROUTE = '/users'; export const OIDC_NOT_CONFIGURED_ROUTE = '/oidc-not-configured'; export const CLUSTER_ROUTE = '/cluster'; -export const STREAM_ROUTE = '/:streamName/:view?' +export const STREAM_ROUTE = '/:streamName/:view?'; -export const STREAM_VIEWS = ['explore', 'manage', 'live-tail'] +export const STREAM_VIEWS = ['explore', 'manage', 'live-tail']; export const PATHS = { all: '/*', diff --git a/src/constants/theme.ts b/src/constants/theme.ts index 4d91ad67..ade9e914 100644 --- a/src/constants/theme.ts +++ b/src/constants/theme.ts @@ -8,4 +8,4 @@ export const STREAM_PRIMARY_TOOLBAR_CONTAINER_HEIGHT = 48; export const STREAM_PRIMARY_TOOLBAR_HEIGHT = 26; export const STREAM_SECONDARY_TOOLBAR_HRIGHT = 70; export const SECONDARY_SIDEBAR_WIDTH = 50; -export const JSON_VIEW_TOOLBAR_HEIGHT = 50; \ No newline at end of file +export const JSON_VIEW_TOOLBAR_HEIGHT = 50; diff --git a/src/constants/timeConstants.ts b/src/constants/timeConstants.ts index 0bf8d8d1..49d81cb8 100644 --- a/src/constants/timeConstants.ts +++ b/src/constants/timeConstants.ts @@ -12,27 +12,27 @@ export const FIXED_DURATIONS: ReadonlyArray = [ { name: 'last 10 minutes', milliseconds: dayjs.duration({ minutes: 10 }).asMilliseconds(), - label: '10M' + label: '10M', }, { name: 'last 1 hour', milliseconds: dayjs.duration({ hours: 1 }).asMilliseconds(), - label: '1H' + label: '1H', }, { name: 'last 5 hours', milliseconds: dayjs.duration({ hours: 5 }).asMilliseconds(), - label: '5H' + label: '5H', }, { name: 'last 24 hours', milliseconds: dayjs.duration({ days: 1 }).asMilliseconds(), - label: '1D' + label: '1D', }, { name: 'last 3 days', milliseconds: dayjs.duration({ days: 3 }).asMilliseconds(), - label: '3D' + label: '3D', }, ] as const; @@ -42,4 +42,4 @@ export const FIXED_DURATIONS_LABEL: { [key: string]: string } = { 'last 5 hours': '5H', 'last 24 hours': '1D', 'last 3 days': '3D', -} as const; \ No newline at end of file +} as const; diff --git a/src/hooks/useCacheToggle.tsx b/src/hooks/useCacheToggle.tsx index e529b6a6..f23ae792 100644 --- a/src/hooks/useCacheToggle.tsx +++ b/src/hooks/useCacheToggle.tsx @@ -3,22 +3,22 @@ import { getCachingStatus, updateCaching } from '@/api/caching'; import { notifySuccess } from '@/utils/notification'; import { useStreamStore, streamStoreReducers } from '@/pages/Stream/providers/StreamProvider'; -const {setCacheEnabled} = streamStoreReducers +const { setCacheEnabled } = streamStoreReducers; export const useCacheToggle = (streamName: string) => { - const [, setStreamStore] = useStreamStore(_store => null) + const [, setStreamStore] = useStreamStore((_store) => null); const { data: checkCacheData, refetch: getCacheStatusRefetch, isError: getCacheError, - isLoading: getCacheLoading + isLoading: getCacheLoading, } = useQuery(['fetch-cache-status', streamName], () => getCachingStatus(streamName), { retry: false, enabled: streamName !== '', refetchOnWindowFocus: false, onSuccess: (data) => { - setStreamStore(store => setCacheEnabled(store, data.data)) - } + setStreamStore((store) => setCacheEnabled(store, data.data)); + }, }); const { mutate: updateCacheStatus } = useMutation( @@ -36,6 +36,6 @@ export const useCacheToggle = (streamName: string) => { isCacheEnabled: checkCacheData?.data, getCacheError, updateCacheStatus, - getCacheLoading + getCacheLoading, }; }; diff --git a/src/hooks/useCurrentRoute.ts b/src/hooks/useCurrentRoute.ts index bc2bfe8d..699e535f 100644 --- a/src/hooks/useCurrentRoute.ts +++ b/src/hooks/useCurrentRoute.ts @@ -1,9 +1,9 @@ -import { PATHS } from "@/constants/routes" -import { matchRoutes, useLocation } from "react-router-dom" +import { PATHS } from '@/constants/routes'; +import { matchRoutes, useLocation } from 'react-router-dom'; const routes = Object.keys(PATHS).map((key: string) => { const value = PATHS[key]; - return {path: value}; + return { path: value }; }); const useCurrentRoute = () => { @@ -17,4 +17,4 @@ const useCurrentRoute = () => { } }; -export default useCurrentRoute; \ No newline at end of file +export default useCurrentRoute; diff --git a/src/hooks/useGetStreamInfo.tsx b/src/hooks/useGetStreamInfo.tsx index 4417bdea..6153553c 100644 --- a/src/hooks/useGetStreamInfo.tsx +++ b/src/hooks/useGetStreamInfo.tsx @@ -11,7 +11,7 @@ export const useGetStreamInfo = (currentStream: string) => { isError: getStreamInfoError, isSuccess: getStreamInfoSuccess, isLoading: getStreamInfoLoading, - refetch: getStreamInfoRefetch + refetch: getStreamInfoRefetch, } = useQuery(['stream-info', currentStream], () => getLogStreamInfo(currentStream), { retry: false, refetchOnWindowFocus: false, @@ -25,6 +25,6 @@ export const useGetStreamInfo = (currentStream: string) => { getStreamInfoError, getStreamInfoSuccess, getStreamInfoLoading, - getStreamInfoRefetch + getStreamInfoRefetch, }; }; diff --git a/src/hooks/useLoginForm.ts b/src/hooks/useLoginForm.ts index 4ad9516a..e41e1022 100644 --- a/src/hooks/useLoginForm.ts +++ b/src/hooks/useLoginForm.ts @@ -62,7 +62,7 @@ export const useLoginForm = () => { const pathname = location.state?.from?.pathname || HOME_ROUTE; nav( { - pathname + pathname, }, { replace: true }, ); diff --git a/src/hooks/useRetentionEditor.tsx b/src/hooks/useRetentionEditor.tsx index 5952e4d5..37fb9518 100644 --- a/src/hooks/useRetentionEditor.tsx +++ b/src/hooks/useRetentionEditor.tsx @@ -17,7 +17,7 @@ export const useRetentionQuery = (streamName: string) => { refetch: getLogRetentionDataRefetch, } = useQuery(['fetch-log-stream-retention', streamName], () => getLogStreamRetention(streamName), { onSuccess: (data) => { - const retentionData = _.isArray(data.data) ? data.data[0] || {} : {} + const retentionData = _.isArray(data.data) ? data.data[0] || {} : {}; setStreamStore((store) => setRetention(store, retentionData)); }, retry: false, diff --git a/src/hooks/useRole.tsx b/src/hooks/useRole.tsx index ee4ca6aa..71062d51 100644 --- a/src/hooks/useRole.tsx +++ b/src/hooks/useRole.tsx @@ -21,7 +21,7 @@ export const useRole = () => { typeof error === 'string' && notifyError({ message: error }); } else if (data.message && typeof data.message === 'string') { notifyError({ message: data.message }); - } + } }, }); @@ -77,7 +77,7 @@ export const useRole = () => { typeof error === 'string' && notifyError({ message: error }); } else if (data.message && typeof data.message === 'string') { notifyError({ message: data.message }); - } + } }, }); diff --git a/src/hooks/useUser.tsx b/src/hooks/useUser.tsx index 55dd4d2e..538babd4 100644 --- a/src/hooks/useUser.tsx +++ b/src/hooks/useUser.tsx @@ -131,7 +131,7 @@ export const useGetUser = () => { refetch: getUserRefetch, } = useQuery(['fetch-user'], () => getUsers(), { retry: false, - refetchOnWindowFocus: false + refetchOnWindowFocus: false, }); return { getUserRefetch, diff --git a/src/jq-web.d.ts b/src/jq-web.d.ts index 9e8114d0..5ae2b409 100644 --- a/src/jq-web.d.ts +++ b/src/jq-web.d.ts @@ -10,4 +10,4 @@ declare module 'jq-web' { const jq: JQWeb; export default jq; -} \ No newline at end of file +} diff --git a/src/main.tsx b/src/main.tsx index 3ddf0b78..f05a59ee 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -16,13 +16,13 @@ import { QueryClient, QueryClientProvider } from 'react-query'; const queryClient = new QueryClient(); ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - - - - - - - - - + + + + + + + + + , ); diff --git a/src/pages/AccessManagement/PrivilegeTR.tsx b/src/pages/AccessManagement/PrivilegeTR.tsx index f5b41a67..d20b77c1 100644 --- a/src/pages/AccessManagement/PrivilegeTR.tsx +++ b/src/pages/AccessManagement/PrivilegeTR.tsx @@ -18,7 +18,7 @@ import { IconPlus, IconTrash, IconX } from '@tabler/icons-react'; import { FC, useEffect, useState } from 'react'; import { useGetLogStreamList } from '@/hooks/useGetLogStreamList'; import { useRole } from '@/hooks/useRole'; -import styles from './styles/AccessManagement.module.css' +import styles from './styles/AccessManagement.module.css'; interface PrivilegeTRProps { roleName: string; @@ -252,7 +252,7 @@ const PrivilegeTR: FC = (props) => { ) : getRoleIsLoading ? ( 'loading..' ) : getRoleData?.data ? ( - + {getBadges(getRoleData?.data)} = (props) => { withArrow position="right"> - + diff --git a/src/pages/AccessManagement/RoleTR.tsx b/src/pages/AccessManagement/RoleTR.tsx index 895ca4a5..75161d92 100644 --- a/src/pages/AccessManagement/RoleTR.tsx +++ b/src/pages/AccessManagement/RoleTR.tsx @@ -27,7 +27,7 @@ interface RoleTRProps { id: string; method: string; }; - deleteUserMutation: (data: { userName: string, onSuccess?: () => void; }) => void; + deleteUserMutation: (data: { userName: string; onSuccess?: () => void }) => void; updateUserPasswordIsError: boolean; getUserRolesIsError: boolean; getUserRolesIsLoading: boolean; diff --git a/src/pages/AccessManagement/Roles.tsx b/src/pages/AccessManagement/Roles.tsx index c5a9c0d2..362640a3 100644 --- a/src/pages/AccessManagement/Roles.tsx +++ b/src/pages/AccessManagement/Roles.tsx @@ -5,19 +5,19 @@ import { useGetLogStreamList } from '@/hooks/useGetLogStreamList'; import PrivilegeTR from './PrivilegeTR'; import { IconBook2, IconPencil, IconUserPlus } from '@tabler/icons-react'; import { useRole } from '@/hooks/useRole'; -import classes from './styles/AccessManagement.module.css' +import classes from './styles/AccessManagement.module.css'; import IconButton from '@/components/Button/IconButton'; import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider'; const navigateToDocs = () => { return window.open('https://www.parseable.io/docs/rbac', '_blank'); -} +}; -const renderDocsIcon = () => +const renderDocsIcon = () => ; const Roles: FC = () => { useDocumentTitle('Parseable | Users'); - const [oidcActive] = useAppStore(store => store.instanceConfig?.oidcActive) + const [oidcActive] = useAppStore((store) => store.instanceConfig?.oidcActive); const [modalOpen, setModalOpen] = useState(false); const [defaultRoleModalOpen, setDefaultRoleModalOpen] = useState(false); @@ -172,9 +172,7 @@ const Roles: FC = () => { return ( - - Roles - + Roles - + @@ -126,8 +126,12 @@ const Users: FC = () => { Username Role - Delete - Reset Password + + Delete + + + Reset Password + {rows} diff --git a/src/pages/Errors/Bug.tsx b/src/pages/Errors/Bug.tsx index 33bb063a..dc4faf12 100644 --- a/src/pages/Errors/Bug.tsx +++ b/src/pages/Errors/Bug.tsx @@ -5,7 +5,7 @@ import type { ImageProps } from '@mantine/core'; import { Box, Button, Center, Group, Image, Text, Title } from '@mantine/core'; import { useDocumentTitle } from '@mantine/hooks'; import type { FC } from 'react'; -import errorStyles from './styles/Errors.module.css' +import errorStyles from './styles/Errors.module.css'; const Illustration: FC = (props) => { return Bug; diff --git a/src/pages/Errors/NotFound.tsx b/src/pages/Errors/NotFound.tsx index eb2e241e..f19f4bd8 100644 --- a/src/pages/Errors/NotFound.tsx +++ b/src/pages/Errors/NotFound.tsx @@ -3,7 +3,7 @@ import { Box, Button, Center, Group, Text, Title } from '@mantine/core'; import { useDocumentTitle } from '@mantine/hooks'; import { ComponentPropsWithoutRef, FC } from 'react'; import { useNavigate } from 'react-router-dom'; -import errorStyles from './styles/Errors.module.css' +import errorStyles from './styles/Errors.module.css'; const Illustration: FC> = (props) => { return ( diff --git a/src/pages/Errors/OIDC.tsx b/src/pages/Errors/OIDC.tsx index eedfbb15..ee083005 100644 --- a/src/pages/Errors/OIDC.tsx +++ b/src/pages/Errors/OIDC.tsx @@ -3,7 +3,7 @@ import { Box, Button, Center, Group, Text, Title } from '@mantine/core'; import { useDocumentTitle } from '@mantine/hooks'; import { ComponentPropsWithoutRef, FC } from 'react'; import { useNavigate } from 'react-router-dom'; -import errorStyles from './styles/Errors.module.css' +import errorStyles from './styles/Errors.module.css'; const Illustration: FC> = (props) => { return ( diff --git a/src/pages/Login/index.tsx b/src/pages/Login/index.tsx index 8ea3b5b3..9c2183a4 100644 --- a/src/pages/Login/index.tsx +++ b/src/pages/Login/index.tsx @@ -4,7 +4,7 @@ import { useLoginForm } from '@/hooks/useLoginForm'; import { Box, Button, Divider, Image, PasswordInput, Text, TextInput, Transition, rem } from '@mantine/core'; import { useDocumentTitle } from '@mantine/hooks'; import { FC } from 'react'; -import loginStyles from './styles/Login.module.css' +import loginStyles from './styles/Login.module.css'; const baseURL = import.meta.env.VITE_PARSEABLE_URL ?? '/'; const Login: FC = () => { @@ -34,7 +34,8 @@ const Login: FC = () => { }}> Unified logs for all applications and infrastructure - Access, debug and analyze your log data here. Run sophisticated SQL queries on your log data, or look at tabular view. + Access, debug and analyze your log data here. Run sophisticated SQL queries on your log data, or look at + tabular view. diff --git a/src/pages/Stream/Views/Explore/Footer.tsx b/src/pages/Stream/Views/Explore/Footer.tsx index 17af5075..5c69fe25 100644 --- a/src/pages/Stream/Views/Explore/Footer.tsx +++ b/src/pages/Stream/Views/Explore/Footer.tsx @@ -1,18 +1,18 @@ -import { FC, useCallback } from "react"; -import { useLogsStore, logsStoreReducers, LOAD_LIMIT, LOG_QUERY_LIMITS } from "../../providers/LogsProvider"; -import { useAppStore } from "@/layouts/MainLayout/providers/AppProvider"; -import { usePagination } from "@mantine/hooks"; -import { downloadDataAsCSV, downloadDataAsJson } from "@/utils/exportHelpers"; -import { Box, Center, Group, Loader, Menu, Pagination, px, Stack, Tooltip } from "@mantine/core"; -import _ from "lodash"; -import { Text } from "@mantine/core"; -import { HumanizeNumber } from "@/utils/formatBytes"; -import IconButton from "@/components/Button/IconButton"; -import { IconDownload, IconSelector } from "@tabler/icons-react"; -import useMountedState from "@/hooks/useMountedState"; -import classes from '../../styles/Footer.module.css' +import { FC, useCallback } from 'react'; +import { useLogsStore, logsStoreReducers, LOAD_LIMIT, LOG_QUERY_LIMITS } from '../../providers/LogsProvider'; +import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider'; +import { usePagination } from '@mantine/hooks'; +import { downloadDataAsCSV, downloadDataAsJson } from '@/utils/exportHelpers'; +import { Box, Center, Group, Loader, Menu, Pagination, px, Stack, Tooltip } from '@mantine/core'; +import _ from 'lodash'; +import { Text } from '@mantine/core'; +import { HumanizeNumber } from '@/utils/formatBytes'; +import IconButton from '@/components/Button/IconButton'; +import { IconDownload, IconSelector } from '@tabler/icons-react'; +import useMountedState from '@/hooks/useMountedState'; +import classes from '../../styles/Footer.module.css'; -const {setPageAndPageData, setCurrentPage, setCurrentOffset, makeExportData} = logsStoreReducers; +const { setPageAndPageData, setCurrentPage, setCurrentOffset, makeExportData } = logsStoreReducers; const TotalCount = (props: { totalCount: number }) => { return ( @@ -48,7 +48,6 @@ const TotalLogsCount = (props: { hasTableLoaded: boolean; isFetchingCount: boole ); }; - const LimitControl: FC = () => { const [opened, setOpened] = useMountedState(false); const [perPage, setLogsStore] = useLogsStore((store) => store.tableOpts.perPage); @@ -151,7 +150,7 @@ const Footer = (props: { loaded: boolean; isLoading: boolean; hasNoData: boolean pagination.setPage(page); }} size="sm"> - + { currentOffset !== 0 && onChangeOffset('prev'); @@ -211,4 +210,4 @@ const Footer = (props: { loaded: boolean; isLoading: boolean; hasNoData: boolean ); }; -export default Footer; \ No newline at end of file +export default Footer; diff --git a/src/pages/Stream/Views/Explore/LoadingViews.tsx b/src/pages/Stream/Views/Explore/LoadingViews.tsx index 591a41bb..7bd7d3b6 100644 --- a/src/pages/Stream/Views/Explore/LoadingViews.tsx +++ b/src/pages/Stream/Views/Explore/LoadingViews.tsx @@ -1,8 +1,8 @@ -import { useCallback } from "react"; -import { useLogsStore, logsStoreReducers } from "../../providers/LogsProvider"; -import { Center, Loader, Stack, Text } from "@mantine/core"; -import { RetryBtn } from "@/components/Button/Retry"; -import classes from '../../styles/Logs.module.css' +import { useCallback } from 'react'; +import { useLogsStore, logsStoreReducers } from '../../providers/LogsProvider'; +import { Center, Loader, Stack, Text } from '@mantine/core'; +import { RetryBtn } from '@/components/Button/Retry'; +import classes from '../../styles/Logs.module.css'; const { getCleanStoreForRefetch } = logsStoreReducers; @@ -35,4 +35,4 @@ export const LoadingView = () => { ); -}; \ No newline at end of file +}; diff --git a/src/pages/Stream/Views/Explore/StaticLogTable.tsx b/src/pages/Stream/Views/Explore/StaticLogTable.tsx index 81e1fc34..965ce9b5 100644 --- a/src/pages/Stream/Views/Explore/StaticLogTable.tsx +++ b/src/pages/Stream/Views/Explore/StaticLogTable.tsx @@ -10,7 +10,11 @@ import EmptyBox from '@/components/Empty'; import Column from '../../components/Column'; import FilterPills from '../../components/FilterPills'; import tableStyles from '../../styles/Logs.module.css'; -import { PRIMARY_HEADER_HEIGHT, STREAM_PRIMARY_TOOLBAR_CONTAINER_HEIGHT, STREAM_SECONDARY_TOOLBAR_HRIGHT } from '@/constants/theme'; +import { + PRIMARY_HEADER_HEIGHT, + STREAM_PRIMARY_TOOLBAR_CONTAINER_HEIGHT, + STREAM_SECONDARY_TOOLBAR_HRIGHT, +} from '@/constants/theme'; import { useLogsStore, logsStoreReducers } from '../../providers/LogsProvider'; import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider'; import _ from 'lodash'; diff --git a/src/pages/Stream/Views/Explore/useLogsFetcher.ts b/src/pages/Stream/Views/Explore/useLogsFetcher.ts index 027de19e..406a44d9 100644 --- a/src/pages/Stream/Views/Explore/useLogsFetcher.ts +++ b/src/pages/Stream/Views/Explore/useLogsFetcher.ts @@ -5,8 +5,8 @@ import { useQueryLogs } from '@/hooks/useQueryLogs'; const { setCleanStoreForStreamChange } = logsStoreReducers; -const useLogsFetcher = (props: {schemaLoading: boolean}) => { - const {schemaLoading} = props; +const useLogsFetcher = (props: { schemaLoading: boolean }) => { + const { schemaLoading } = props; const [currentStream] = useAppStore((store) => store.currentStream); const [tableOpts, setLogsStore] = useLogsStore((store) => store.tableOpts); const { currentOffset, currentPage, pageData } = tableOpts; diff --git a/src/pages/Stream/Views/LiveTail/LiveLogRow.tsx b/src/pages/Stream/Views/LiveTail/LiveLogRow.tsx index 3f22a8f4..83ade660 100644 --- a/src/pages/Stream/Views/LiveTail/LiveLogRow.tsx +++ b/src/pages/Stream/Views/LiveTail/LiveLogRow.tsx @@ -2,7 +2,7 @@ import { parseLogData } from '@/utils'; import { FC, Fragment } from 'react'; import { Log } from '@/@types/parseable/api/query'; import { LogStreamData } from '@/@types/parseable/api/stream'; -import styles from '../../styles/Logs.module.css' +import styles from '../../styles/Logs.module.css'; type LogRowProps = { logData: Log[]; diff --git a/src/pages/Stream/Views/Manage/Alerts.tsx b/src/pages/Stream/Views/Manage/Alerts.tsx index 2d935466..4236505f 100644 --- a/src/pages/Stream/Views/Manage/Alerts.tsx +++ b/src/pages/Stream/Views/Manage/Alerts.tsx @@ -1,4 +1,16 @@ -import { Button, Stack, Text, Box, Tooltip, Modal, TextInput, Select, Checkbox, NumberInput, Loader } from '@mantine/core'; +import { + Button, + Stack, + Text, + Box, + Tooltip, + Modal, + TextInput, + Select, + Checkbox, + NumberInput, + Loader, +} from '@mantine/core'; import classes from '../../styles/Management.module.css'; import { TransformedAlert } from '../../providers/StreamProvider'; import _ from 'lodash'; @@ -9,7 +21,7 @@ import { useStreamStore, streamStoreReducers } from '../../providers/StreamProvi const defaultColumnTypeConfig = { column: '', operator: '=', value: '', repeats: 1, ignoreCase: false }; const defaultColumnTypeRule = { type: 'column' as 'column', config: defaultColumnTypeConfig }; -const {transformAlerts} = streamStoreReducers; +const { transformAlerts } = streamStoreReducers; const stringOperators = [ { value: '=', label: 'equals to' }, @@ -102,7 +114,8 @@ const useAlertsForm = (opts: FormOpts) => { name: (value) => isValidName(value, opts.allAlertNames || []), message: (value) => (_.isEmpty(value) ? 'Message cannot be empty' : null), rule: { - type: (value: 'column' | 'composite') => (_.includes([columnRuleType, compositeRuleType], value) ? null : 'Unknown rule type'), + type: (value: 'column' | 'composite') => + _.includes([columnRuleType, compositeRuleType], value) ? null : 'Unknown rule type', }, targets: { endpoint: (value) => (_.isEmpty(value) ? 'Cannot be empty' : null), @@ -143,7 +156,11 @@ const RuleSectionHeader = (props: RuleSectionHeaderProps) => { Rule Description for rule - ); }; @@ -393,11 +410,10 @@ const TargetsSection = (props: TargetsSectionProps) => { @@ -475,7 +491,12 @@ const AlertForm = (props: { form: AlertsFormType }) => { type AlertsFormType = UseFormReturnType TransformedAlert>; -const AlertsModal = (props: { open: boolean; alertName: string; onClose: () => void, updateAlerts: ({ config, onSuccess }: { config: any, onSuccess: () => void }) => void; }) => { +const AlertsModal = (props: { + open: boolean; + alertName: string; + onClose: () => void; + updateAlerts: ({ config, onSuccess }: { config: any; onSuccess: () => void }) => void; +}) => { const { open, alertName, onClose, updateAlerts } = props; const [alertsConfig] = useStreamStore((store) => store.alertsConfig); const { alerts } = alertsConfig; @@ -494,26 +515,26 @@ const AlertsModal = (props: { open: boolean; alertName: string; onClose: () => v const onSubmitSuccess = useCallback(() => { form.setValues(defaultAlert); onClose(); - }, []) + }, []); const onSubmit = useCallback(() => { - const errors = form.validate() + const errors = form.validate(); if (!errors.hasErrors) { const formValues = form.values; const allAlerts = (() => { if (alert) { - const alertIndex = _.findIndex(alerts, alert => alert.name === formValues.name) + const alertIndex = _.findIndex(alerts, (alert) => alert.name === formValues.name); const modifiedAlerts = _.clone(alerts); - modifiedAlerts[alertIndex] = formValues; + modifiedAlerts[alertIndex] = formValues; return modifiedAlerts; } else { - return [...alerts, formValues] + return [...alerts, formValues]; } - })() - const transformedAlerts = transformAlerts(allAlerts) - updateAlerts({config: {...alertsConfig, alerts: transformedAlerts}, onSuccess: onSubmitSuccess}) + })(); + const transformedAlerts = transformAlerts(allAlerts); + updateAlerts({ config: { ...alertsConfig, alerts: transformedAlerts }, onSuccess: onSubmitSuccess }); } - }, [updateAlerts, form, alertsConfig, alert]) + }, [updateAlerts, form, alertsConfig, alert]); return ( v ); }; -const Header = (props: { selectAlert: selectAlert, isLoading: boolean }) => { +const Header = (props: { selectAlert: selectAlert; isLoading: boolean }) => { return ( - + Alerts {!props.isLoading && ( @@ -554,7 +575,7 @@ const Header = (props: { selectAlert: selectAlert, isLoading: boolean }) => { variant="outline" onClick={() => props.selectAlert('')} // h={'2rem'} - leftSection={}> + leftSection={}> New Alert @@ -563,7 +584,11 @@ const Header = (props: { selectAlert: selectAlert, isLoading: boolean }) => { ); }; -const AlertItem = (props: { alert: TransformedAlert; selectAlert: selectAlert, onDeleteAlert: (name: string) => void; }) => { +const AlertItem = (props: { + alert: TransformedAlert; + selectAlert: selectAlert; + onDeleteAlert: (name: string) => void; +}) => { const { alert, selectAlert } = props; const { name } = alert; @@ -584,7 +609,11 @@ const AlertItem = (props: { alert: TransformedAlert; selectAlert: selectAlert, o type selectAlert = (title: string) => void; -const AlertList = (props: { selectAlert: selectAlert, isLoading: boolean, updateAlerts: ({ config }: { config: any }) => void; }) => { +const AlertList = (props: { + selectAlert: selectAlert; + isLoading: boolean; + updateAlerts: ({ config }: { config: any }) => void; +}) => { const [alertsConfig] = useStreamStore((store) => store.alertsConfig); const { alerts } = alertsConfig; @@ -593,14 +622,14 @@ const AlertList = (props: { selectAlert: selectAlert, isLoading: boolean, update const alertIndex = _.findIndex(alerts, (alert) => alert.name === alertName); const modifiedAlerts = _.clone(alerts); modifiedAlerts.splice(alertIndex, 1); - const transformedAlerts = transformAlerts(modifiedAlerts) + const transformedAlerts = transformAlerts(modifiedAlerts); props.updateAlerts({ config: { ...alertsConfig, alerts: transformedAlerts } }); }, [alertsConfig], ); return ( - + {props.isLoading ? ( @@ -610,7 +639,7 @@ const AlertList = (props: { selectAlert: selectAlert, isLoading: boolean, update ) : ( <> {_.map(alerts, (alert) => { - return ; + return ; })} )} @@ -621,7 +650,7 @@ const AlertList = (props: { selectAlert: selectAlert, isLoading: boolean, update const Alerts = (props: { isLoading: boolean; schemaLoading: boolean; - updateAlerts: ({ config, onSuccess }: { config: any, onSuccess?: () => void; }) => void; + updateAlerts: ({ config, onSuccess }: { config: any; onSuccess?: () => void }) => void; }) => { const [alertName, setAlertName] = useState(''); const [alertModalOpen, setAlertModalOpen] = useState(false); @@ -636,10 +665,10 @@ const Alerts = (props: { }, []); return ( - - + +
- + ); }; diff --git a/src/pages/Stream/Views/Manage/Info.tsx b/src/pages/Stream/Views/Manage/Info.tsx index f575b94e..d7b6f574 100644 --- a/src/pages/Stream/Views/Manage/Info.tsx +++ b/src/pages/Stream/Views/Manage/Info.tsx @@ -17,7 +17,7 @@ const Header = () => { const InfoItem = (props: { title: string; value: string; fullWidth?: boolean }) => { return ( - + { const getStreamStats = useLogStreamStats(currentStream || ''); const getRetentionConfig = useRetentionQuery(currentStream || ''); const getStreamInfo = useGetStreamInfo(currentStream || ''); - const hotTierFetch = useHotTier(currentStream || '') + const hotTierFetch = useHotTier(currentStream || ''); // todo - handle loading and error states separately const isStatsLoading = getStreamStats.getLogStreamStatsDataIsLoading || getStreamStats.getLogStreamStatsDataIsError; const isAlertsLoading = getStreamAlertsConfig.isError || getStreamAlertsConfig.isLoading; - const isRetentionLoading = getRetentionConfig.getLogRetentionIsLoading || getRetentionConfig.getLogRetentionIsError || instanceConfig === null; + const isRetentionLoading = + getRetentionConfig.getLogRetentionIsLoading || getRetentionConfig.getLogRetentionIsError || instanceConfig === null; const isStreamInfoLoading = getStreamInfo.getStreamInfoLoading || getStreamInfo.getStreamInfoError; const isHotTierLoading = hotTierFetch.getHotTierInfoLoading; return ( - + diff --git a/src/pages/Stream/Views/Manage/Stats.tsx b/src/pages/Stream/Views/Manage/Stats.tsx index 1e1e1cff..0f981011 100644 --- a/src/pages/Stream/Views/Manage/Stats.tsx +++ b/src/pages/Stream/Views/Manage/Stats.tsx @@ -145,7 +145,7 @@ const StorageSizeRow = () => { style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}> {`( `} - + {compressionSize} diff --git a/src/pages/Stream/components/Column.tsx b/src/pages/Stream/components/Column.tsx index 6a0d1ae3..ef997206 100644 --- a/src/pages/Stream/components/Column.tsx +++ b/src/pages/Stream/components/Column.tsx @@ -73,8 +73,8 @@ const Column: FC = (props) => { }, []); const openPopover = useCallback(() => { - setPopoverOpen(true) - }, []) + setPopoverOpen(true); + }, []); const onSearch = useCallback( (e: ChangeEvent) => { @@ -125,7 +125,7 @@ const Column: FC = (props) => { - + Filter by values: diff --git a/src/pages/Stream/components/PrimaryToolbar.tsx b/src/pages/Stream/components/PrimaryToolbar.tsx index 8d7a6160..e1dfd010 100644 --- a/src/pages/Stream/components/PrimaryToolbar.tsx +++ b/src/pages/Stream/components/PrimaryToolbar.tsx @@ -15,7 +15,7 @@ import _ from 'lodash'; import StreamingButton from '@/components/Header/StreamingButton'; import { useLogsStore, logsStoreReducers } from '../providers/LogsProvider'; import { filterStoreReducers, useFilterStore } from '../providers/FilterProvider'; -import classes from './styles/PrimaryToolbar.module.css' +import classes from './styles/PrimaryToolbar.module.css'; const { toggleDeleteModal, onToggleView } = logsStoreReducers; const { toggleSavedFiltersModal } = filterStoreReducers; @@ -85,7 +85,7 @@ const ViewToggle = () => { ]} /> ); -} +}; const PrimaryToolbar = () => { const [maximized] = useAppStore((store) => store.maximized); @@ -113,11 +113,11 @@ const PrimaryToolbar = () => { - + - + ) : view === 'live-tail' ? ( @@ -126,14 +126,12 @@ const PrimaryToolbar = () => { - ) - : view === 'manage' ? ( + ) : view === 'manage' ? ( - ) - : null} + ) : null} ); }; diff --git a/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx b/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx index c2d424d6..69802ab0 100644 --- a/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx +++ b/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx @@ -264,7 +264,7 @@ export const FilterQueryBuilder = (props: { onClear: () => void; onApply: () => }, [query.rules, fields]); return ( - + {query.rules.map((ruleSet) => { diff --git a/src/pages/Stream/components/Querier/QueryCodeEditor.tsx b/src/pages/Stream/components/Querier/QueryCodeEditor.tsx index d5424c14..0f1f02c1 100644 --- a/src/pages/Stream/components/Querier/QueryCodeEditor.tsx +++ b/src/pages/Stream/components/Querier/QueryCodeEditor.tsx @@ -188,12 +188,15 @@ const SchemaList = (props: { currentStream: string | null; fields: Field[] }) => if (!fields || fields.length === 0) return null; const { leftColumns, rightColumns } = genColumnConfig(fields); - const showShadow = schemaDivHeight > 190 ? (!((schemaDivHeight -190) === scrollPosition.y) ? queryCodeStyles.schemaListShadow : ''): ''; + const showShadow = + schemaDivHeight > 190 + ? !(schemaDivHeight - 190 === scrollPosition.y) + ? queryCodeStyles.schemaListShadow + : '' + : ''; return ( - + {schemaDivHeight > 190 && scrollPosition.y < 10 ? ( - Scroll to see more + + Scroll to see more + ) : null} ); diff --git a/src/pages/Stream/components/Querier/QueryEditor.tsx b/src/pages/Stream/components/Querier/QueryEditor.tsx index c92920a7..8889d17c 100644 --- a/src/pages/Stream/components/Querier/QueryEditor.tsx +++ b/src/pages/Stream/components/Querier/QueryEditor.tsx @@ -2,7 +2,7 @@ import { CodeHighlight } from '@mantine/code-highlight'; import { useLogsStore } from '../../providers/LogsProvider'; export const AppliedSQLQuery = () => { - const [custSearchQuery] = useLogsStore(store => store.custQuerySearchState.custSearchQuery) + const [custSearchQuery] = useLogsStore((store) => store.custQuerySearchState.custSearchQuery); return ( { if (_.isString(query.filter_query)) { props.onSqlSearchApply(query.filter_query, filter_id, time_filter); @@ -141,8 +140,8 @@ const SavedFilterItem = (props: { _.isString(query.filter_query) ? query.filter_query : query.filter_builder - ? parseQuery(query.filter_builder, stream_name).parsedQuery - : '' + ? parseQuery(query.filter_builder, stream_name).parsedQuery + : '' } language="sql" withCopyButton={false} diff --git a/src/pages/Stream/components/Querier/index.tsx b/src/pages/Stream/components/Querier/index.tsx index bac334bc..93f0f58a 100644 --- a/src/pages/Stream/components/Querier/index.tsx +++ b/src/pages/Stream/components/Querier/index.tsx @@ -72,7 +72,7 @@ const QuerierModal = (props: { onSqlSearchApply: (query: string) => void; onFiltersApply: () => void; }) => { - const [currentStream] = useAppStore(store => store.currentStream) + const [currentStream] = useAppStore((store) => store.currentStream); const [{ showQueryBuilder, viewMode }, setLogsStore] = useLogsStore((store) => store.custQuerySearchState); const onClose = useCallback(() => { setLogsStore((store) => toggleQueryBuilder(store, false)); diff --git a/src/pages/Stream/index.tsx b/src/pages/Stream/index.tsx index ed74396f..cf0af849 100644 --- a/src/pages/Stream/index.tsx +++ b/src/pages/Stream/index.tsx @@ -89,7 +89,7 @@ const Logs: FC = () => { error ? ( ) : ( - + ) ) : view === 'live-tail' ? ( diff --git a/src/pages/Stream/providers/FilterProvider.tsx b/src/pages/Stream/providers/FilterProvider.tsx index 8eb80ed7..ba31984e 100644 --- a/src/pages/Stream/providers/FilterProvider.tsx +++ b/src/pages/Stream/providers/FilterProvider.tsx @@ -160,7 +160,7 @@ const addRuleToGroup = (store: FilterStore, groupId: string) => { ...ruleSet.rules, { id: `rule-${generateRandomId(6)}`, field: fields[0].name, value: '', operator: '=' }, ], - }; + }; }), }, }; @@ -297,24 +297,24 @@ const setFields = (_store: FilterStore, schema: LogStreamSchemaData) => { const toggleSaveFiltersModal = (_store: FilterStore, val: boolean) => { return { - isSaveFiltersModalOpen: val - } -} + isSaveFiltersModalOpen: val, + }; +}; const toggleSavedFiltersModal = (_store: FilterStore, val: boolean) => { return { - isSavedFiltersModalOpen: val - } -} + isSavedFiltersModalOpen: val, + }; +}; const applySavedFilters = (store: FilterStore, query: QueryType) => { return { ...store, appliedQuery: query, query, - isSumbitDisabled: true - } -} + isSumbitDisabled: true, + }; +}; const filterStoreReducers: FilterStoreReducers = { storeAppliedQuery, @@ -330,7 +330,7 @@ const filterStoreReducers: FilterStoreReducers = { toggleSubmitBtn, toggleSaveFiltersModal, toggleSavedFiltersModal, - applySavedFilters + applySavedFilters, }; export { FilterProvider, useFilterStore, filterStoreReducers }; diff --git a/src/pages/Stream/providers/LogsProvider.tsx b/src/pages/Stream/providers/LogsProvider.tsx index 42e487d9..7b9649ae 100644 --- a/src/pages/Stream/providers/LogsProvider.tsx +++ b/src/pages/Stream/providers/LogsProvider.tsx @@ -359,7 +359,7 @@ const setTimeRange = ( return { ...cleanStore, timeRange: { ...store.timeRange, startTime: startTime.toDate(), endTime: endTime.toDate(), label, interval, type }, - viewMode: store.viewMode + viewMode: store.viewMode, }; }; @@ -501,7 +501,7 @@ const filterAndSortData = ( return doesMatch ? [...acc, d] : acc; }, [], - ) as Log[]); + ) as Log[]); const sortedData = _.orderBy(filteredData, [sortKey], [sortOrder]); return sortedData; }; @@ -522,7 +522,7 @@ const searchAndSortData = (opts: { searchValue: string }, data: Log[]) => { return doesMatch ? [...acc, d] : acc; }, [], - ) as Log[]); + ) as Log[]); const sortedData = _.orderBy(filteredData, [defaultSortKey], [defaultSortOrder]); return sortedData; }; @@ -871,7 +871,10 @@ const toggleSideBar = (store: LogsStore) => { const onToggleView = (store: LogsStore, viewMode: 'json' | 'table') => { const { data, tableOpts } = store; - const filteredData = filterAndSortData({ sortOrder: defaultSortOrder, sortKey: defaultSortKey, filters: {} }, data.rawData); + const filteredData = filterAndSortData( + { sortOrder: defaultSortOrder, sortKey: defaultSortKey, filters: {} }, + data.rawData, + ); const currentPage = tableOpts.currentPage; const newPageSlice = getPageSlice(currentPage, tableOpts.perPage, filteredData); @@ -888,7 +891,7 @@ const onToggleView = (store: LogsStore, viewMode: 'json' | 'table') => { currentPage, totalPages: getTotalPages(filteredData, tableOpts.perPage), }, - viewMode + viewMode, }; }; diff --git a/src/pages/Stream/providers/StreamProvider.tsx b/src/pages/Stream/providers/StreamProvider.tsx index 10a7608e..df9ec3a0 100644 --- a/src/pages/Stream/providers/StreamProvider.tsx +++ b/src/pages/Stream/providers/StreamProvider.tsx @@ -121,7 +121,7 @@ const initialState: StreamStore = { info: {}, sideBarOpen: false, cacheEnabled: null, - hotTier: {} + hotTier: {}, }; const { Provider: StreamProvider, useStore: useStreamStore } = initContext(initialState); @@ -132,15 +132,15 @@ const streamChangeCleanup = (store: StreamStore) => { const toggleSideBar = (store: StreamStore) => { return { - sideBarOpen: !store.sideBarOpen - } -} + sideBarOpen: !store.sideBarOpen, + }; +}; const setCacheEnabled = (_store: StreamStore, enabled: boolean) => { return { - cacheEnabled: enabled - } -} + cacheEnabled: enabled, + }; +}; const parseType = (type: any): 'text' | 'number' => { if (typeof type === 'object') { @@ -213,15 +213,15 @@ const setRetention = (_store: StreamStore, retention: { duration?: string; descr const setStreamInfo = (_store: StreamStore, infoResponse: AxiosResponse) => { return { - info: infoResponse.data - } -} + info: infoResponse.data, + }; +}; const setHotTier = (_store: StreamStore, hotTier: HotTierConfig) => { return { - hotTier - } -} + hotTier, + }; +}; const operatorLabelMap = { lessThanEquals: '<=', @@ -338,7 +338,7 @@ const streamStoreReducers: LogsStoreReducers = { toggleSideBar, setCacheEnabled, setStreamInfo, - setHotTier + setHotTier, }; export { StreamProvider, useStreamStore, streamStoreReducers }; diff --git a/src/pages/Stream/utils.ts b/src/pages/Stream/utils.ts index 46da868d..a709934d 100644 --- a/src/pages/Stream/utils.ts +++ b/src/pages/Stream/utils.ts @@ -1,6 +1,6 @@ -import { Log } from "@/@types/parseable/api/query"; -import { LogStreamSchemaData } from "@/@types/parseable/api/stream"; -import { columnsToSkip } from "./providers/LogsProvider"; +import { Log } from '@/@types/parseable/api/query'; +import { LogStreamSchemaData } from '@/@types/parseable/api/stream'; +import { columnsToSkip } from './providers/LogsProvider'; export const getPageSlice = (page = 1, perPage: number, data: Log[]) => { const firstPageIndex = (page - 1) * perPage; @@ -20,7 +20,7 @@ export const makeHeadersFromSchema = (schema: LogStreamSchemaData | null): strin export const makeHeadersfromData = (data: Log[]): string[] => { const allKeys: string[] = []; - // cannot parse cust search query and get the possible keys. + // cannot parse cust search query and get the possible keys. // and also its not necessary that each record will have all the specified columns // so go through all the records and get the keys data.forEach((obj) => { @@ -34,8 +34,13 @@ export const makeHeadersfromData = (data: Log[]): string[] => { return allKeys; }; -export const genColumnsToShow = (opts: {disabledColumns: string[], headers: string[], isPinned: boolean, pinnedColumns: string[]}) => { - const {disabledColumns, headers, isPinned, pinnedColumns} = opts; +export const genColumnsToShow = (opts: { + disabledColumns: string[]; + headers: string[]; + isPinned: boolean; + pinnedColumns: string[]; +}) => { + const { disabledColumns, headers, isPinned, pinnedColumns } = opts; const columnsToIgnore = [ ...disabledColumns, @@ -43,4 +48,4 @@ export const genColumnsToShow = (opts: {disabledColumns: string[], headers: stri ...headers.filter((header) => (isPinned ? !pinnedColumns.includes(header) : pinnedColumns.includes(header))), ]; return headers.filter((header) => !columnsToIgnore.includes(header)); -} \ No newline at end of file +}; diff --git a/src/pages/Systems/index.tsx b/src/pages/Systems/index.tsx index b5da814a..ac54dc5a 100644 --- a/src/pages/Systems/index.tsx +++ b/src/pages/Systems/index.tsx @@ -5,8 +5,8 @@ import Cluster from './Cluster'; import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider'; const Systems: FC = () => { - const { getAboutIsLoading, getAboutIsError} = useAbout(); - const [isStandAloneMode] = useAppStore(store => store.isStandAloneMode) + const { getAboutIsLoading, getAboutIsError } = useAbout(); + const [isStandAloneMode] = useAppStore((store) => store.isStandAloneMode); if (getAboutIsLoading || getAboutIsError || isStandAloneMode !== false) return null; return ( diff --git a/src/pages/Systems/utils.ts b/src/pages/Systems/utils.ts index 227def60..7ea67e0b 100644 --- a/src/pages/Systems/utils.ts +++ b/src/pages/Systems/utils.ts @@ -1,4 +1,4 @@ -import { HumanizeNumber, formatBytes } from "@/utils/formatBytes"; +import { HumanizeNumber, formatBytes } from '@/utils/formatBytes'; interface Label { [key: string]: string; @@ -83,9 +83,14 @@ export type SanitizedMetrics = { }; export const sanitizeIngestorData = (prometheusResponse: PrometheusMetricResponse): SanitizedMetrics | null => { - const {parseable_events_ingested, parseable_staging_files, parseable_storage_size, process_resident_memory_bytes} = prometheusResponse - const streamWiseDataStorage = Array.isArray(parseable_storage_size) ? parseable_storage_size.filter((d) => d.type === 'data') : [] - const streamWiseStagingStorage = Array.isArray(parseable_storage_size) ? parseable_storage_size.filter((d) => d.type === 'staging') : [] + const { parseable_events_ingested, parseable_staging_files, parseable_storage_size, process_resident_memory_bytes } = + prometheusResponse; + const streamWiseDataStorage = Array.isArray(parseable_storage_size) + ? parseable_storage_size.filter((d) => d.type === 'data') + : []; + const streamWiseStagingStorage = Array.isArray(parseable_storage_size) + ? parseable_storage_size.filter((d) => d.type === 'staging') + : []; const totalEventsIngested = parseStreamDataMetrics(parseable_events_ingested); const totalBytesIngested = parseStreamDataMetrics(streamWiseDataStorage); const stagingFilesCount = parseStreamDataMetrics(parseable_staging_files); @@ -98,4 +103,4 @@ export const sanitizeIngestorData = (prometheusResponse: PrometheusMetricRespons stagingFilesCount: HumanizeNumber(stagingFilesCount), stagingSize: formatBytes(stagingSize), }; -}; \ No newline at end of file +}; diff --git a/src/routes/AccessSpecificRoute.tsx b/src/routes/AccessSpecificRoute.tsx index 0ffd9fe4..5f1f53ad 100644 --- a/src/routes/AccessSpecificRoute.tsx +++ b/src/routes/AccessSpecificRoute.tsx @@ -11,7 +11,7 @@ const AccessSpecificRoute: FC = (props) => { const { accessRequired } = props; const navigate = useNavigate(); - const [streamSpecificUserAccess] = useAppStore(store => store.streamSpecificUserAccess) + const [streamSpecificUserAccess] = useAppStore((store) => store.streamSpecificUserAccess); useEffect(() => { if ( diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 19c672eb..9fa259b8 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -5,7 +5,7 @@ import { OIDC_NOT_CONFIGURED_ROUTE, USERS_MANAGEMENT_ROUTE, CLUSTER_ROUTE, - STREAM_ROUTE + STREAM_ROUTE, } from '@/constants/routes'; import FullPageLayout from '@/layouts/FullPageLayout'; import NotFound from '@/pages/Errors/NotFound'; diff --git a/src/utils/formatBytes.ts b/src/utils/formatBytes.ts index 7ceeb451..47882a9b 100644 --- a/src/utils/formatBytes.ts +++ b/src/utils/formatBytes.ts @@ -49,9 +49,9 @@ export const calcCompressionRate = (storageSize: string, ingestionSize: string) if (parsedIngestionSize === 0) return '0%'; - const rate = (100 - (parsedStorageSize / parsedIngestionSize) * 100) - + const rate = 100 - (parsedStorageSize / parsedIngestionSize) * 100; + if (rate <= 0) return '0%'; return `${rate.toPrecision(4)}%`; -}; \ No newline at end of file +}; diff --git a/src/utils/initContext.tsx b/src/utils/initContext.tsx index 043fa2ae..3624c1f2 100644 --- a/src/utils/initContext.tsx +++ b/src/utils/initContext.tsx @@ -53,10 +53,10 @@ export default function initContext(initialState: Store) { const setStore = useCallback( (updateFn: (store: Store) => Partial) => { - store.set(updateFn(store.get())); + store.set(updateFn(store.get())); }, [store], - ); + ); return [state, setStore]; } diff --git a/src/utils/notification.ts b/src/utils/notification.ts index 69e289e5..0d809935 100644 --- a/src/utils/notification.ts +++ b/src/utils/notification.ts @@ -1,8 +1,8 @@ -import type { NotificationData } from '@mantine/notifications'; +import type { NotificationData } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications'; export const notifyError = (payload?: NotificationData) => { - const title = payload?.title || 'Oops!'; + const title = payload?.title || 'Oops!'; const message = payload?.message || 'Something went wrong!.'; const color = payload?.color || 'red'; const autoClose = payload?.autoClose || 3000; @@ -12,7 +12,7 @@ export const notifyError = (payload?: NotificationData) => { message, color, autoClose, - }) + }); }; export const notifySuccess = (payload?: NotificationData) => { @@ -26,8 +26,8 @@ export const notifySuccess = (payload?: NotificationData) => { message, color, autoClose, - }) -}; + }); +}; export const notify = (payload: NotificationData) => { const color = payload.color || 'green'; @@ -37,4 +37,4 @@ export const notify = (payload: NotificationData) => { color, autoClose, }); -}; \ No newline at end of file +}; diff --git a/src/utils/sanitiseSqlString.ts b/src/utils/sanitiseSqlString.ts index e070b652..ca1d6a38 100644 --- a/src/utils/sanitiseSqlString.ts +++ b/src/utils/sanitiseSqlString.ts @@ -2,22 +2,22 @@ import { notify } from './notification'; import { LOAD_LIMIT } from '@/pages/Stream/providers/LogsProvider'; export const sanitiseSqlString = (sqlString: string): string => { - const withoutComments = sqlString.replace(/--.*$/gm, ''); - const withoutNewLines = withoutComments.replace(/\n/g, ' '); - const withoutTrailingSemicolon = withoutNewLines.replace(/;/g, '').trim(); - const limitRegex = /limit\s+(\d+)/i; + const withoutComments = sqlString.replace(/--.*$/gm, ''); + const withoutNewLines = withoutComments.replace(/\n/g, ' '); + const withoutTrailingSemicolon = withoutNewLines.replace(/;/g, '').trim(); + const limitRegex = /limit\s+(\d+)/i; - if (limitRegex.test(withoutTrailingSemicolon)) { - return withoutTrailingSemicolon.replace(limitRegex, (match, p1) => { - const currentLimit = parseInt(p1, 10); - if (currentLimit > LOAD_LIMIT) { - notify({ message: `Limit exceeds the default load limit. Replacing with default limit - ${LOAD_LIMIT}` }); - return `LIMIT ${LOAD_LIMIT}`; - } - return match; - }); - } + if (limitRegex.test(withoutTrailingSemicolon)) { + return withoutTrailingSemicolon.replace(limitRegex, (match, p1) => { + const currentLimit = parseInt(p1, 10); + if (currentLimit > LOAD_LIMIT) { + notify({ message: `Limit exceeds the default load limit. Replacing with default limit - ${LOAD_LIMIT}` }); + return `LIMIT ${LOAD_LIMIT}`; + } + return match; + }); + } - notify({ message: `Default limit used i.e - ${LOAD_LIMIT}` }); - return `${withoutTrailingSemicolon} LIMIT ${LOAD_LIMIT}`; -}; \ No newline at end of file + notify({ message: `Default limit used i.e - ${LOAD_LIMIT}` }); + return `${withoutTrailingSemicolon} LIMIT ${LOAD_LIMIT}`; +};