-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
pr05 Typescript #3: Migrate client/utils folder #3553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
a52d312
2480bd1
87adc72
9efdd25
462524c
8010af7
cb9ddc5
f7282c2
411eb4a
e7eaa2c
53962db
3efc164
fa6d69f
75b35a3
b7fb7a0
2440d6f
0a9af47
5302f54
2638c32
723cac3
e0cb6c7
0aab549
60f8a6e
04ca29a
e91000f
0713173
16d84e1
6957124
97754db
ed0c6f0
0b223df
a52372d
de6fc10
8061e09
058d155
34f0735
c6c7d40
2362807
1f5614c
8febdcb
a9d954f
50eab48
87d9c0d
e387df2
c4af496
c67d841
589318b
5f2d878
7421ef9
5de3876
2cc486a
c92d53e
0418d8c
7173d5d
02428a0
15cabf8
bbeac90
fcc9a4a
919ab3b
de0f4da
482fb18
640a0bb
8b3fee5
6de4d6d
0ad638f
c832736
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ import objectID from 'bson-objectid'; | |
import each from 'async/each'; | ||
import { isEqual } from 'lodash'; | ||
import browserHistory from '../../../browserHistory'; | ||
import apiClient from '../../../utils/apiClient'; | ||
import getConfig from '../../../utils/getConfig'; | ||
import { apiClient } from '../../../utils/apiClient'; | ||
import { getConfig } from '../../../utils/getConfig'; | ||
import * as ActionTypes from '../../../constants'; | ||
import { showToast, setToastText } from './toast'; | ||
import { | ||
|
@@ -15,9 +15,11 @@ import { | |
} from './ide'; | ||
import { clearState, saveState } from '../../../persistState'; | ||
|
||
const ROOT_URL = getConfig('API_URL'); | ||
const S3_BUCKET_URL_BASE = getConfig('S3_BUCKET_URL_BASE'); | ||
const S3_BUCKET = getConfig('S3_BUCKET'); | ||
const ROOT_URL = getConfig('API_URL', { throwErrorIfNotFound: true }); | ||
const S3_BUCKET_URL_BASE = getConfig('S3_BUCKET_URL_BASE', { | ||
throwErrorIfNotFound: true | ||
}); | ||
const S3_BUCKET = getConfig('S3_BUCKET', { throwErrorIfNotFound: true }); | ||
|
||
export function setProject(project) { | ||
return { | ||
|
@@ -307,6 +309,8 @@ export function cloneProject(project) { | |
(file, callback) => { | ||
if ( | ||
file.url && | ||
S3_BUCKET && | ||
S3_BUCKET_URL_BASE && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this check for safety because I think
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good call!! |
||
(file.url.includes(S3_BUCKET_URL_BASE) || | ||
file.url.includes(S3_BUCKET)) | ||
) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import prettyBytes from 'pretty-bytes'; | ||
import { getConfig } from '../../../utils/getConfig'; | ||
import { parseNumber } from '../../../utils/parseStringToType'; | ||
|
||
import getConfig from '../../../utils/getConfig'; | ||
|
||
const limit = getConfig('UPLOAD_LIMIT') || 250000000; | ||
const limit = parseNumber(getConfig('UPLOAD_LIMIT')) || 250000000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Currently this file is still jsx so it would be ok to use the string version of this number, but it's not as safe |
||
const MAX_SIZE_B = limit; | ||
|
||
const formatPercent = (percent) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@khanniie what do you think of this update?
getConfig
options
param now hasthrowErrorIfNotFound
, which throws and error if the value is not found (or is an empty string)This allows the compiler to throw errors immediately when attempting a local build if these things are missing
I've done a search for all instances where
getConfig
is used and made a guess of what I think would be useful to fail at compile-time if the config variable doesn't exist, but this is totally a guess