This is an automated email from the ASF dual-hosted git repository. young pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push: new 7a79dee27 feat: show ui commit sha in settings modal (#3041) 7a79dee27 is described below commit 7a79dee275ca9ee36193140a31ae7a9f5130796f Author: YYYoung <isk...@outlook.com> AuthorDate: Mon May 12 09:50:13 2025 +0800 feat: show ui commit sha in settings modal (#3041) --- package.json | 1 + pnpm-lock.yaml | 120 ++++++++++++++++++++++++++++++++++ src/components/page/SettingsModal.tsx | 47 +++++++++---- src/locales/en/common.json | 3 +- src/types/vite-env.d.ts | 1 + vite.config.ts | 2 + 6 files changed, 160 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index b9c9f5e93..573c43354 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "typescript": "~5.8.3", "typescript-eslint": "^8.32.0", "unplugin-icons": "^22.1.0", + "unplugin-info": "^1.2.2", "vite": "^6.3.5", "vite-tsconfig-paths": "^5.1.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8a89bd16f..908a984ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -192,6 +192,9 @@ importers: unplugin-icons: specifier: ^22.1.0 version: 22.1.0(@svgr/core@8.1.0(typescript@5.8.3)) + unplugin-info: + specifier: ^1.2.2 + version: 1.2.2(esbuild@0.25.2)(rollup@4.40.0)(vite@6.3.5(@types/node@22.14.1)(sugarss@4.0.1(postcss@8.5.3))(tsx@4.19.3)(yaml@2.7.1)) vite: specifier: ^6.3.5 version: 6.3.5(@types/node@22.14.1)(sugarss@4.0.1(postcss@8.5.3))(tsx@4.19.3)(yaml@2.7.1) @@ -786,6 +789,12 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} + '@kwsites/file-exists@1.1.1': + resolution: {integrity: sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==} + + '@kwsites/promise-deferred@1.1.1': + resolution: {integrity: sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==} + '@mantine/core@8.0.0': resolution: {integrity: sha512-TskeJS2/+DbmUe85fXDoUAyErkSvR4YlbUl8MLqhjFBJUqwc72ZrLynmN13wuKtlVPakDYYjq4/IEDMReh3CYA==} peerDependencies: @@ -1277,6 +1286,9 @@ packages: '@types/parse-json@4.0.2': resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==} + '@types/parse-path@7.1.0': + resolution: {integrity: sha512-EULJ8LApcVEPbrfND0cRQqutIOdiIgJ1Mgrhpy755r14xMohPTEpkV/k28SJvuOs9bHRFW8x+KeDAEPiGQPB9Q==} + '@types/qs@6.9.18': resolution: {integrity: sha512-kK7dgTYDyGqS+e2Q4aK9X3D7q234CIZ1Bv0q/7Z5IwRDoADNU81xXJK/YVyLbLTZCoIwUoDoffFeF+p/eIklAA==} @@ -1517,6 +1529,10 @@ packages: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} + ci-info@4.2.0: + resolution: {integrity: sha512-cYY9mypksY8NRqgDB1XD1RiJL338v/551niynFTGkZOO2LHuB2OmOYxDIe/ttN9AHwrqdum1360G3ald0W9kCg==} + engines: {node: '>=8'} + classnames@2.5.1: resolution: {integrity: sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==} @@ -1981,6 +1997,12 @@ packages: get-tsconfig@4.10.0: resolution: {integrity: sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A==} + git-up@8.1.1: + resolution: {integrity: sha512-FDenSF3fVqBYSaJoYy1KSc2wosx0gCvKP+c+PRBht7cAaiCeQlBtfBDX9vgnNOHmdePlSFITVcn4pFfcgNvx3g==} + + git-url-parse@16.1.0: + resolution: {integrity: sha512-cPLz4HuK86wClEW7iDdeAKcCVlWXmrLpb2L+G9goW0Z1dtpNS6BXXSOckUTlJT/LDQViE1QZKstNORzHsLnobw==} + glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -2186,6 +2208,9 @@ packages: resolution: {integrity: sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==} engines: {node: '>= 0.4'} + is-ssh@1.4.1: + resolution: {integrity: sha512-JNeu1wQsHjyHgn9NcWTaXq6zWSR6hqE0++zhfZlkFBbScNkyvxCdeV8sRkSBaeLKxmbpR21brail63ACNxJ0Tg==} + is-stream@3.0.0: resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -2513,6 +2538,13 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} + parse-path@7.1.0: + resolution: {integrity: sha512-EuCycjZtfPcjWk7KTksnJ5xPMvWGA/6i4zrLYhRG0hGvC3GPU/jGUj3Cy+ZR0v30duV3e23R95T1lE2+lsndSw==} + + parse-url@9.2.0: + resolution: {integrity: sha512-bCgsFI+GeGWPAvAiUv63ZorMeif3/U0zaXABGJbOWt5OH2KCaPHF6S+0ok4aqM9RuIPGyZdx9tR9l13PsW4AYQ==} + engines: {node: '>=14.13.0'} + path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -2614,6 +2646,9 @@ packages: prop-types@15.8.1: resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} + protocols@2.0.2: + resolution: {integrity: sha512-hHVTzba3wboROl0/aWRRG9dMytgH6ow//STBZh43l/wQgmMhYhOFi0EHWAPtoCz9IAUymsyP0TSBHkhgMEGNnQ==} + proxy-from-env@1.1.0: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} @@ -3126,6 +3161,9 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + simple-git@3.27.0: + resolution: {integrity: sha512-ivHoFS9Yi9GY49ogc6/YAi3Fl9ROnF4VyubNylgCkA+RVqLaKWnDSzXOVzya8csELIaWaYNutsEuAhZrtOjozA==} + slice-ansi@5.0.0: resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==} engines: {node: '>=12'} @@ -3381,6 +3419,29 @@ packages: vue-template-es2015-compiler: optional: true + unplugin-info@1.2.2: + resolution: {integrity: sha512-GiDA/pC+qRerudmIZ9TM7eEwdg4GA0DMdNHfRDP00QWV6XEQeiKckhibubehrqJkrOZlyALBVCF7DqQvaYgC4w==} + peerDependencies: + '@nuxt/kit': ^3 + '@nuxt/schema': ^3 + esbuild: '*' + rollup: ^2 || ^3 || ^4 + vite: '>=3.2.7' + webpack: ^4 || ^5 + peerDependenciesMeta: + '@nuxt/kit': + optional: true + '@nuxt/schema': + optional: true + esbuild: + optional: true + rollup: + optional: true + vite: + optional: true + webpack: + optional: true + unplugin@2.3.2: resolution: {integrity: sha512-3n7YA46rROb3zSj8fFxtxC/PqoyvYQ0llwz9wtUPUutr9ig09C8gGo5CWCwHrUzlqC1LLR43kxp5vEIyH1ac1w==} engines: {node: '>=18.12.0'} @@ -4291,6 +4352,14 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 + '@kwsites/file-exists@1.1.1': + dependencies: + debug: 4.4.0 + transitivePeerDependencies: + - supports-color + + '@kwsites/promise-deferred@1.1.1': {} + '@mantine/core@8.0.0(@mantine/hooks@8.0.0(react@19.1.0))(@types/react@19.1.3)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)': dependencies: '@floating-ui/react': 0.26.28(react-dom@19.1.0(react@19.1.0))(react@19.1.0) @@ -4752,6 +4821,10 @@ snapshots: '@types/parse-json@4.0.2': {} + '@types/parse-path@7.1.0': + dependencies: + parse-path: 7.1.0 + '@types/qs@6.9.18': {} '@types/react-dom@19.1.2(@types/react@19.1.3)': @@ -5122,6 +5195,8 @@ snapshots: optionalDependencies: fsevents: 2.3.3 + ci-info@4.2.0: {} + classnames@2.5.1: {} cli-cursor@5.0.0: @@ -5706,6 +5781,15 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 + git-up@8.1.1: + dependencies: + is-ssh: 1.4.1 + parse-url: 9.2.0 + + git-url-parse@16.1.0: + dependencies: + git-up: 8.1.1 + glob-parent@5.1.2: dependencies: is-glob: 4.0.3 @@ -5891,6 +5975,10 @@ snapshots: dependencies: call-bound: 1.0.4 + is-ssh@1.4.1: + dependencies: + protocols: 2.0.2 + is-stream@3.0.0: {} is-string@1.1.1: @@ -6242,6 +6330,15 @@ snapshots: json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 + parse-path@7.1.0: + dependencies: + protocols: 2.0.2 + + parse-url@9.2.0: + dependencies: + '@types/parse-path': 7.1.0 + parse-path: 7.1.0 + path-exists@4.0.0: {} path-key@3.1.1: {} @@ -6327,6 +6424,8 @@ snapshots: object-assign: 4.1.1 react-is: 16.13.1 + protocols@2.0.2: {} + proxy-from-env@1.1.0: {} punycode@2.3.1: {} @@ -6974,6 +7073,14 @@ snapshots: signal-exit@4.1.0: {} + simple-git@3.27.0: + dependencies: + '@kwsites/file-exists': 1.1.1 + '@kwsites/promise-deferred': 1.1.1 + debug: 4.4.0 + transitivePeerDependencies: + - supports-color + slice-ansi@5.0.0: dependencies: ansi-styles: 6.2.1 @@ -7235,6 +7342,19 @@ snapshots: transitivePeerDependencies: - supports-color + unplugin-info@1.2.2(esbuild@0.25.2)(rollup@4.40.0)(vite@6.3.5(@types/node@22.14.1)(sugarss@4.0.1(postcss@8.5.3))(tsx@4.19.3)(yaml@2.7.1)): + dependencies: + ci-info: 4.2.0 + git-url-parse: 16.1.0 + simple-git: 3.27.0 + unplugin: 2.3.2 + optionalDependencies: + esbuild: 0.25.2 + rollup: 4.40.0 + vite: 6.3.5(@types/node@22.14.1)(sugarss@4.0.1(postcss@8.5.3))(tsx@4.19.3)(yaml@2.7.1) + transitivePeerDependencies: + - supports-color + unplugin@2.3.2: dependencies: acorn: 8.14.1 diff --git a/src/components/page/SettingsModal.tsx b/src/components/page/SettingsModal.tsx index 0f7c6dca0..5cf8e8215 100644 --- a/src/components/page/SettingsModal.tsx +++ b/src/components/page/SettingsModal.tsx @@ -14,11 +14,41 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Modal, TextInput } from '@mantine/core'; +import { Divider, InputWrapper, Modal, Text, TextInput } from '@mantine/core'; import { useTranslation } from 'react-i18next'; import { queryClient } from '@/config/global'; import { globalStore } from '@/stores/global'; +import { sha } from '~build/git'; + +const AdminKey = () => { + const { t } = useTranslation(); + return ( + <TextInput + label={t('settings.adminKey')} + value={globalStore.settings.adminKey} + onChange={(e) => { + globalStore.settings.set('adminKey', e.currentTarget.value); + setTimeout(() => { + queryClient.invalidateQueries(); + queryClient.refetchQueries(); + }); + }} + required + /> + ); +}; + +const UICommitSha = () => { + const { t } = useTranslation(); + return ( + <InputWrapper label={t('settings.ui-commit-sha')}> + <Text c="gray.6" size="sm"> + {sha} + </Text> + </InputWrapper> + ); +}; export const SettingsModal = () => { const { t } = useTranslation(); @@ -30,18 +60,9 @@ export const SettingsModal = () => { centered title={t('settings.title')} > - <TextInput - label={t('settings.adminKey')} - value={globalStore.settings.adminKey} - onChange={(e) => { - globalStore.settings.set('adminKey', e.currentTarget.value); - setTimeout(() => { - queryClient.invalidateQueries(); - queryClient.refetchQueries(); - }); - }} - required - /> + <AdminKey /> + <Divider my="lg" /> + <UICommitSha /> </Modal> ); }; diff --git a/src/locales/en/common.json b/src/locales/en/common.json index 721303fcf..95b74ff11 100644 --- a/src/locales/en/common.json +++ b/src/locales/en/common.json @@ -441,7 +441,8 @@ }, "settings": { "adminKey": "Admin Key", - "title": "Settings" + "title": "Settings", + "ui-commit-sha": "UI Commit SHA" }, "ssls": { "add": { diff --git a/src/types/vite-env.d.ts b/src/types/vite-env.d.ts index 1fedc830e..299c06ccd 100644 --- a/src/types/vite-env.d.ts +++ b/src/types/vite-env.d.ts @@ -15,3 +15,4 @@ * limitations under the License. */ /// <reference types="vite/client" /> +/// <reference types="unplugin-info/client" /> diff --git a/vite.config.ts b/vite.config.ts index 1fe17391e..ba48397e2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -20,6 +20,7 @@ import observerPlugin from 'mobx-react-observer/swc-plugin'; import postcssPresetMantine from 'postcss-preset-mantine'; import postcssSimpleVars from 'postcss-simple-vars'; import UnpluginIcons from 'unplugin-icons/vite'; +import UnpluginInfo from 'unplugin-info/vite'; import { defineConfig } from 'vite'; import tsconfigPaths from 'vite-tsconfig-paths'; @@ -60,6 +61,7 @@ export default defineConfig({ compiler: 'jsx', jsx: 'react', }), + UnpluginInfo(), TanStackRouterVite({ target: 'react', autoCodeSplitting: true,