Skip to content

Commit

Permalink
Merge pull request #75 from AlexSciFier/change-frontend-versioning
Browse files Browse the repository at this point in the history
Change frontend versioning
  • Loading branch information
AlexSciFier authored Sep 8, 2023
2 parents 826bc7a + 2e75820 commit dbacb97
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 15 deletions.
1 change: 1 addition & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_VERSION=$npm_package_version
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neonlink-frontend",
"version": "1.2.0",
"version": "1.4.10",
"private": true,
"dependencies": {
"@dnd-kit/core": "^6.0.8",
Expand Down
26 changes: 18 additions & 8 deletions frontend/src/components/PrivateWrapper.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import React, { useEffect } from "react";
import { Route, Routes, useLocation, useNavigate } from "react-router";
import NavBar from "./NavBar";
import { useUserCurrentStore, userCurrentKeys } from "../stores/userCurrentStore";
import { appSettingsKeys, useAppSettingsStore } from "../stores/appSettingsStore";
import {
useUserCurrentStore,
userCurrentKeys,
} from "../stores/userCurrentStore";
import {
appSettingsKeys,
useAppSettingsStore,
} from "../stores/appSettingsStore";

const Dashboard = React.lazy(() => import("../pages/dashboard"));
const NotFound = React.lazy(() => import("../pages/notFound"));
Expand All @@ -20,17 +26,21 @@ const routes = [
];

export default function PrivateWrapper() {
const [ authenticationEnabled, ] = useAppSettingsStore(appSettingsKeys.AuthenticationEnabled);
const [ forceRegistration, ] = useAppSettingsStore(appSettingsKeys.ForceRegistration);
const [ authenticated, ] = useUserCurrentStore(userCurrentKeys.Authenticated);
const { pathname,search } = useLocation();
const [authenticationEnabled] = useAppSettingsStore(
appSettingsKeys.AuthenticationEnabled
);
const [forceRegistration] = useAppSettingsStore(
appSettingsKeys.ForceRegistration
);
const [authenticated] = useUserCurrentStore(userCurrentKeys.Authenticated);
const { pathname, search, hash } = useLocation();
const navigate = useNavigate();

useEffect(() => {
if (forceRegistration) navigate("/register");
else if (authenticationEnabled && !authenticated) navigate("/login");
else navigate(pathname+search);
// eslint-disable-next-line react-hooks/exhaustive-deps
else navigate(pathname + hash + search);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [authenticated, authenticationEnabled, forceRegistration]);

return (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/helpers/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const APP_NAME = "NeonLink";
export const VERSION = "1.4.8";
export const VERSION = process.env.REACT_APP_VERSION;
export const DEF_MAX_ITEMS = 20;
export const DEF_COLUMNS = 3;
export const CARD_HEADER_STYLE = [
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/pages/settings/tabHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import React from "react";

export default function TabHeader({ title, isActive, onClick }) {
return (
<li
<a
className={`px-4 py-2 hover:bg-cyan-600/10 hover:cursor-pointer ${
isActive ? "border-b-2 border-cyan-500" : ""
}`}
onClick={onClick}
href={`#${title}`}
>
{title}
</li>
</a>
);
}
12 changes: 11 additions & 1 deletion frontend/src/pages/settings/tabView.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import TabHeader from "./tabHeader";
import AboutTab from "./tabs/aboutTab";
import GroupTab from "./tabs/groupTab/groupTab";
import MainTab from "./tabs/mainTab/mainTab";
import InterfaceTab from "./tabs/interfaceTab/interfaceTab";
import { useLocation } from "react-router";

export default function TabView() {
const location = useLocation();
const tabs = [
{
header: "Main",
Expand All @@ -27,6 +29,14 @@ export default function TabView() {

const [curentTab, setCurentTab] = useState(0);

useEffect(() => {
if (location.hash) {
let found = tabs.filter((tab) => tab.header === location.hash.slice(1));
let foundIdx = tabs.indexOf(found[0]);
setCurentTab(foundIdx);
}
}, []);

return (
<div className="md:w-2/4 w-full px-3">
<ul className="flex gap-3 w-full text-lg overflow-x-auto">
Expand Down

0 comments on commit dbacb97

Please sign in to comment.