style: revert changes on src/ and __test__

This commit is contained in:
lazzzis 2022-07-05 21:11:25 -07:00
parent 289953703e
commit 1e4a509a23
16 changed files with 37 additions and 33 deletions

View file

@ -4,7 +4,7 @@ import {
patientClick,
selectFileTreeItem,
sleep,
waitForLegacyPJAXRedirect,
waitForLegacyPJAXRedirect
} from '../../utils'
describe(`in Gitako project page`, () => {

View file

@ -5,7 +5,7 @@ import {
patientClick,
selectFileTreeItem,
sleep,
waitForLegacyPJAXRedirect,
waitForLegacyPJAXRedirect
} from '../../utils'
describe(`in Gitako project page`, () => {

View file

@ -3,13 +3,11 @@ import {
expectToFind,
expectToNotFind,
scroll,
selectFileTreeItem,
selectFileTreeItem
} from '../../utils'
describe(`in Gitako project page`, () => {
beforeAll(() =>
page.goto('https://github.com/EnixCoda/Gitako/tree/test/200-changed-files-200-lines-each'),
)
beforeAll(() => page.goto('https://github.com/EnixCoda/Gitako/tree/test/200-changed-files-200-lines-each'))
it('should render Gitako', async () => {
await expectToFind('.gitako-side-bar .gitako-side-bar-body-wrapper')

View file

@ -1,4 +1,9 @@
import { expectToFind, selectFileTreeItem, sleep, waitForLegacyPJAXRedirect } from '../../utils'
import {
expectToFind,
selectFileTreeItem,
sleep,
waitForLegacyPJAXRedirect
} from '../../utils'
describe(`in Gitako project page`, () => {
beforeAll(() => page.goto('https://github.com/EnixCoda/Gitako/tree/develop/src'))

View file

@ -40,7 +40,7 @@ export async function listenTo<Args extends any[] = any[]>(
(event, target, callbackName, oneTime) => {
const t = target === 'document' ? document : window
const onEvent = (...args: any[]): void => {
;(window[callbackName as any] as any as (...args: any[]) => void)(...args)
;((window[callbackName as any] as any) as (...args: any[]) => void)(...args)
if (oneTime) t.removeEventListener(event, onEvent)
}
t.addEventListener(event, onEvent)
@ -81,9 +81,7 @@ export async function patientClick(selector: string) {
}
export async function expandFloatModeSidebar() {
const rect = await (
await page.$('.gitako-toggle-show-button')
)?.evaluate(button => {
const rect = await (await page.$('.gitako-toggle-show-button'))?.evaluate(button => {
const { x, y, width, height } = button.getBoundingClientRect()
// pass required properties to avoid serialization issues
return { x, y, width, height }

View file

@ -24,7 +24,7 @@ import {
ReplyIcon as Reply,
SearchIcon as Search,
TabIcon as Tab,
XIcon as X,
XIcon as X
} from '@primer/octicons-react'
import * as React from 'react'
import { cx } from 'utils/cx'

View file

@ -2,7 +2,7 @@ import { BranchName, Breadcrumb, Flex, Text } from '@primer/components'
import { GitBranchIcon } from '@primer/octicons-react'
import { platform } from 'platforms'
import * as React from 'react'
import { createAnchorClickHandler } from 'utils/createAnchorClickHandler'
import { createAnchorClickHandler } from "utils/createAnchorClickHandler"
type Props = {
metaData: MetaData

View file

@ -104,7 +104,7 @@ export function SideBarBodyWrapper({
const dummySize: [number, number] = React.useMemo(() => [size, size], [size])
const defaultSideBarWidth = React.useMemo(() => getDefaultConfigs().sideBarWidth, [])
const defaultSideBarWidth = React.useMemo(() => getDefaultConfigs().sideBarWidth, []);
return (
<div

View file

@ -7,7 +7,7 @@ import * as ReactDOM from 'react-dom'
import {
insertLogoMountPoint,
insertSideBarMountPoint,
persistGitakoElements,
persistGitakoElements
} from 'utils/DOMHelper'
import './content.scss'

4
src/global.d.ts vendored
View file

@ -17,8 +17,8 @@ type TreeNode = {
sha?: string
accessDenied?: boolean
comments?: {
active: number
resolved: number
active: number,
resolved: number,
}
diff?: {
status: 'modified' | 'added' | 'removed' | 'renamed'

View file

@ -54,7 +54,8 @@ export function getCurrentBranch(passive = false) {
if (title !== defaultTitle && !title.includes(' ')) return title
}
const findFileButtonSelector = 'main .file-navigation a[data-hotkey="t"]'
const findFileButtonSelector =
'main .file-navigation a[data-hotkey="t"]'
const urlFromFindFileButton: string | null = $(
findFileButtonSelector,
element => (element as HTMLAnchorElement).href,

View file

@ -77,7 +77,8 @@ export async function getTreeData(
): Promise<GiteaAPI.TreeData> {
const search = new URLSearchParams()
if (recursive) search.set('recursive', '1')
const url = `${API_ENDPOINT}/repos/${userName}/${repoName}/git/trees/${branchName}?` + search
const url =
`${API_ENDPOINT}/repos/${userName}/${repoName}/git/trees/${branchName}?` + search
return await request(url, { accessToken })
}
@ -93,14 +94,14 @@ export async function getBlobData(
export async function OAuth(code: string): Promise<string | null> {
const endpoint = `https://gitako.enix.one/oauth/gitea?`
const res = await fetch(endpoint + new URLSearchParams({ code }).toString(), {
method: 'post',
})
const res = await fetch(endpoint + new URLSearchParams({ code }).toString(), {
method: 'post',
})
if (res.ok) {
const body = await res.json()
const accessToken = body?.accessToken
if (typeof accessToken === 'string') return accessToken
}
return null
if (res.ok) {
const body = await res.json()
const accessToken = body?.accessToken
if (typeof accessToken === 'string') return accessToken
}
return null
}

View file

@ -67,4 +67,4 @@ export function getCurrentPath(branchName = '') {
return path.map(decodeURIComponent)
}
return []
}
}

View file

@ -19,7 +19,7 @@ export class EventSubscription<Data, Listener extends VoidFN<Data> = VoidFN<Data
export class EventHub<
Shape extends {
[event: string]: any
},
}
> {
ports: {
[key in keyof Shape]: EventSubscription<Shape[key]>

View file

@ -31,8 +31,7 @@ export function useResizeHandler(
if (!pointerDown.current) return
const [x0, y0] = initialSizeRef.current
// Allow minor movement, this happened unintentionally for few times when I use track pad
pointerMoved.current =
pointerMoved.current || (clientX - x0) ** 2 + (clientY - y0) ** 2 > distanceTolerance ** 2
pointerMoved.current = pointerMoved.current || (clientX - x0) ** 2 + (clientY - y0) ** 2 > distanceTolerance ** 2
const [x1, y1] = baseSize.current
onResize([x1 + clientX - x0, y1 + clientY - y0])
}

View file

@ -1,6 +1,8 @@
import * as React from 'react'
export function useStateIO<S>(initialState: S | (() => S)): {
export function useStateIO<S>(
initialState: S | (() => S),
): {
value: S
onChange: React.Dispatch<React.SetStateAction<S>>
} {