Skip to content

Commit

Permalink
feat: display current git commit link
Browse files Browse the repository at this point in the history
  • Loading branch information
Romsters committed Jan 15, 2025
1 parent 1a27876 commit 30d17e4
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ watch(
);
const portalRuntimeConfig = usePortalRuntimeConfig();
logger.log(`=== App version: ${portalRuntimeConfig.appVersion} ===`);
if (portalRuntimeConfig.gitRepoUrl && portalRuntimeConfig.gitCommitHash) {
logger.log(`=== App source: ${portalRuntimeConfig.gitRepoUrl}/commit/${portalRuntimeConfig.gitCommitHash} ===`);
}
</script>
17 changes: 17 additions & 0 deletions components/footer/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
</CommonButtonLabel>
</div>
<div class="links-container">
<CommonButtonLabel v-if="!!gitCommitUrl" as="a" :href="gitCommitUrl" target="_blank" class="footer-link">
<span class="github-link-content">
<IconsGitHub class="h-6 w-6" />
{{ portalRuntimeConfig.gitCommitHash }}
</span>
</CommonButtonLabel>
<CommonButtonLabel as="a" href="https://zksync.io/terms" target="_blank" class="footer-link">
Terms of Service
</CommonButtonLabel>
Expand All @@ -17,6 +23,7 @@
</template>

<script lang="ts" setup>
const portalRuntimeConfig = usePortalRuntimeConfig();
const eraWalletStore = useZkSyncWalletStore();
const { isCorrectNetworkSet } = storeToRefs(eraWalletStore);
const { isConnected, connectorName } = storeToRefs(useOnboardStore());
Expand All @@ -28,6 +35,12 @@ const addNetworkToWallet = async () => {
const showAddNetworkButton = computed(() => {
return isConnected.value && !isCorrectNetworkSet.value && connectorName.value !== "WalletConnect";
});
const gitCommitUrl = computed(() =>
portalRuntimeConfig.gitRepoUrl && portalRuntimeConfig.gitCommitHash
? `${portalRuntimeConfig.gitRepoUrl}/commit/${portalRuntimeConfig.gitCommitHash}`
: ""
);
</script>

<style lang="scss" scoped>
Expand All @@ -37,5 +50,9 @@ const showAddNetworkButton = computed(() => {
.links-container {
@apply flex w-max flex-wrap items-center justify-center gap-x-8 gap-y-4 whitespace-nowrap;
}
.github-link-content {
@apply flex items-center gap-1;
}
}
</style>
8 changes: 8 additions & 0 deletions components/icons/GitHub.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<svg width="19.2" height="19.2" viewBox="0 0 24 24" fill="currentColor">
<path fill="none" d="M0 0h24v24H0z"></path>
<path
d="M12 2C6.475 2 2 6.475 2 12a9.994 9.994 0 006.838 9.488c.5.087.687-.213.687-.476 0-.237-.013-1.024-.013-1.862-2.512.463-3.162-.612-3.362-1.175-.113-.288-.6-1.175-1.025-1.413-.35-.187-.85-.65-.013-.662.788-.013 1.35.725 1.538 1.025.9 1.512 2.338 1.087 2.912.825.088-.65.35-1.087.638-1.337-2.225-.25-4.55-1.113-4.55-4.938 0-1.088.387-1.987 1.025-2.688-.1-.25-.45-1.275.1-2.65 0 0 .837-.262 2.75 1.026a9.28 9.28 0 012.5-.338c.85 0 1.7.112 2.5.337 1.912-1.3 2.75-1.024 2.75-1.024.55 1.375.2 2.4.1 2.65.637.7 1.025 1.587 1.025 2.687 0 3.838-2.337 4.688-4.562 4.938.362.312.675.912.675 1.85 0 1.337-.013 2.412-.013 2.75 0 .262.188.574.688.474A10.016 10.016 0 0022 12c0-5.525-4.475-10-10-10z"
></path>
</svg>
</template>
3 changes: 2 additions & 1 deletion composables/usePortalRuntimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const usePortalRuntimeConfig = () => {
: undefined,
},
hyperchainsConfig: runtimeConfig?.hyperchainsConfig,
appVersion: runtimeConfig?.appVersion || process.env.APP_VERSION,
gitCommitHash: runtimeConfig?.gitCommitHash || process.env.GIT_COMMIT_HASH,
gitRepoUrl: runtimeConfig?.gitRepoUrl || process.env.GIT_REPO_URL,
};
};
3 changes: 2 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export default defineNuxtConfig({
"SCREENING_API_URL",
"RUDDER_KEY",
"DATAPLANE_URL",
"APP_VERSION",
"GIT_COMMIT_HASH",
"GIT_REPO_URL",
].map((key) => [`process.env.${key}`, JSON.stringify(process.env[key])])
),
css: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev:node:memory": "cross-env NODE_TYPE=memory npm run dev",
"dev:node:docker": "cross-env NODE_TYPE=dockerized npm run dev",
"dev:node:hyperchain": "ts-node --transpile-only scripts/hyperchains/empty-check.ts && cross-env NODE_TYPE=hyperchain npm run dev",
"generate": "cross-env APP_VERSION=$(git rev-parse --short HEAD) nuxt generate && npm run generate-meta",
"generate": "cross-env GIT_COMMIT_HASH=$(git rev-parse --short HEAD) GIT_REPO_URL=${$(git config --get remote.origin.url)//.git/} nuxt generate && npm run generate-meta",
"generate:node:memory": "cross-env NODE_TYPE=memory npm run generate",
"generate:node:docker": "cross-env NODE_TYPE=dockerized npm run generate",
"generate:node:hyperchain": "ts-node --transpile-only scripts/hyperchains/empty-check.ts && cross-env NODE_TYPE=hyperchain npm run generate",
Expand Down
3 changes: 2 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ declare global {
};
};
hyperchainsConfig?: HyperchainsConfig;
appVersion?: string;
gitCommitHash?: string;
gitRepoUrl?: string;
};
}
}

0 comments on commit 30d17e4

Please sign in to comment.