From f9d1c360e059ed07909abd7bc83a61fcd3e2746d Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 31 Jan 2022 18:37:28 -0300 Subject: [PATCH] 17914: Replaces deprecated substr() with substring(). Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/common/app-info.ts | 2 +- src/common/url.ts | 2 +- src/routes/routes.ts | 2 +- src/services/api/url-builder.ts | 4 ++-- src/services/auth-service/auth-service.ts | 2 +- src/store/auth/auth-action-session.ts | 2 +- src/store/auth/auth-reducer.ts | 4 ++-- src/views-components/data-explorer/renderers.tsx | 4 ++-- src/views-components/main-app-bar/account-menu.tsx | 2 +- src/views/link-account-panel/link-account-panel-root.tsx | 4 ++-- src/views/my-account-panel/my-account-panel-root.tsx | 2 +- src/views/search-results-panel/search-results-panel-view.tsx | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/common/app-info.ts b/src/common/app-info.ts index de6708eb..a6e3af74 100644 --- a/src/common/app-info.ts +++ b/src/common/app-info.ts @@ -7,7 +7,7 @@ export const getBuildInfo = (): string => { return "v" + process.env.REACT_APP_VERSION; } else { const getBuildNumber = "BN-" + (process.env.REACT_APP_BUILD_NUMBER || "dev"); - const getGitCommit = "GIT-" + (process.env.REACT_APP_GIT_COMMIT || "latest").substr(0, 7); + const getGitCommit = "GIT-" + (process.env.REACT_APP_GIT_COMMIT || "latest").substring(0, 7); return getBuildNumber + " / " + getGitCommit; } }; diff --git a/src/common/url.ts b/src/common/url.ts index 6d66778a..db12cb8e 100644 --- a/src/common/url.ts +++ b/src/common/url.ts @@ -13,7 +13,7 @@ export function normalizeURLPath(url: string) { const u = new URL(url); u.pathname = u.pathname.replace(/\/\//, '/'); if (u.pathname[u.pathname.length - 1] === '/') { - u.pathname = u.pathname.substr(0, u.pathname.length - 1); + u.pathname = u.pathname.substring(0, u.pathname.length - 1); } return u.toString(); } diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 528a0376..41c71f7c 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -68,7 +68,7 @@ export const getResourceUrl = (uuid: string) => { export const getNavUrl = (uuid: string, config: FederationConfig) => { const path = getResourceUrl(uuid) || ""; - const cls = uuid.substr(0, 5); + const cls = uuid.substring(0, 5); if (cls === config.localCluster || extractUuidKind(uuid) === ResourceKind.USER || COLLECTION_PDH_REGEX.exec(uuid)) { return path; } else if (config.remoteHostsConfig[cls]) { diff --git a/src/services/api/url-builder.ts b/src/services/api/url-builder.ts index 32039a50..d94aab35 100644 --- a/src/services/api/url-builder.ts +++ b/src/services/api/url-builder.ts @@ -30,13 +30,13 @@ export function joinUrls(url0?: string, url1?: string) { if (url0) { let idx0 = url0.length - 1; while (url0[idx0] === '/') { --idx0; } - u0 = url0.substr(0, idx0 + 1); + u0 = url0.substring(0, idx0 + 1); } let u1 = ""; if (url1) { let idx1 = 0; while (url1[idx1] === '/') { ++idx1; } - u1 = url1.substr(idx1); + u1 = url1.substring(idx1); } let url = u0; if (u1.length > 0) { diff --git a/src/services/auth-service/auth-service.ts b/src/services/auth-service/auth-service.ts index 5b975969..548dbcaa 100644 --- a/src/services/auth-service/auth-service.ts +++ b/src/services/auth-service/auth-service.ts @@ -64,7 +64,7 @@ export class AuthService { this.getStorage().setItem(API_TOKEN_KEY, token); const sp = token.split('/'); if (sp.length === 3) { - this.getStorage().setItem(HOME_CLUSTER, sp[1].substr(0, 5)); + this.getStorage().setItem(HOME_CLUSTER, sp[1].substring(0, 5)); } } diff --git a/src/store/auth/auth-action-session.ts b/src/store/auth/auth-action-session.ts index 2712f136..7e81f2d9 100644 --- a/src/store/auth/auth-action-session.ts +++ b/src/store/auth/auth-action-session.ts @@ -99,7 +99,7 @@ export const getSaltedToken = (clusterId: string, token: string) => { throw new Error(invalidV2Token); } let salted = secret; - if (uuid.substr(0, 5) !== clusterId) { + if (uuid.substring(0, 5) !== clusterId) { shaObj.setHMACKey(secret, "TEXT"); shaObj.update(clusterId); salted = shaObj.getHMAC("HEX"); diff --git a/src/store/auth/auth-reducer.ts b/src/store/auth/auth-reducer.ts index ce836a55..c109acaf 100644 --- a/src/store/auth/auth-reducer.ts +++ b/src/store/auth/auth-reducer.ts @@ -79,12 +79,12 @@ export const authReducer = (services: ServiceRepository) => (state = initialStat apiToken: token, apiTokenExpiration: tokenExpiration, apiTokenLocation: tokenLocation, - homeCluster: user.uuid.substr(0, 5) + homeCluster: user.uuid.substring(0, 5) }), LOGIN: () => state, LOGOUT: () => ({ ...state, apiToken: undefined }), USER_DETAILS_SUCCESS: (user: User) => - ({ ...state, user, homeCluster: user.uuid.substr(0, 5) }), + ({ ...state, user, homeCluster: user.uuid.substring(0, 5) }), SET_SSH_KEYS: (sshKeys: SshKeyResource[]) => ({ ...state, sshKeys }), ADD_SSH_KEY: (sshKey: SshKeyResource) => ({ ...state, sshKeys: state.sshKeys.concat(sshKey) }), diff --git a/src/views-components/data-explorer/renderers.tsx b/src/views-components/data-explorer/renderers.tsx index 901704d9..47c1eaa9 100644 --- a/src/views-components/data-explorer/renderers.tsx +++ b/src/views-components/data-explorer/renderers.tsx @@ -221,7 +221,7 @@ const renderIsHidden = (props: { permissionLinkUuid: string, visible: boolean, canManage: boolean, - setMemberIsHidden: (memberLinkUuid: string, permissionLinkUuid: string, hide: boolean) => void + setMemberIsHidden: (memberLinkUuid: string, permissionLinkUuid: string, hide: boolean) => void }) => { if (props.memberLinkUuid) { return { const CLUSTER_ID_LENGTH = 5; const pos = props.uuid.length > CLUSTER_ID_LENGTH ? props.uuid.indexOf('-') : 5; - const clusterId = pos >= CLUSTER_ID_LENGTH ? props.uuid.substr(0, pos) : ''; + const clusterId = pos >= CLUSTER_ID_LENGTH ? props.uuid.substring(0, pos) : ''; const ci = pos >= CLUSTER_ID_LENGTH ? ((((( (props.uuid.charCodeAt(0) * props.uuid.charCodeAt(1)) + props.uuid.charCodeAt(2)) diff --git a/src/views-components/main-app-bar/account-menu.tsx b/src/views-components/main-app-bar/account-menu.tsx index 9356e077..7faf27c2 100644 --- a/src/views-components/main-app-bar/account-menu.tsx +++ b/src/views-components/main-app-bar/account-menu.tsx @@ -90,7 +90,7 @@ export const AccountMenuComponent = title="Account Management" key={currentRoute}> - {getUserDisplayName(user)} {user.uuid.substr(0, 5) !== localCluster && `(${user.uuid.substr(0, 5)})`} + {getUserDisplayName(user)} {user.uuid.substring(0, 5) !== localCluster && `(${user.uuid.substring(0, 5)})`} {user.isActive && accountMenuItems} diff --git a/src/views/link-account-panel/link-account-panel-root.tsx b/src/views/link-account-panel/link-account-panel-root.tsx index eb52ba18..c5c86eb2 100644 --- a/src/views/link-account-panel/link-account-panel-root.tsx +++ b/src/views/link-account-panel/link-account-panel-root.tsx @@ -55,7 +55,7 @@ function displayUser(user: UserResource, showCreatedAt: boolean = false, showClu const disp: JSX.Element[] = []; disp.push({user.email} ({user.username}, {user.uuid})); if (showCluster) { - const homeCluster = user.uuid.substr(0, 5); + const homeCluster = user.uuid.substring(0, 5); disp.push( hosted on cluster {homeCluster} and ); } if (showCreatedAt) { @@ -134,7 +134,7 @@ export const LinkAccountPanelRoot = withStyles(styles)( This a remote account. You can link a local Arvados account to this one. After linking, you can access the local account's data by logging into the {localCluster} cluster as user {targetUser.email} - from {targetUser.uuid.substr(0, 5)}. + from {targetUser.uuid.substring(0, 5)}.