Skip to content

Commit

Permalink
fix type errors for LogType usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziinc authored and joshenlim committed Feb 15, 2022
1 parent b4e0fbb commit b012a92
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions studio/components/interfaces/Settings/Logs/Logs.constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LogTemplate, LogType } from '.'
import { LogTemplate } from '.'

export const TEMPLATES: LogTemplate[] = [
{
Expand Down Expand Up @@ -57,7 +57,7 @@ ORDER BY
},
]

export const LOG_TYPE_LABEL_MAPPING: { [k: LogType]: string } = {
export const LOG_TYPE_LABEL_MAPPING: { [k: string]: string } = {
api: 'API',
database: 'Database',
}
2 changes: 1 addition & 1 deletion studio/components/interfaces/Settings/Logs/Logs.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface LogData {
export interface LogTemplate {
label?: string
mode: 'custom' | 'simple'
for?: LogType[]
for?: string[]
searchString: string
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { LogType, LOG_TYPE_LABEL_MAPPING } from 'components/interfaces/Settings/Logs'
import { LOG_TYPE_LABEL_MAPPING } from 'components/interfaces/Settings/Logs'
import { ProductMenuGroup } from 'components/ui/ProductMenu/ProductMenu.types'

export const generateSettingsMenu = (ref: string): ProductMenuGroup[] => {
const logTypes: LogType[] = ['database', 'api']
const logTypes: string[] = ['database', 'api']

return [
{
Expand Down
5 changes: 2 additions & 3 deletions studio/pages/project/[ref]/settings/logs/[type].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
TEMPLATES,
LogData,
LogSearchCallback,
LogType,
LOG_TYPE_LABEL_MAPPING,
} from 'components/interfaces/Settings/Logs'
import { uuidv4 } from 'lib/helpers'
Expand Down Expand Up @@ -66,7 +65,7 @@ export const LogPage: NextPage = () => {
timestamp_start: '',
timestamp_end: '',
})
const title = `Logs - ${LOG_TYPE_LABEL_MAPPING[type as LogType]}`
const title = `Logs - ${LOG_TYPE_LABEL_MAPPING[type as keyof typeof LOG_TYPE_LABEL_MAPPING]}`
const checkIfSelectQuery = (value: string) =>
value.toLowerCase().includes('select') ? true : false
const isSelectQuery = checkIfSelectQuery(editorValue)
Expand Down Expand Up @@ -248,7 +247,7 @@ export const LogPage: NextPage = () => {
isCustomQuery={mode === 'custom'}
isLoading={isValidating}
newCount={newCount}
templates={TEMPLATES.filter((template) => template.for?.includes(type as LogType))}
templates={TEMPLATES.filter((template) => template.for?.includes(type as string))}
onRefresh={handleRefresh}
onSearch={handleSearch}
defaultSearchValue={params.search_query}
Expand Down

0 comments on commit b012a92

Please sign in to comment.