Skip to content

Commit

Permalink
fix: remove Buckets button from sidebar, fix tests and lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
klausborges committed Dec 17, 2024
1 parent 5c04082 commit ab23173
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 51 deletions.
9 changes: 2 additions & 7 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": [
"build",
"build-tsc",
"standalone-plugins",
"standalone"
]
"ignore": ["build", "build-tsc", "standalone-plugins", "standalone"]
},
"formatter": {
"enabled": true,
Expand Down
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@
"node": ">=20.0.0"
},
"type": "module",
"workspaces": [
"packages/*",
"plugins/*"
],
"keywords": [
"platform",
"iot",
"tagoio",
"tcore"
],
"workspaces": ["packages/*", "plugins/*"],
"keywords": ["platform", "iot", "tagoio", "tcore"],
"bugs": {
"url": "https://github.com/tago-io/tcore/issues"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/console/biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
Expand Down
17 changes: 0 additions & 17 deletions packages/console/src/Components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import { EIcon } from "../Icon/Icon.types";
import Link from "../Link/Link.tsx";
import * as Style from "./Navbar.style";

/**
* Props.
*/
interface INavbarProps {
/**
* This function will be called when the user presses the sidebar button. It should
Expand All @@ -41,25 +38,17 @@ interface INavbarProps {
* This is the main navigation bar located at the top of the page.
*/
function Navbar(props: INavbarProps) {
// const theme = useTheme();
// const updateTheme = useContext(ThemeUpdateContext);
const { logoWidth, onSidebarToggle } = props;
const navigate = useNavigate();
const theme = useTheme();

/**
* Removes the account, token, and goes back to the /console/login route.
*/
const signOut = useCallback(() => {
store.account = undefined;
store.token = "";
setLocalStorage("token", "");
navigate("/console/login");
}, [navigate]);

/**
* Renders the navbar buttons for a specific plugin.
*/
const renderNavbarButtons = (
plugin: IPluginListItem,
buttons: IPluginButtonModuleSetupOption[],
Expand Down Expand Up @@ -121,12 +110,6 @@ function Navbar(props: INavbarProps) {
<Style.RightSection>
{store.plugins.map((x) => renderNavbarButtons(x, x.buttons.navbar))}

<Link href="/console/logs">
<Button type={EButton.primary} testId="plugin-logs-button">
<Icon size="17px" icon={EIcon.scroll} />
</Button>
</Link>

<Button onClick={signOut} type={EButton.primary}>
<Icon size="17px" icon={EIcon["sign-out-alt"]} />
</Button>
Expand Down
14 changes: 7 additions & 7 deletions packages/console/src/Components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ function Sidebar(props: ISidebarProps) {
},
},
{
color: theme.bucket,
icon: EIcon.bucket,
text: "Buckets",
text: "Store",
icon: EIcon.store,
color: theme.settings,
action: {
type: "open-url",
url: "/console/buckets/",
url: "/console/pluginstore",
},
},
{
Expand All @@ -74,12 +74,12 @@ function Sidebar(props: ISidebarProps) {
},
},
{
text: "Store",
icon: EIcon.store,
text: "Logs",
icon: EIcon.scroll,
color: theme.settings,
action: {
type: "open-url",
url: "/console/pluginstore",
url: "/logs",
},
},
{
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/Types/DeviceData/DeviceData.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ function handleDates(
timezone: string,
type: "start" | "end",
): Date {
let date: any = new Date(rawDate);
let date: Date | "never" | undefined = new Date(rawDate);

if (!isDate(rawDate)) {
if (!isDate(date)) {
try {
date = parseRelativeDate(rawDate, type === "start" ? "minus" : "plus");
date = parseRelativeDate(date, type === "start" ? "minus" : "plus");
} catch (ex) {
throw new Error(`Invalid ${type} date`);
}
Expand Down
6 changes: 5 additions & 1 deletion plugins/tagoio-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
"watch": "vite",
"build": "vite build",
"build-watch": "vite build --watch",
"test": "vitest"
"test": "vitest",
"check-types": "tsc --noEmit",
"lint": "biome check .",
"format": "biome format . --write",
"lint-fix": "biome check . --write"
},
"dependencies": {
"path-browserify": "1.0.1",
Expand Down
8 changes: 4 additions & 4 deletions plugins/tagoio-integration/src/front/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function App() {
/**
* Fetches the tcore instance and sets it locally.
*/
const fetchTCore = async () => {
const fetchTCore = useCallback(async () => {
const location = window.location;
axios
.get(`${location.protocol}//${location.hostname}:${port}/tcore`)
Expand All @@ -28,7 +28,7 @@ function App() {
.catch(() => {
setLoading(false);
});
};
}, [port]);

/**
* Signs out.
Expand All @@ -40,7 +40,7 @@ function App() {
);
setTCore(null);
setLoading(false);
}, []);
}, [port]);

/**
* Tries to fetch tcore once we load the app.
Expand All @@ -49,7 +49,7 @@ function App() {
if (port) {
fetchTCore();
}
}, [port]);
}, [port, fetchTCore]);

/**
* TODO:
Expand Down
2 changes: 1 addition & 1 deletion plugins/tagoio-integration/src/front/Details/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Details(props: IDetailsProps) {
`${location.protocol}//${location.hostname}:${port}/tcore`,
{ active },
);
}, [active]);
}, [active, port]);

/**
* Called when the active changes.
Expand Down
24 changes: 24 additions & 0 deletions plugins/tagoio-integration/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"outDir": "./build-tsc",
"rootDir": "./src",
"baseUrl": ".",
"jsx": "react-jsx",
"noImplicitAny": true,
"declaration": true,
"noEmit": true,
"allowImportingTsExtensions": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler"
},
"include": ["types/index.d.ts", "src/**/*", "vite-env.d.ts"],
"exclude": ["src/**/*.test.tsx", "src/**/__mocks__/*", "node_modules"]
}
25 changes: 25 additions & 0 deletions plugins/tagoio-integration/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* PNG imports will return a string containing the path to the image.
*/
declare module "*.png" {
const content: string;
export default content;
}

/**
* GIF imports will return a string containing the path to the image.
*/
declare module "*.gif" {
const content: string;
export default content;
}

/**
* SVG imports will return the actual `<svg>` tag in a React component via SVGR.
*/
declare module "*.svg" {
import type React from "react";
const SVG: React.VFC<React.SVGProps<SVGSVGElement>>;

export default SVG;
}
1 change: 1 addition & 0 deletions plugins/tagoio-integration/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite-plugin-svgr/client" />

0 comments on commit ab23173

Please sign in to comment.