From 88dff819c945de2f77d4f2726c187a56b61bab3a Mon Sep 17 00:00:00 2001 From: Tan Nhu Date: Mon, 22 Aug 2022 16:44:07 -0700 Subject: [PATCH] Clean up unused files --- web/src/App.tsx | 24 ++--- web/src/AppProps.ts | 3 - web/src/RouteDestinations.tsx | 2 - web/src/bootstrap.tsx | 9 +- web/src/pages/Login/Login.tsx | 116 --------------------- web/src/pages/Login/login.module.scss | 62 ----------- web/src/pages/Login/login.module.scss.d.ts | 18 ---- 7 files changed, 12 insertions(+), 222 deletions(-) delete mode 100644 web/src/pages/Login/Login.tsx delete mode 100644 web/src/pages/Login/login.module.scss delete mode 100644 web/src/pages/Login/login.module.scss.d.ts diff --git a/web/src/App.tsx b/web/src/App.tsx index 68bdf7ff9..b18f06ac4 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -16,18 +16,16 @@ import { StringsContextProvider } from './framework/strings/StringsContextProvid FocusStyleManager.onlyShowFocusOnTabs() -const App: React.FC = props => { - const { - standalone = false, - accountId = '', - baseRoutePath = '', - lang = 'en', - apiToken, - on401 = handle401, - children, - hooks = {}, - components = {} - } = props +const App: React.FC = ({ + standalone = false, + accountId = '', + lang = 'en', + apiToken, + on401 = handle401, + children, + hooks = {}, + components = {} +}) => { const [strings, setStrings] = useState() const [token, setToken] = useAPIToken(apiToken) const getRequestOptions = useCallback((): Partial => { @@ -47,7 +45,7 @@ const App: React.FC = props => { return strings ? ( - + = React.memo(({ standalone }) => { - // console.log({ standalone, signin: routePath(standalone, RoutePath.DASHBOARD) }) - const Destinations: React.FC = useCallback( () => ( diff --git a/web/src/bootstrap.tsx b/web/src/bootstrap.tsx index 73d39fdcb..fe0d83f82 100644 --- a/web/src/bootstrap.tsx +++ b/web/src/bootstrap.tsx @@ -9,13 +9,6 @@ import './App.scss' window.STRIP_SCM_PREFIX = true ReactDOM.render( - , + , document.getElementById('react-root') ) diff --git a/web/src/pages/Login/Login.tsx b/web/src/pages/Login/Login.tsx deleted file mode 100644 index 1928a3c77..000000000 --- a/web/src/pages/Login/Login.tsx +++ /dev/null @@ -1,116 +0,0 @@ -import React from 'react' -import { useHistory, Link, useLocation } from 'react-router-dom' -import { - FormInput, - Formik, - FormikForm, - Button, - Text, - Color, - Container, - HarnessIcons, - Layout, - useToaster -} from '@harness/uicore' -import { get } from 'lodash-es' -import { useAPIToken } from 'hooks/useAPIToken' -import { useOnLogin, useOnRegister } from 'services/pm' -import { useStrings } from 'framework/strings' -import routes from 'RouteDefinitions' - -import styles from './Login.module.scss' - -interface LoginForm { - username: string - password: string -} - -const HarnessLogo = HarnessIcons['harness-logo-black'] - -export const Login: React.FC = () => { - const history = useHistory() - const { getString } = useStrings() - const { pathname } = useLocation() - const [, setToken] = useAPIToken() - const { mutate } = useOnLogin({}) - const { showError } = useToaster() - const { mutate: mutateRegister } = useOnRegister({}) - - const handleLogin = async (data: LoginForm): Promise => { - const formData = new FormData() - formData.append('username', data.username) - formData.append('password', data.password) - - if (pathname === '/login') { - mutate(formData as unknown as void) - .then(_data => { - setToken(get(_data, 'access_token' as string)) - history.replace(routes.toDashboard()) - }) - .catch(error => { - showError(`Error: ${error}`) - }) - } else { - mutateRegister(formData as unknown as void) - .then(_data => { - setToken(get(_data, 'access_token' as string)) - history.replace(routes.toDashboard()) - }) - .catch(error => { - showError(`Error: ${error}`) - }) - } - } - - const handleSubmit = (data: LoginForm): void => { - handleLogin(data) - } - - return ( -
-
-
- - - - - {pathname === '/login' ? getString('signIn') : getString('signUp')} - - - and get ship done. - - - - - initialValues={{ username: '', password: '' }} - formName="loginPageForm" - onSubmit={handleSubmit}> - - - - - - - - - - {pathname === '/signin' ? getString('noAccount') : getString('existingAccount')} - - {pathname === '/signin' ? getString('signUp') : getString('signIn')} - - -
-
-
- -
-
- ) -} diff --git a/web/src/pages/Login/login.module.scss b/web/src/pages/Login/login.module.scss deleted file mode 100644 index c470786e6..000000000 --- a/web/src/pages/Login/login.module.scss +++ /dev/null @@ -1,62 +0,0 @@ -.layout { - // Signup card widths - --min-width: 540px; - --max-width: 35%; - display: grid; - grid-template-columns: minmax(var(--min-width), var(--max-width)) auto; - grid-template-rows: 100vh; - - .cardColumn { - overflow-y: auto; - } - - .card { - padding: 85px 40px; - overflow-x: hidden; - width: var(--min-width); - margin: 0 auto; - } -} - -.imageColumn { - overflow-y: hidden; - background-color: #07182b; - padding-left: 40px; - - .image { - object-fit: contain; - height: 100%; - width: 100%; - } -} - -.loginPage { - height: 100vh; - background: var(--primary-7); - display: flex; - - .card { - width: 420px; - margin: auto; - } -} - -@media (max-width: 1280px) { - .layout { - display: flex; - justify-content: center; - width: 100vw; - } - - .imageColumn { - display: none; - } -} - -// Firefox has a bug where padding-bottom is ignored when overflow occurs -// https://bugzilla.mozilla.org/show_bug.cgi?id=748518 -@-moz-document url-prefix() { - .disclaimer { - margin-bottom: 85px !important; - } -} diff --git a/web/src/pages/Login/login.module.scss.d.ts b/web/src/pages/Login/login.module.scss.d.ts deleted file mode 100644 index cbc91449e..000000000 --- a/web/src/pages/Login/login.module.scss.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable */ -/** - * Copyright 2021 Harness Inc. All rights reserved. - * Use of this source code is governed by the PolyForm Shield 1.0.0 license - * that can be found in the licenses directory at the root of this repository, also available at - * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt. - **/ -// this is an auto-generated file, do not update this manually -declare const styles: { - readonly card: string - readonly cardColumn: string - readonly disclaimer: string - readonly image: string - readonly imageColumn: string - readonly layout: string - readonly loginPage: string -} -export default styles