Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Add errorList.json to record error meta and expose the doc link from TaskCheckRunPanel by consulting its data

天舟3f3bc4245553
diff --git a/frontend/src/components/TaskCheckRunPanel.vue b/frontend/src/components/TaskCheckRunPanel.vue
index 4c9524a47f..710dcae0d0 100644
--- a/frontend/src/components/TaskCheckRunPanel.vue
+++ b/frontend/src/components/TaskCheckRunPanel.vue
@@ -73,6 +73,13 @@
</BBTableCell>
<BBTableCell class="table-cell w-48">
{{ checkResult.content }}
+ <a
+ v-if="errorCodeLink(checkResult.code)"
+ class="normal-link"
+ :href="errorCodeLink(checkResult.code)"
+ target="__blank"
+ >view doc</a
+ >
</BBTableCell>
</template>
</BBTable>
@@ -82,7 +89,14 @@
<script lang="ts">
import { computed, PropType } from "vue";
import { BBTableColumn } from "../bbkit/types";
-import { TaskCheckStatus, TaskCheckRun, TaskCheckResult } from "../types";
+import {
+ TaskCheckStatus,
+ TaskCheckRun,
+ TaskCheckResult,
+ ErrorMeta,
+ ErrorCode,
+} from "../types";
+import errorJson from "../types/errorList.json";
const columnList: BBTableColumn[] = [
{
@@ -106,6 +120,8 @@ export default {
},
},
setup(props, ctx) {
+ const errorList: ErrorMeta[] = errorJson as ErrorMeta[];
+
const statusIconClass = (status: TaskCheckStatus) => {
switch (status) {
case "SUCCESS":
@@ -143,10 +159,16 @@ export default {
return [];
});
+ const errorCodeLink = (code: ErrorCode): string => {
+ const error = errorList.find((item) => item.code == code);
+ return error ? `https://bytebase.com/doc/error#${error.hash}` : "";
+ };
+
return {
columnList,
statusIconClass,
checkResultList,
+ errorCodeLink,
};
},
};
diff --git a/frontend/src/types/error.ts b/frontend/src/types/error.ts
index e590ce3534..368eeeb69f 100644
--- a/frontend/src/types/error.ts
+++ b/frontend/src/types/error.ts
@@ -34,3 +34,21 @@ export enum CompatibilityErrorCode {
COMPATIBILITY_ALTER_CHECK = 10010,
COMPATIBILITY_ALTER_COLUMN = 10011,
}
+
+export type ErrorCode =
+ | GeneralErrorCode
+ | DBErrorCode
+ | MigrationErrorCode
+ | CompatibilityErrorCode;
+
+export type ErrorTag = "General" | "Compatibility";
+
+// error.json stores the corresponding data, this will be used by Bytebase to construct the link and our doc website to generate
+// the content
+export type ErrorMeta = {
+ code: ErrorCode;
+ hash: string;
+ name: string;
+ description: string;
+ tagList: ErrorTag[];
+};
diff --git a/frontend/src/types/errorList.json b/frontend/src/types/errorList.json
new file mode 100644
index 0000000000..4ea1f74f80
--- /dev/null
+++ b/frontend/src/types/errorList.json
@@ -0,0 +1,23 @@
+[
+ {
+ "code": 0,
+ "hash": "ok-0",
+ "name": "Ok",
+ "description": "Code indicating success",
+ "tagList": ["General"]
+ },
+ {
+ "code": 101,
+ "hash": "db-connection-101",
+ "name": "Failed to connect database",
+ "description": "Unable to connect database.",
+ "tagList": ["General"]
+ },
+ {
+ "code": 10001,
+ "hash": "drop-database-10001",
+ "name": "DROP DATABASE (backward incompatible migration)",
+ "description": "DROP DATABASE is a backward incompatible migration.",
+ "tagList": ["Compatibility"]
+ }
+]
diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json
index 75e7b427db..8cbbf4e7af 100644
--- a/frontend/tsconfig.json
+++ b/frontend/tsconfig.json
@@ -2,12 +2,12 @@
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
- "target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
- "module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
+ "target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
+ "module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
- "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
+ "jsx": "preserve" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
@@ -23,7 +23,7 @@
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
- "strict": true, /* Enable all strict type-checking options. */
+ "strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
@@ -39,14 +39,14 @@
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
- "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
+ "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
- "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
+ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
@@ -61,6 +61,8 @@
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
+ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
+ /* Import json file */
+ "resolveJsonModule": true
}
}