mirror of
https://github.com/harness/drone.git
synced 2025-05-21 19:39:59 +08:00
Clean up unused files
This commit is contained in:
parent
7f5a783416
commit
88dff819c9
@ -16,18 +16,16 @@ import { StringsContextProvider } from './framework/strings/StringsContextProvid
|
||||
|
||||
FocusStyleManager.onlyShowFocusOnTabs()
|
||||
|
||||
const App: React.FC<AppProps> = props => {
|
||||
const {
|
||||
const App: React.FC<AppProps> = ({
|
||||
standalone = false,
|
||||
accountId = '',
|
||||
baseRoutePath = '',
|
||||
lang = 'en',
|
||||
apiToken,
|
||||
on401 = handle401,
|
||||
children,
|
||||
hooks = {},
|
||||
components = {}
|
||||
} = props
|
||||
}) => {
|
||||
const [strings, setStrings] = useState<LanguageRecord>()
|
||||
const [token, setToken] = useAPIToken(apiToken)
|
||||
const getRequestOptions = useCallback((): Partial<RequestInit> => {
|
||||
@ -47,7 +45,7 @@ const App: React.FC<AppProps> = props => {
|
||||
return strings ? (
|
||||
<StringsContextProvider initialStrings={strings}>
|
||||
<AppErrorBoundary>
|
||||
<AppContextProvider value={{ standalone, baseRoutePath, accountId, lang, on401, hooks, components }}>
|
||||
<AppContextProvider value={{ standalone, accountId, lang, on401, hooks, components }}>
|
||||
<RestfulProvider
|
||||
base="/"
|
||||
requestOptions={getRequestOptions}
|
||||
|
@ -27,9 +27,6 @@ export interface AppProps {
|
||||
/** App children. When provided, children is a remote view which will be mounted under App contexts */
|
||||
children?: React.ReactNode
|
||||
|
||||
/** Base Route information where app is mounted */
|
||||
baseRoutePath?: string
|
||||
|
||||
/** Active account id when app is embedded */
|
||||
accountId?: string
|
||||
|
||||
|
@ -7,8 +7,6 @@ import { routePath } from './RouteUtils'
|
||||
import { RoutePath } from './RouteDefinitions'
|
||||
|
||||
export const RouteDestinations: React.FC<{ standalone: boolean }> = React.memo(({ standalone }) => {
|
||||
// console.log({ standalone, signin: routePath(standalone, RoutePath.DASHBOARD) })
|
||||
|
||||
const Destinations: React.FC = useCallback(
|
||||
() => (
|
||||
<Switch>
|
||||
|
@ -9,13 +9,6 @@ import './App.scss'
|
||||
window.STRIP_SCM_PREFIX = true
|
||||
|
||||
ReactDOM.render(
|
||||
<App
|
||||
standalone
|
||||
accountId="default"
|
||||
apiToken="default"
|
||||
baseRoutePath="/account/default/settings/governance"
|
||||
hooks={{}}
|
||||
components={{}}
|
||||
/>,
|
||||
<App standalone accountId="default" apiToken="default" hooks={{}} components={{}} />,
|
||||
document.getElementById('react-root')
|
||||
)
|
||||
|
@ -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>
|
||||
)
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
18
web/src/pages/Login/login.module.scss.d.ts
vendored
18
web/src/pages/Login/login.module.scss.d.ts
vendored
@ -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
|
Loading…
Reference in New Issue
Block a user