Skip to content

Commit

Permalink
[#2643] refactor: Replace TypeScript with JavaScript in the web (#3728)
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

This pull request replaces TypeScript with JavaScript in the web
directory. Key changes include:

- Converted files in `web/types` from TypeScript to JavaScript.
- Converted files in `web/lib/enums` from TypeScript to JavaScript.
- Converted files in `web/lib/utils/axios` from TypeScript to
JavaScript.
- Updated `web/src/components/ColumnTypeChip.js` to ensure it conforms
to JavaScript standards.
- Replaced `web/tsconfig.json` with `web/jsconfig.json`.

### Why are the changes needed?

These changes are needed to maintain consistency in the frontend
codebase by using JavaScript instead of TypeScript. This helps to:

1. Simplify the development process by using a single language
(JavaScript) for the frontend.
2. Reduce complexity and potential issues arising from maintaining both
TypeScript and JavaScript files.

Fix: #2643

### Does this PR introduce _any_ user-facing change?

No, this PR does not introduce any user-facing changes. It only involves
internal code refactoring.

### How was this patch tested?

This patch was tested by:
1. Running the existing unit and integration tests to ensure that all
functionalities work as expected.
2. Manually verifying that the application builds and runs without
errors after the refactor.
3. Ensuring that all references and imports in the converted files are
correctly updated.

---------

Co-authored-by: LanceLin <[email protected]>
  • Loading branch information
LanceHsun and LanceLin authored Jun 14, 2024
1 parent 81e373d commit e34c825
Show file tree
Hide file tree
Showing 18 changed files with 374 additions and 337 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ tasks.rat {
"web/dist/**/*",
"web/node_modules/**/*",
"web/src/lib/utils/axios/**/*",
"web/src/lib/enums/httpEnum.ts",
"web/src/lib/enums/httpEnum.js",
"web/src/types/axios.d.ts",
"web/yarn.lock",
"web/package-lock.json",
Expand Down
3 changes: 1 addition & 2 deletions web/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,5 @@

Vben
./src/lib/utils/axios
./src/types/axios.d.ts
./src/lib/enums/httpEnum.ts
./src/lib/enums/httpEnum.js
./src/lib/utils/index.js (parts of)
3 changes: 1 addition & 2 deletions web/LICENSE.bin
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@

Vben
./web/lib/utils/axios
./web/types/axios.d.ts
./web/lib/enums/httpEnum.ts
./web/lib/enums/httpEnum.js
./web/lib/utils/index.js (parts of)

@aashutoshrathi/word-wrap
Expand Down
22 changes: 4 additions & 18 deletions web/tsconfig.json → web/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
{
"compilerOptions": {
"paths": {
"@/*": [
"./src/*"
]
"@/*": ["./src/*"]
},
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
Expand All @@ -27,14 +21,6 @@
}
]
},
"include": [
"next-env.d.ts",
"dist/ui/types/**/*.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
"include": ["next-env.d.ts", "dist/ui/types/**/*.js", "**/*.js", "**/*.jsx", ".next/types/**/*.js"],
"exclude": ["node_modules"]
}
2 changes: 1 addition & 1 deletion web/src/components/ColumnTypeChip.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { Chip } from '@mui/material'
import { ColumnTypeColorEnum } from '@/lib/enums/columnTypeEnum'
import { ColumnTypeColorEnum } from '@/lib/enums/columnTypeEnum.js'
import colors from '@/lib/theme/colors'
import { alpha } from '@/lib/utils/color'
import { isString } from 'lodash-es'
Expand Down
35 changes: 35 additions & 0 deletions web/src/lib/enums/columnTypeEnum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/

/**
* @enum {string}
*/
const ColumnTypeColorEnum = Object.freeze({
boolean: 'primary',
short: 'primary',
integer: 'primary',
long: 'primary',
float: 'primary',
double: 'primary',
decimal: 'primary',
fixed: 'primary',

date: 'info',
time: 'info',
timestamp: 'info',
timestamp_tz: 'info',
interval_day: 'info',
interval_year: 'info',

string: 'warning',
char: 'warning',
varchar: 'warning',

byte: 'success',
uuid: 'success',
binary: 'success'
})

export { ColumnTypeColorEnum }
30 changes: 0 additions & 30 deletions web/src/lib/enums/columnTypeEnum.ts

This file was deleted.

49 changes: 28 additions & 21 deletions web/src/lib/enums/httpEnum.ts → web/src/lib/enums/httpEnum.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,35 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
*/

/**
* @enum {string}
*/
const ContentTypeEnum = Object.freeze({
JSON: 'application/json;charset=UTF-8',
FORM_URLENCODED: 'application/x-www-form-urlencoded;charset=UTF-8',
FORM_DATA: 'multipart/form-data;charset=UTF-8'
})

/**
* Referred from src/enums/httpEnum.ts
* @enum {string}
*/
const RequestEnum = Object.freeze({
GET: 'GET',
POST: 'POST',
PUT: 'PUT',
DELETE: 'DELETE'
})

export enum ContentTypeEnum {
JSON = 'application/json;charset=UTF-8',
FORM_URLENCODED = 'application/x-www-form-urlencoded;charset=UTF-8',
FORM_DATA = 'multipart/form-data;charset=UTF-8'
}

export enum RequestEnum {
GET = 'GET',
POST = 'POST',
PUT = 'PUT',
DELETE = 'DELETE'
}

export enum ResultEnum {
SUCCESS = 0,
ERROR = -1,
TIMEOUT = 401,
TYPE = 'success'
}
/**
* @enum {number|string}
*/
const ResultEnum = Object.freeze({
SUCCESS: 0,
ERROR: -1,
TIMEOUT: 401,
TYPE: 'success'
})

export { ContentTypeEnum, RequestEnum, ResultEnum }
Loading

0 comments on commit e34c825

Please sign in to comment.