Skip to content

Commit

Permalink
eslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vivek-devtron committed Feb 12, 2024
1 parent f208ef4 commit 6e33708
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 85 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ src/Common/Dialogs/ForceDeleteDialog.tsx
src/Common/DraggableWrapper/DraggableButton.tsx
src/Common/DraggableWrapper/DraggableWrapper.tsx
src/Common/Drawer/Drawer.tsx
src/Common/EmptyState/EmptyState.tsx
src/Common/EmptyState/GenericEmptyState.tsx
src/Common/Error.tsx
src/Common/ErrorScreenNotFound.tsx
Expand Down
13 changes: 5 additions & 8 deletions src/Common/Api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MutableRefObject } from 'react'
import { ServerErrors } from './ServerError'
import { FALLBACK_REQUEST_TIMEOUT, Host, URLS } from './Constants'
import { ResponseType, APIOptions } from './Types'
import { MutableRefObject } from 'react'

const responseMessages = {
100: 'Continue',
Expand Down Expand Up @@ -76,9 +76,7 @@ const responseMessages = {

function handleLogout() {
const continueParam = `${window.location.pathname.replace(window.__BASE_URL__, '')}${window.location.search}`
window.location.href = `${window.location.origin}${window.__BASE_URL__}${
URLS.LOGIN_SSO
}?continue=${continueParam}`
window.location.href = `${window.location.origin}${window.__BASE_URL__}${URLS.LOGIN_SSO}?continue=${continueParam}`
}

async function handleServerError(contentType, response) {
Expand Down Expand Up @@ -225,14 +223,13 @@ export const put = (url: string, data: object, options?: APIOptions): Promise<Re

export const get = (url: string, options?: APIOptions): Promise<ResponseType> => fetchInTime(url, 'GET', null, options)

export const trash = (url: string, data?: object, options?: APIOptions): Promise<ResponseType> => {
return fetchInTime(url, 'DELETE', data, options)
}
export const trash = (url: string, data?: object, options?: APIOptions): Promise<ResponseType> =>
fetchInTime(url, 'DELETE', data, options)

/**
* Aborts the previous request before triggering next request
*/
export const abortPreviousRequests = <T,>(
export const abortPreviousRequests = <T>(
callback: () => Promise<T>,
abortControllerRef: MutableRefObject<AbortController>,
): Promise<T> => {
Expand Down
32 changes: 16 additions & 16 deletions src/Common/Helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -585,19 +585,19 @@ export const customStyles = {
}),
}

export const getFilteredChartVersions = (charts, selectedChartType) => {
// Filter chart versions based on selected chart type
return charts
.filter((item) => item?.chartType === selectedChartType.value)
.map((item) => ({
value: item?.chartVersion,
label: item?.chartVersion,
chartRefId: item.chartRefId,
}))
}
export const getFilteredChartVersions = (charts, selectedChartType) =>
// Filter chart versions based on selected chart type
charts
.filter((item) => item?.chartType === selectedChartType.value)
.map((item) => ({
value: item?.chartVersion,
label: item?.chartVersion,
chartRefId: item.chartRefId,
}))

function removeEmptyObjectKeysAndNullValues(obj, originaljsonCopy) {
// It recursively removes empty object keys and empty array keys
for (let key in obj) {
for (const key in obj) {
if (Array.isArray(obj[key])) {
// Check if the array is empty
if (obj[key].length !== 0) {
Expand Down Expand Up @@ -629,18 +629,18 @@ export function getUnlockedJSON(json, jsonPathArray, removeParentKeysAndEmptyArr

const jsonCopy = JSON.parse(JSON.stringify(json))
const originaljsonCopy = JSON.parse(JSON.stringify(json))
let removedPatches = []
let patches = jsonPathArray.flatMap((jsonPath) => {
const removedPatches = []
const patches = jsonPathArray.flatMap((jsonPath) => {
const pathsToRemove = JSONPath({ path: jsonPath, json: jsonCopy, resultType: 'all' })
//reversing patches to handle correct array index deletion
// reversing patches to handle correct array index deletion
pathsToRemove.reverse()
return pathsToRemove.map((result) => {
//storing removed patches to have functionality of undo
// storing removed patches to have functionality of undo
removedPatches.push({ op: 'add', path: result.pointer, value: result.value })
return { op: 'remove', path: result.pointer }
})
})
let newDocument = jsonpatch.applyPatch(jsonCopy, patches).newDocument
const { newDocument } = jsonpatch.applyPatch(jsonCopy, patches)
if (removeParentKeysAndEmptyArrays) removeEmptyObjectKeysAndNullValues(newDocument, originaljsonCopy)
return { newDocument, removedPatches: removedPatches.reverse() }
}
Expand Down
114 changes: 55 additions & 59 deletions src/Common/RJSF/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,65 +13,61 @@ export const translateString = (stringToTranslate: TranslatableString, params?:
}
}

export const getCommonSelectStyle = (styleOverrides = {}) => {
return {
menuList: (base) => ({
...base,
paddingTop: 0,
paddingBottom: 0,
cursor: 'pointer',
}),
control: (base, state) => ({
...base,
minHeight: '32px',
boxShadow: 'none',
backgroundColor: 'var(--N50)',
border: state.isFocused ? '1px solid var(--B500)' : '1px solid var(--N200)',
cursor: 'pointer',
}),
option: (base, state) => ({
...base,
color: 'var(--N900)',
backgroundColor: state.isFocused ? 'var(--N100)' : 'white',
padding: '10px 12px',
cursor: 'pointer',
}),
dropdownIndicator: (base, state) => ({
...base,
color: 'var(--N400)',
padding: '0 8px',
transition: 'all .2s ease',
transform: state.selectProps.menuIsOpen ? 'rotate(180deg)' : 'rotate(0deg)',
}),
valueContainer: (base, state) => ({
...base,
padding: '0 8px',
fontWeight: '400',
color: state.selectProps.menuIsOpen ? 'var(--N500)' : base.color,
}),
loadingMessage: (base) => ({
...base,
color: 'var(--N600)',
}),
noOptionsMessage: (base) => ({
...base,
color: 'var(--N600)',
}),
multiValue: (base, state) => {
return {
...base,
border: `1px solid var(--N200)`,
borderRadius: `4px`,
background: 'white',
height: '28px',
marginRight: '8px',
padding: '2px',
fontSize: '12px',
}
},
...styleOverrides,
}
}
export const getCommonSelectStyle = (styleOverrides = {}) => ({
menuList: (base) => ({
...base,
paddingTop: 0,
paddingBottom: 0,
cursor: 'pointer',
}),
control: (base, state) => ({
...base,
minHeight: '32px',
boxShadow: 'none',
backgroundColor: 'var(--N50)',
border: state.isFocused ? '1px solid var(--B500)' : '1px solid var(--N200)',
cursor: 'pointer',
}),
option: (base, state) => ({
...base,
color: 'var(--N900)',
backgroundColor: state.isFocused ? 'var(--N100)' : 'white',
padding: '10px 12px',
cursor: 'pointer',
}),
dropdownIndicator: (base, state) => ({
...base,
color: 'var(--N400)',
padding: '0 8px',
transition: 'all .2s ease',
transform: state.selectProps.menuIsOpen ? 'rotate(180deg)' : 'rotate(0deg)',
}),
valueContainer: (base, state) => ({
...base,
padding: '0 8px',
fontWeight: '400',
color: state.selectProps.menuIsOpen ? 'var(--N500)' : base.color,
}),
loadingMessage: (base) => ({
...base,
color: 'var(--N600)',
}),
noOptionsMessage: (base) => ({
...base,
color: 'var(--N600)',
}),
multiValue: (base, state) => ({
...base,
border: `1px solid var(--N200)`,
borderRadius: `4px`,
background: 'white',
height: '28px',
marginRight: '8px',
padding: '2px',
fontSize: '12px',
}),
...styleOverrides,
})

/**
* Returns the redirection props for a url
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ export interface EdgeEndNodeType extends EdgeNodeType {

/**
* Search params for sorting configuration
*
*
* Note: Either both sortOrder and sortBy are required or none
*/
export type SortingParams<T = string> =
Expand Down

0 comments on commit 6e33708

Please sign in to comment.