Clean up unused files

This commit is contained in:
Tan Nhu 2022-08-22 16:44:07 -07:00
parent 7f5a783416
commit 88dff819c9
7 changed files with 12 additions and 222 deletions

View File

@ -16,18 +16,16 @@ import { StringsContextProvider } from './framework/strings/StringsContextProvid
FocusStyleManager.onlyShowFocusOnTabs() FocusStyleManager.onlyShowFocusOnTabs()
const App: React.FC<AppProps> = props => { const App: React.FC<AppProps> = ({
const {
standalone = false, standalone = false,
accountId = '', accountId = '',
baseRoutePath = '',
lang = 'en', lang = 'en',
apiToken, apiToken,
on401 = handle401, on401 = handle401,
children, children,
hooks = {}, hooks = {},
components = {} components = {}
} = props }) => {
const [strings, setStrings] = useState<LanguageRecord>() const [strings, setStrings] = useState<LanguageRecord>()
const [token, setToken] = useAPIToken(apiToken) const [token, setToken] = useAPIToken(apiToken)
const getRequestOptions = useCallback((): Partial<RequestInit> => { const getRequestOptions = useCallback((): Partial<RequestInit> => {
@ -47,7 +45,7 @@ const App: React.FC<AppProps> = props => {
return strings ? ( return strings ? (
<StringsContextProvider initialStrings={strings}> <StringsContextProvider initialStrings={strings}>
<AppErrorBoundary> <AppErrorBoundary>
<AppContextProvider value={{ standalone, baseRoutePath, accountId, lang, on401, hooks, components }}> <AppContextProvider value={{ standalone, accountId, lang, on401, hooks, components }}>
<RestfulProvider <RestfulProvider
base="/" base="/"
requestOptions={getRequestOptions} requestOptions={getRequestOptions}

View File

@ -27,9 +27,6 @@ export interface AppProps {
/** App children. When provided, children is a remote view which will be mounted under App contexts */ /** App children. When provided, children is a remote view which will be mounted under App contexts */
children?: React.ReactNode children?: React.ReactNode
/** Base Route information where app is mounted */
baseRoutePath?: string
/** Active account id when app is embedded */ /** Active account id when app is embedded */
accountId?: string accountId?: string

View File

@ -7,8 +7,6 @@ import { routePath } from './RouteUtils'
import { RoutePath } from './RouteDefinitions' import { RoutePath } from './RouteDefinitions'
export const RouteDestinations: React.FC<{ standalone: boolean }> = React.memo(({ standalone }) => { export const RouteDestinations: React.FC<{ standalone: boolean }> = React.memo(({ standalone }) => {
// console.log({ standalone, signin: routePath(standalone, RoutePath.DASHBOARD) })
const Destinations: React.FC = useCallback( const Destinations: React.FC = useCallback(
() => ( () => (
<Switch> <Switch>

View File

@ -9,13 +9,6 @@ import './App.scss'
window.STRIP_SCM_PREFIX = true window.STRIP_SCM_PREFIX = true
ReactDOM.render( ReactDOM.render(
<App <App standalone accountId="default" apiToken="default" hooks={{}} components={{}} />,
standalone
accountId="default"
apiToken="default"
baseRoutePath="/account/default/settings/governance"
hooks={{}}
components={{}}
/>,
document.getElementById('react-root') document.getElementById('react-root')
) )

View File

@ -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<void> => {
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 (
<div className={styles.layout}>
<div className={styles.cardColumn}>
<div className={styles.card}>
<Container flex={{ justifyContent: 'space-between', alignItems: 'center' }} margin={{ bottom: 'xxxlarge' }}>
<HarnessLogo height={25} />
</Container>
<Text font={{ size: 'large', weight: 'bold' }} color={Color.BLACK}>
{pathname === '/login' ? getString('signIn') : getString('signUp')}
</Text>
<Text font={{ size: 'medium' }} color={Color.BLACK} margin={{ top: 'xsmall' }}>
and get ship done.
</Text>
<Container margin={{ top: 'xxxlarge' }}>
<Formik<LoginForm>
initialValues={{ username: '', password: '' }}
formName="loginPageForm"
onSubmit={handleSubmit}>
<FormikForm>
<FormInput.Text name="email" label={getString('email')} />
<FormInput.Text name="password" label={getString('password')} inputGroup={{ type: 'password' }} />
<Button type="submit" intent="primary" width="100%">
{pathname === '/signin' ? getString('signIn') : getString('signUp')}
</Button>
</FormikForm>
</Formik>
</Container>
<Layout.Horizontal margin={{ top: 'xxxlarge' }} spacing="xsmall">
<Text>{pathname === '/signin' ? getString('noAccount') : getString('existingAccount')}</Text>
<Link to={pathname === '/signin' ? routes.toSignUp() : routes.toSignIn()}>
{pathname === '/signin' ? getString('signUp') : getString('signIn')}
</Link>
</Layout.Horizontal>
</div>
</div>
<div className={styles.imageColumn}>
<img
className={styles.image}
src={'https://app.harness.io/auth/assets/AuthIllustration.f611adb8.svg'}
alt=""
aria-hidden
/>
</div>
</div>
)
}

View File

@ -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;
}
}

View File

@ -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