mirror of
https://github.com/harness/drone.git
synced 2025-05-21 11:29:52 +08:00
Merge pull request #6 from harness/ui-template-improved4
Add typing improvements
This commit is contained in:
commit
d62e4e376e
@ -1,6 +1,7 @@
|
|||||||
import type React from 'react'
|
import type React from 'react'
|
||||||
import type * as History from 'history'
|
import type * as History from 'history'
|
||||||
import type { PermissionOptionsMenuButtonProps } from 'components/Permissions/PermissionsOptionsMenuButton'
|
import type { PermissionOptionsMenuButtonProps } from 'components/Permissions/PermissionsOptionsMenuButton'
|
||||||
|
import type { Unknown } from 'utils/Utils'
|
||||||
import type { LangLocale } from './framework/strings/languageLoader'
|
import type { LangLocale } from './framework/strings/languageLoader'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,16 +67,16 @@ export interface AppPathProps {
|
|||||||
* Platform integration.
|
* Platform integration.
|
||||||
*/
|
*/
|
||||||
export interface AppPropsHook {
|
export interface AppPropsHook {
|
||||||
usePermission(permissionRequest: any, deps?: Array<any>): Array<boolean>
|
usePermission(permissionRequest: Unknown, deps?: Array<Unknown>): Array<boolean>
|
||||||
useGetSchemaYaml(params: any, deps?: Array<any>): Record<string, any>
|
useGetSchemaYaml(params: Unknown, deps?: Array<Unknown>): Record<string, Unknown>
|
||||||
useGetToken(): any
|
useGetToken(): Unknown
|
||||||
useAppStore(): any
|
useAppStore(): Unknown
|
||||||
useGitSyncStore(): any
|
useGitSyncStore(): Unknown
|
||||||
useSaveToGitDialog(props: { onSuccess: any; onClose: any; onProgessOverlayClose: any }): any
|
useSaveToGitDialog(props: { onSuccess: Unknown; onClose: Unknown; onProgessOverlayClose: Unknown }): Unknown
|
||||||
useGetListOfBranchesWithStatus(props: any): any
|
useGetListOfBranchesWithStatus(props: Unknown): Unknown
|
||||||
useAnyEnterpriseLicense(): boolean
|
useAnyEnterpriseLicense(): boolean
|
||||||
useCurrentEnterpriseLicense(): boolean
|
useCurrentEnterpriseLicense(): boolean
|
||||||
useLicenseStore(): any
|
useLicenseStore(): Unknown
|
||||||
} // eslint-disable-line @typescript-eslint/no-empty-interface
|
} // eslint-disable-line @typescript-eslint/no-empty-interface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,7 +88,7 @@ export interface AppPropsComponent {
|
|||||||
RbacButton: React.FC
|
RbacButton: React.FC
|
||||||
RbacOptionsMenuButton: React.FC<PermissionOptionsMenuButtonProps>
|
RbacOptionsMenuButton: React.FC<PermissionOptionsMenuButtonProps>
|
||||||
GitSyncStoreProvider: React.FC
|
GitSyncStoreProvider: React.FC
|
||||||
GitContextForm: React.FC<any>
|
GitContextForm: React.FC<Unknown>
|
||||||
NavigationCheck: React.FC<{
|
NavigationCheck: React.FC<{
|
||||||
when?: boolean
|
when?: boolean
|
||||||
textProps?: {
|
textProps?: {
|
||||||
|
@ -6,7 +6,9 @@ import { SignUp } from 'pages/SignUp/SignUp'
|
|||||||
import { routePath } from './RouteUtils'
|
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(function RouteDestinations({
|
||||||
|
standalone
|
||||||
|
}) {
|
||||||
const Destinations: React.FC = useCallback(
|
const Destinations: React.FC = useCallback(
|
||||||
() => (
|
() => (
|
||||||
<Switch>
|
<Switch>
|
||||||
|
@ -6,6 +6,7 @@ import { Classes, IInputGroupProps, ITagInputProps } from '@blueprintjs/core'
|
|||||||
import cx from 'classnames'
|
import cx from 'classnames'
|
||||||
import type { FormikProps } from 'formik'
|
import type { FormikProps } from 'formik'
|
||||||
import { useStrings } from 'framework/strings'
|
import { useStrings } from 'framework/strings'
|
||||||
|
import type { Unknown } from 'utils/Utils'
|
||||||
import type {
|
import type {
|
||||||
DescriptionComponentProps,
|
DescriptionComponentProps,
|
||||||
DescriptionProps,
|
DescriptionProps,
|
||||||
@ -23,7 +24,7 @@ export interface NameIdDescriptionTagsProps {
|
|||||||
tagsProps?: Partial<ITagInputProps> & {
|
tagsProps?: Partial<ITagInputProps> & {
|
||||||
isOption?: boolean
|
isOption?: boolean
|
||||||
}
|
}
|
||||||
formikProps: FormikProps<any>
|
formikProps: FormikProps<Unknown>
|
||||||
className?: string
|
className?: string
|
||||||
tooltipProps?: DataTooltipInterface
|
tooltipProps?: DataTooltipInterface
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import type { TagInputProps } from '@harness/uicore'
|
|||||||
import type { ITagInputProps, IInputGroupProps } from '@blueprintjs/core'
|
import type { ITagInputProps, IInputGroupProps } from '@blueprintjs/core'
|
||||||
import type { InputWithIdentifierProps } from '@harness/uicore/dist/components/InputWithIdentifier/InputWithIdentifier'
|
import type { InputWithIdentifierProps } from '@harness/uicore/dist/components/InputWithIdentifier/InputWithIdentifier'
|
||||||
import type { FormikProps } from 'formik'
|
import type { FormikProps } from 'formik'
|
||||||
|
import type { Unknown } from 'utils/Utils'
|
||||||
|
|
||||||
export interface DescriptionProps {
|
export interface DescriptionProps {
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
@ -34,7 +35,7 @@ export interface NameIdDescriptionTagsDeprecatedProps<T> {
|
|||||||
identifierProps?: Omit<InputWithIdentifierProps, 'formik'>
|
identifierProps?: Omit<InputWithIdentifierProps, 'formik'>
|
||||||
descriptionProps?: DescriptionProps
|
descriptionProps?: DescriptionProps
|
||||||
tagInputProps?: TagInputProps<T>
|
tagInputProps?: TagInputProps<T>
|
||||||
formikProps: FormikProps<any>
|
formikProps: FormikProps<Unknown>
|
||||||
className?: string
|
className?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,5 +44,5 @@ export interface NameIdDescriptionProps {
|
|||||||
inputGroupProps?: IInputGroupProps
|
inputGroupProps?: IInputGroupProps
|
||||||
descriptionProps?: DescriptionProps
|
descriptionProps?: DescriptionProps
|
||||||
className?: string
|
className?: string
|
||||||
formikProps: Omit<FormikProps<any>, 'tags'>
|
formikProps: Omit<FormikProps<Unknown>, 'tags'>
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Button, ButtonProps } from '@harness/uicore'
|
import { Button, ButtonProps } from '@harness/uicore'
|
||||||
import { useAppContext } from 'AppContext'
|
import { useAppContext } from 'AppContext'
|
||||||
|
import type { Unknown } from 'utils/Utils'
|
||||||
|
|
||||||
interface PermissionButtonProps extends ButtonProps {
|
interface PermissionButtonProps extends ButtonProps {
|
||||||
permission?: any
|
permission?: Unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PermissionsButton: React.FC<PermissionButtonProps> = (props: PermissionButtonProps) => {
|
export const PermissionsButton: React.FC<PermissionButtonProps> = (props: PermissionButtonProps) => {
|
||||||
|
@ -2,11 +2,12 @@ import React, { AnchorHTMLAttributes, ReactElement } from 'react'
|
|||||||
import type { IMenuItemProps } from '@blueprintjs/core'
|
import type { IMenuItemProps } from '@blueprintjs/core'
|
||||||
import { OptionsMenuButton, OptionsMenuButtonProps } from 'components/OptionsMenuButton/OptionsMenuButton'
|
import { OptionsMenuButton, OptionsMenuButtonProps } from 'components/OptionsMenuButton/OptionsMenuButton'
|
||||||
import { useAppContext } from 'AppContext'
|
import { useAppContext } from 'AppContext'
|
||||||
|
import type { Unknown } from 'utils/Utils'
|
||||||
|
|
||||||
type Item = ((IMenuItemProps | PermissionsMenuItemProps) & AnchorHTMLAttributes<HTMLAnchorElement>) | '-'
|
type Item = ((IMenuItemProps | PermissionsMenuItemProps) & AnchorHTMLAttributes<HTMLAnchorElement>) | '-'
|
||||||
|
|
||||||
interface PermissionsMenuItemProps extends IMenuItemProps {
|
interface PermissionsMenuItemProps extends IMenuItemProps {
|
||||||
permission?: any
|
permission?: Unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PermissionOptionsMenuButtonProps extends OptionsMenuButtonProps {
|
export interface PermissionOptionsMenuButtonProps extends OptionsMenuButtonProps {
|
||||||
|
@ -2,9 +2,10 @@ import React from 'react'
|
|||||||
import { useLocation } from 'react-router-dom'
|
import { useLocation } from 'react-router-dom'
|
||||||
import qs from 'qs'
|
import qs from 'qs'
|
||||||
import type { IParseOptions } from 'qs'
|
import type { IParseOptions } from 'qs'
|
||||||
|
import type { Unknown } from 'utils/Utils'
|
||||||
|
|
||||||
export interface UseQueryParamsOptions<T> extends IParseOptions {
|
export interface UseQueryParamsOptions<T> extends IParseOptions {
|
||||||
processQueryParams?(data: any): T
|
processQueryParams?(data: Unknown): T
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useQueryParams<T = unknown>(options?: UseQueryParamsOptions<T>): T {
|
export function useQueryParams<T = unknown>(options?: UseQueryParamsOptions<T>): T {
|
||||||
@ -18,7 +19,7 @@ export function useQueryParams<T = unknown>(options?: UseQueryParamsOptions<T>):
|
|||||||
}
|
}
|
||||||
|
|
||||||
return params
|
return params
|
||||||
}, [search, options, options?.processQueryParams])
|
}, [search, options])
|
||||||
|
|
||||||
return queryParams as unknown as T
|
return queryParams as unknown as T
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
export function useStandalonePermission(_permissionsRequest?: any, _deps: Array<any> = []): Array<boolean> {
|
import type { Unknown } from 'utils/Utils'
|
||||||
|
|
||||||
|
export function useStandalonePermission(_permissionsRequest?: Unknown, _deps: Array<Unknown> = []): Array<boolean> {
|
||||||
return [true, true]
|
return [true, true]
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useHistory } from 'react-router-dom'
|
// import { useHistory } from 'react-router-dom'
|
||||||
import React, { useCallback, useState } from 'react'
|
import React, { useCallback, useState } from 'react'
|
||||||
// import { get } from 'lodash-es'
|
// import { get } from 'lodash-es'
|
||||||
import { Button, Container, Layout, Text, TextInput } from '@harness/uicore'
|
import { Button, Container, Layout, Text, TextInput } from '@harness/uicore'
|
||||||
@ -9,7 +9,7 @@ import { useOnLogin } from 'services/pm'
|
|||||||
|
|
||||||
export const SignIn: React.FC = () => {
|
export const SignIn: React.FC = () => {
|
||||||
const { getString } = useStrings()
|
const { getString } = useStrings()
|
||||||
const history = useHistory()
|
// const history = useHistory()
|
||||||
const [username, setUsername] = useState('')
|
const [username, setUsername] = useState('')
|
||||||
const [password, setPassword] = useState('')
|
const [password, setPassword] = useState('')
|
||||||
// const [, setToken] = useAPIToken()
|
// const [, setToken] = useAPIToken()
|
||||||
@ -30,7 +30,7 @@ export const SignIn: React.FC = () => {
|
|||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error({ error })
|
console.error({ error })
|
||||||
})
|
})
|
||||||
}, [mutate, username, password, history])
|
}, [mutate, username, password])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout.Vertical>
|
<Layout.Vertical>
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
export enum Sort {
|
|
||||||
DESC = 'DESC',
|
|
||||||
ASC = 'ASC'
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum SortFields {
|
|
||||||
LastUpdatedAt = 'updated',
|
|
||||||
AZ09 = 'AZ09',
|
|
||||||
ZA90 = 'ZA90',
|
|
||||||
Name = 'name'
|
|
||||||
}
|
|
@ -5,6 +5,8 @@ import moment from 'moment'
|
|||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { useAppContext } from 'AppContext'
|
import { useAppContext } from 'AppContext'
|
||||||
|
|
||||||
|
export type Unknown = any // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
|
|
||||||
/** This utility shows a toaster without being bound to any component.
|
/** This utility shows a toaster without being bound to any component.
|
||||||
* It's useful to show cross-page/component messages */
|
* It's useful to show cross-page/component messages */
|
||||||
export function showToaster(message: string, props?: Partial<IToastProps>): IToaster {
|
export function showToaster(message: string, props?: Partial<IToastProps>): IToaster {
|
||||||
@ -99,7 +101,7 @@ export const useAnyTrialLicense = (): boolean => {
|
|||||||
return !!anyTrialEntitlements
|
return !!anyTrialEntitlements
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useGetTrialInfo = (): any => {
|
export const useGetTrialInfo = (): Unknown => {
|
||||||
const {
|
const {
|
||||||
hooks: { useLicenseStore = () => ({}) }
|
hooks: { useLicenseStore = () => ({}) }
|
||||||
} = useAppContext()
|
} = useAppContext()
|
||||||
|
Loading…
Reference in New Issue
Block a user