Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/lint-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Lint Auto Check

on:
pull_request:
branches:
- main
- staging
- dev

permissions:
contents: read
pull-requests: write

jobs:
lint:
name: Run Lint Auto Checks
runs-on: ubuntu-latest

steps:
# Checkout to repo
- name: Checkout code
uses: actions/checkout@v4

# Install Bun
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

# Install deps
- name: Install dependencies
run: bun install

# Run ESLint check
- name: Run ESLint
id: lint
run: bun run lint

# Comment on PR if lint fails
- name: Comment on PR if lint fails
if: failure()
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
```diff
==================================================
|| ⚠️ ESLint Checks Failed! ❌ ||
==================================================
```
Please review the errors and fix them **before requesting a review.**

**Tips:**
- Run `bun run lint` locally to see detailed issues.
- Commit fixes, push again, and this check will re-run automatically.

# Comment on PR if lint passes
- name: Comment on PR if lint passes
if: success()
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
```ini
==================================================
|| ✅ ESLint Checks Passed! 🎉 ||
==================================================
```
All linting checks completed successfully. You can now request a review.
6 changes: 4 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "Scale Manager",
"slug": "scaleManager",
"version": "1.2.2",
"version": "1.2.3",
"orientation": "portrait",
"icon": "./assets/images/noBgScaleManagerLogo.png",
"scheme": "myapp",
Expand Down Expand Up @@ -39,7 +39,9 @@
"resizeMode": "contain",
"backgroundColor": "#ffffff"
}
]
],
"expo-font",
"expo-web-browser"
],
"experiments": {
"typedRoutes": true
Expand Down
2 changes: 1 addition & 1 deletion app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function TabLayout() {
useEffect(() => {
async function checkVersion() {
const serverConf = await getServerConfig();
if (serverConf?.version && serverConf.version == "0.26") {
if (serverConf?.version && serverConf.version === "0.26") {
setHideRoutes(true);
}
}
Expand Down
5 changes: 0 additions & 5 deletions app/(tabs)/acl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ export default function ACLScreen() {
const {
// State
policy,
originalPolicy,
loading,
saving,
policyVersions,
showVersions,
editing,
editText,
showSetupGuide,
showErrorModal,
currentError,

// Actions
fetchPolicy,
Expand All @@ -41,8 +38,6 @@ export default function ACLScreen() {
// Modal controls
setShowVersions,
setShowSetupGuide,
setShowErrorModal,
setCurrentError,
setEditText,
} = useACL();

Expand Down
17 changes: 10 additions & 7 deletions app/(tabs)/apikeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MaterialIcons } from "@expo/vector-icons";
import Toast from "react-native-toast-message";
import { useApiKeys } from "@/app/funcs/apikeys";

export default function apiKeysScreen() {
export default function ApiKeysScreen() {
const {
apiKeys,
newKeyExpire,
Expand All @@ -26,7 +26,7 @@ export default function apiKeysScreen() {

useEffect(() => {
fetchApiKeys();
}, []);
}, [fetchApiKeys]);

const handleCreateKeyWithDisplay = async () => {
const result = await handleCreateKey();
Expand Down Expand Up @@ -69,8 +69,8 @@ export default function apiKeysScreen() {
visible={showKeyModal}
onRequestClose={closeKeyModal}
>
<View className="flex-1 justify-center items-center px-4">
<View className="bg-zinc-800 rounded-2xl p-6 w-full max-w-md">
<View className="flex-1 justify-center items-center px-4 bg-black/50">
<View className="bg-zinc-800 rounded-2xl p-6 w-full max-w-md shadow-2xl">
<View className="items-center mb-4">
<MaterialIcons name="vpn-key" size={48} color="#10b981" />
<Text className="text-white text-xl font-bold mt-2">
Expand All @@ -91,6 +91,7 @@ export default function apiKeysScreen() {
<TouchableOpacity
onPress={() => copyToClipboard(newApiKey!)}
className="flex-1 bg-blue-600 py-3 rounded-lg flex-row items-center justify-center"
activeOpacity={0.7}
>
<MaterialIcons name="content-copy" size={18} color="white" />
<Text className="text-white font-semibold ml-2">Copy Key</Text>
Expand All @@ -99,6 +100,7 @@ export default function apiKeysScreen() {
<TouchableOpacity
onPress={closeKeyModal}
className="flex-1 bg-zinc-600 py-3 rounded-lg"
activeOpacity={0.7}
>
<Text className="text-white font-semibold text-center">Done</Text>
</TouchableOpacity>
Expand All @@ -113,7 +115,7 @@ export default function apiKeysScreen() {
);

return (
<SafeAreaView className="flex-1 bg-zinc-900 px-4 pt-4">
<SafeAreaView className="flex-1 bg-zinc-900">
{loading ? (
<View className="flex-1 justify-center items-center">
<ActivityIndicator size="large" color="#ffffff" />
Expand All @@ -129,7 +131,7 @@ export default function apiKeysScreen() {
{/* Header */}
<View className="mb-6 flex-row justify-between items-center">
<Text className="text-white text-2xl font-bold">API Keys</Text>
<TouchableOpacity onPress={fetchApiKeys}>
<TouchableOpacity onPress={fetchApiKeys} activeOpacity={0.7}>
<MaterialIcons name="refresh" size={24} color="white" />
</TouchableOpacity>
</View>
Expand Down Expand Up @@ -170,7 +172,7 @@ export default function apiKeysScreen() {
<TouchableOpacity
onPress={handleCreateKeyWithDisplay}
className="bg-green-600 p-3 rounded-lg flex-row items-center justify-center"
activeOpacity={0.8}
activeOpacity={0.7}
>
<MaterialIcons name="add" size={18} color="white" />
<Text className="text-white text-center font-semibold ml-1">
Expand Down Expand Up @@ -265,6 +267,7 @@ export default function apiKeysScreen() {
className={`p-3 rounded-lg flex-row items-center justify-center ${
expired ? "bg-zinc-600" : "bg-red-600"
}`}
activeOpacity={0.7}
>
<MaterialIcons
name={expired ? "block" : "delete"}
Expand Down
13 changes: 0 additions & 13 deletions app/(tabs)/devices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
ActivityIndicator,
RefreshControl,
TextInput,
Modal,
} from "react-native";
import { MaterialIcons } from "@expo/vector-icons";
import { useDevices } from "@/app/funcs/devices";
Expand Down Expand Up @@ -60,18 +59,6 @@ export default function DevicesScreen() {
fetchDevices();
};

const formatDate = (dateString: string) => {
try {
return new Date(dateString).toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
});
} catch {
return "Unknown";
}
};

return (
<SafeAreaView className="flex-1 bg-zinc-900">
Expand Down
1 change: 1 addition & 0 deletions app/(tabs)/preauthkeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default function PreAuthKeysScreen() {
text1: "Copy Failed",
text2: "Could not copy to clipboard",
});
console.error(error)
}
};

Expand Down
3 changes: 0 additions & 3 deletions app/(tabs)/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
Alert,
RefreshControl,
} from "react-native";
import Toast from "react-native-toast-message";
import { MaterialIcons } from "@expo/vector-icons";
import { useRoutes } from "@/app/funcs/routes";

Expand All @@ -22,9 +21,7 @@ export default function RoutesScreen() {
handleDisableRoute,
handleEnableRoute,
routes,
setRoutes,
loading,
setLoading,
fetchRoutes
} = useRoutes();

Expand Down
1 change: 0 additions & 1 deletion app/api/acl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getServerConfig } from "../utils/getServer";
import { getApiEndpoints, makeApiRequest } from "../utils/apiUtils";

export async function getACLPolicy() {
Expand Down
3 changes: 1 addition & 2 deletions app/customScreens/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useRef } from "react";
import {
View, Text, TextInput, TouchableOpacity, SafeAreaView,
ScrollView, Animated
Animated
} from "react-native";
import { MaterialIcons } from "@expo/vector-icons";
import { useRouter, useLocalSearchParams } from "expo-router";
import { Device } from "../types";
import { useDeviceDetail } from "../funcs/deviceDetail";
import { formatDate, getTimeAgo, copyToClipboard } from "../utils/deviceUtils";
import { InfoRow } from "../components/InfoRow";
Expand Down
6 changes: 6 additions & 0 deletions app/funcs/deviceDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export function useDeviceDetail(deviceData: string | undefined) {
text1: "⚠️ Rename Error",
text2: "An error occurred while renaming",
});
console.error(error)
}
};

Expand Down Expand Up @@ -137,6 +138,7 @@ export function useDeviceDetail(deviceData: string | undefined) {
text1: "⚠️ Change Error",
text2: "An error occurred while changing user",
});
console.error(error)
}
};

Expand Down Expand Up @@ -198,6 +200,7 @@ export function useDeviceDetail(deviceData: string | undefined) {
text1: "⚠️ Add Error",
text2: "An error occurred while adding tags",
});
console.error(error)
}
};

Expand Down Expand Up @@ -239,6 +242,7 @@ export function useDeviceDetail(deviceData: string | undefined) {
text1: "⚠️ Update Error",
text2: "An error occurred while approving routes",
});
console.error(error)
}
};

Expand Down Expand Up @@ -285,6 +289,7 @@ export function useDeviceDetail(deviceData: string | undefined) {
text1: "⚠️ Update Error",
text2: "An error occurred while removing route",
});
console.error(error)
}
},
},
Expand Down Expand Up @@ -337,6 +342,7 @@ export function useDeviceDetail(deviceData: string | undefined) {
text1: "Delete Error",
text2: "An error occurred while deleting",
});
console.error(error)
}
},
},
Expand Down
3 changes: 1 addition & 2 deletions app/funcs/devices.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useState } from "react";
import { Alert } from "react-native";
import { getDevices, registerDevice } from "../api/devices";
import { getUsers } from "../api/users";
import Toast from "react-native-toast-message";
Expand Down Expand Up @@ -194,7 +193,7 @@ export function useDevices() {
);

if (fullCommandMatch) {
const username = fullCommandMatch[1];
//const username = fullCommandMatch[1];
const preAuthKey = fullCommandMatch[2];
if (preAuthKey) {
setDeviceKey(preAuthKey);
Expand Down
2 changes: 1 addition & 1 deletion app/funcs/routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { useEffect, useState } from "react";
import { useState } from "react";
import { getServerRoutes, disableRoute, enableRoute } from "../api/routes";
import Toast from "react-native-toast-message";

Expand Down
3 changes: 3 additions & 0 deletions app/funcs/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export function useUsers() {
text1: "⚠️ Add Failed",
text2: "An error occurred while adding the user.",
});
console.error(error)
}
},
},
Expand Down Expand Up @@ -205,6 +206,7 @@ export function useUsers() {
text1: "⚠️ Rename Failed",
text2: "An error occurred while renaming the user.",
});
console.error(error)
}
},
},
Expand Down Expand Up @@ -262,6 +264,7 @@ export function useUsers() {
text1: "⚠️ Delete Failed",
text2: "An error occurred while deleting the user.",
});
console.error(error)
}
};

Expand Down
1 change: 0 additions & 1 deletion app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Platform,
ActivityIndicator,
Image,
Modal,
ScrollView
} from "react-native";
import { MaterialIcons } from "@expo/vector-icons";
Expand Down
3 changes: 2 additions & 1 deletion app/utils/apiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export async function makeApiRequest(url: string, options: RequestInit = {}) {
try {
const errorData = JSON.parse(errorText);
return errorData; // Return the error data instead of null
} catch (parseError) {
} catch (error) {
console.error(error)
// If parsing fails, return a generic error object
return {
code: response.status,
Expand Down
1 change: 1 addition & 0 deletions app/utils/deviceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const copyToClipboard = async (text: string, label: string) => {
text1: "Copy Failed",
text2: "Could not copy to clipboard",
});
console.error(error)
}
};

Expand Down
Loading