mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-07-13 05:42:23 +02:00
add version button to settings view
This commit is contained in:
6
.github/workflows/docker-image.yml
vendored
6
.github/workflows/docker-image.yml
vendored
@ -44,6 +44,12 @@ jobs:
|
|||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=pr
|
type=ref,event=pr
|
||||||
type=sha
|
type=sha
|
||||||
|
|
||||||
|
- name: Set build env
|
||||||
|
run: |
|
||||||
|
echo "VITE_COMMIT_HASH=$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
|
||||||
|
echo "VITE_APP_VERSION=$(jq -r .version ./package.json)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
|
4
.github/workflows/pages.yml
vendored
4
.github/workflows/pages.yml
vendored
@ -37,6 +37,10 @@ jobs:
|
|||||||
cache: "npm"
|
cache: "npm"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install
|
||||||
|
- name: Set build env
|
||||||
|
run: |
|
||||||
|
echo "VITE_COMMIT_HASH=$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
|
||||||
|
echo "VITE_APP_VERSION=$(jq -r .version ./package.json)" >> $GITHUB_ENV
|
||||||
- name: Build
|
- name: Build
|
||||||
run: yarn build
|
run: yarn build
|
||||||
- name: Setup Pages
|
- name: Setup Pages
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
FROM node:18
|
FROM node:18
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . /app/
|
COPY . /app/
|
||||||
|
ENV VITE_COMMIT_HASH=""
|
||||||
|
ENV VITE_APP_VERSION="custom"
|
||||||
RUN yarn install && yarn build
|
RUN yarn install && yarn build
|
||||||
|
|
||||||
FROM nginx:stable-alpine-slim
|
FROM nginx:stable-alpine-slim
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite serve",
|
"start": "vite serve",
|
||||||
"dev": "vite serve",
|
"dev": "VITE_APP_VERSION=development vite serve",
|
||||||
"build": "tsc --project tsconfig.json && vite build",
|
"build": "tsc --project tsconfig.json && vite build",
|
||||||
"format": "prettier --ignore-path .prettierignore -w .",
|
"format": "prettier --ignore-path .prettierignore -w .",
|
||||||
"e2e": "cypress open",
|
"e2e": "cypress open",
|
||||||
|
28
src/components/version-button.tsx
Normal file
28
src/components/version-button.tsx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { Button, ButtonProps } from "@chakra-ui/react";
|
||||||
|
import { CheckIcon, ClipboardIcon } from "./icons";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
export default function VersionButton({ ...props }: Omit<ButtonProps, "children">) {
|
||||||
|
const [copied, setCopied] = useState(false);
|
||||||
|
const version = [import.meta.env.VITE_APP_VERSION, import.meta.env.VITE_COMMIT_HASH].filter(Boolean).join("-");
|
||||||
|
|
||||||
|
if (!version) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
rightIcon={copied ? <CheckIcon /> : <ClipboardIcon />}
|
||||||
|
onClick={() => {
|
||||||
|
if (navigator.clipboard) {
|
||||||
|
navigator.clipboard.writeText(version);
|
||||||
|
setCopied(true);
|
||||||
|
setTimeout(() => setCopied(false), 2000);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
Version: {version}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
@ -9,6 +9,7 @@ import PrivacySettings from "./privacy-settings";
|
|||||||
import useAppSettings from "../../hooks/use-app-settings";
|
import useAppSettings from "../../hooks/use-app-settings";
|
||||||
import { FormProvider, useForm } from "react-hook-form";
|
import { FormProvider, useForm } from "react-hook-form";
|
||||||
import VerticalPageLayout from "../../components/vertical-page-layout";
|
import VerticalPageLayout from "../../components/vertical-page-layout";
|
||||||
|
import VersionButton from "../../components/version-button";
|
||||||
|
|
||||||
export default function SettingsView() {
|
export default function SettingsView() {
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
@ -46,6 +47,7 @@ export default function SettingsView() {
|
|||||||
<Link isExternal href="https://github.com/hzrd149/nostrudel">
|
<Link isExternal href="https://github.com/hzrd149/nostrudel">
|
||||||
<GithubIcon /> Github
|
<GithubIcon /> Github
|
||||||
</Link>
|
</Link>
|
||||||
|
<VersionButton />
|
||||||
<Button
|
<Button
|
||||||
ml="auto"
|
ml="auto"
|
||||||
isLoading={form.formState.isLoading || form.formState.isValidating || form.formState.isSubmitting}
|
isLoading={form.formState.isLoading || form.formState.isValidating || form.formState.isSubmitting}
|
||||||
|
Reference in New Issue
Block a user