mirror of https://github.com/rancher/dashboard.git
Add additional types for extensions, fix other typing errors
This commit is contained in:
parent
660b3c7612
commit
77d65c9c9b
|
|
@ -14,7 +14,7 @@ const TOOLTIP = 'tooltip';
|
|||
|
||||
export type AsyncButtonCallback = (success: boolean) => void;
|
||||
|
||||
export default Vue.extend({
|
||||
export default Vue.extend<{ phase: string}, any, any, any>({
|
||||
props: {
|
||||
/**
|
||||
* Mode maps to keys in asyncButton.* translations
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ echo "Generating ..."
|
|||
|
||||
# utils
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/utils/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils > /dev/null
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/utils/validators/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils/validators > /dev/null
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/utils/crypto/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/utils/crypto > /dev/null
|
||||
|
||||
# config
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/config/query-params.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/config > /dev/null
|
||||
|
|
@ -22,15 +24,21 @@ ${BASE_DIR}/node_modules/.bin/tsc shell/config/labels-annotations.js --declarati
|
|||
|
||||
# store
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/store/features.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/store > /dev/null
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/store/prefs.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/store > /dev/null
|
||||
|
||||
# plugins
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/plugins/dashboard-store/normalize.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/plugins/dashboard-store/resource-class.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/plugins/dashboard-store/classify.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/plugins/dashboard-store/actions.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store/ > /dev/null
|
||||
|
||||
|
||||
# mkixins
|
||||
# mixins
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/mixins/create-edit-view/index.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/mixins/create-edit-view > /dev/null
|
||||
|
||||
# models
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/models/namespace.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/models/ > /dev/null
|
||||
${BASE_DIR}/node_modules/.bin/tsc shell/models/networking.k8s.io.ingress.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/models/ > /dev/null
|
||||
|
||||
#./node_modules/.bin/tsc shell/plugins/dashboard-store/*.js --declaration --allowJs --emitDeclarationOnly --outDir ${SHELL_DIR}/tmp/plugins/dashboard-store > /dev/null
|
||||
|
||||
# Go through all of the folders and combine by wrapping with 'declare module'
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import cronstrue from 'cronstrue';
|
|||
import { Translation } from '@shell/types/t';
|
||||
|
||||
// import uniq from 'lodash/uniq';
|
||||
export type Validator = (val: any, arg?: any) => undefined | string;
|
||||
export type Validator<T = undefined | string> = (val: any, arg?: any) => T;
|
||||
|
||||
export type ValidatorFactory = (arg1: any, arg2?: any) => Validator
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ export interface ValidationOptions {
|
|||
}
|
||||
|
||||
// "t" is the function name we use for getting a translated string
|
||||
export default function(t: Translation, { key = 'Value' }: ValidationOptions): unknown {
|
||||
export default function(t: Translation, { key = 'Value' }: ValidationOptions): { [key:string]: Validator<any> | ValidatorFactory } {
|
||||
// utility validators these validators only get used by other validators
|
||||
const startDot: ValidatorFactory = (label: string): Validator => (val: string) => val?.slice(0, 1) === '.' ? t(`validation.dns.${ label }.startDot`, { key }) : undefined;
|
||||
|
||||
|
|
@ -257,7 +257,7 @@ export default function(t: Translation, { key = 'Value' }: ValidationOptions): u
|
|||
|
||||
const clusterName: ValidatorFactory = (isRke2: boolean): Validator => (val: string | undefined) => isRke2 && (val || '')?.match(/^(c-.{5}|local)$/i) ? t('validation.cluster.name') : undefined;
|
||||
|
||||
const servicePort = (val: ServicePort) => {
|
||||
const servicePort: Validator<string | Port | undefined> = (val: ServicePort) => {
|
||||
const {
|
||||
name,
|
||||
idx
|
||||
|
|
|
|||
Loading…
Reference in New Issue