mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-06 23:13:17 +00:00
fix(frontend): unused vars/params
This commit is contained in:
@@ -25,12 +25,10 @@ import {
|
|||||||
X,
|
X,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useTheme } from "../contexts/ThemeContext";
|
|
||||||
import { dashboardPreferencesAPI } from "../utils/api";
|
import { dashboardPreferencesAPI } from "../utils/api";
|
||||||
|
|
||||||
// Sortable Card Item Component
|
// Sortable Card Item Component
|
||||||
const SortableCardItem = ({ card, onToggle }) => {
|
const SortableCardItem = ({ card, onToggle }) => {
|
||||||
const { isDark } = useTheme();
|
|
||||||
const {
|
const {
|
||||||
attributes,
|
attributes,
|
||||||
listeners,
|
listeners,
|
||||||
@@ -103,7 +101,6 @@ const DashboardSettingsModal = ({ isOpen, onClose }) => {
|
|||||||
const [cards, setCards] = useState([]);
|
const [cards, setCards] = useState([]);
|
||||||
const [hasChanges, setHasChanges] = useState(false);
|
const [hasChanges, setHasChanges] = useState(false);
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const { isDark } = useTheme();
|
|
||||||
|
|
||||||
const sensors = useSensors(
|
const sensors = useSensors(
|
||||||
useSensor(PointerSensor),
|
useSensor(PointerSensor),
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ const InlineGroupEdit = ({
|
|||||||
options = [],
|
options = [],
|
||||||
className = "",
|
className = "",
|
||||||
disabled = false,
|
disabled = false,
|
||||||
placeholder = "Select group...",
|
|
||||||
}) => {
|
}) => {
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
const [selectedValue, setSelectedValue] = useState(value);
|
const [selectedValue, setSelectedValue] = useState(value);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const Layout = ({ children }) => {
|
|||||||
const saved = localStorage.getItem("sidebarCollapsed");
|
const saved = localStorage.getItem("sidebarCollapsed");
|
||||||
return saved ? JSON.parse(saved) : false;
|
return saved ? JSON.parse(saved) : false;
|
||||||
});
|
});
|
||||||
const [userMenuOpen, setUserMenuOpen] = useState(false);
|
const [_userMenuOpen, setUserMenuOpen] = useState(false);
|
||||||
const [githubStars, setGithubStars] = useState(null);
|
const [githubStars, setGithubStars] = useState(null);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const {
|
const {
|
||||||
@@ -339,7 +339,7 @@ const Layout = ({ children }) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{navigation.map((item, index) => {
|
{navigation.map((item) => {
|
||||||
if (item.name) {
|
if (item.name) {
|
||||||
// Single item (Dashboard)
|
// Single item (Dashboard)
|
||||||
return (
|
return (
|
||||||
@@ -490,7 +490,7 @@ const Layout = ({ children }) => {
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
{navigation.map((item, index) => {
|
{navigation.map((item) => {
|
||||||
if (item.name) {
|
if (item.name) {
|
||||||
// Single item (Dashboard)
|
// Single item (Dashboard)
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ export const AuthProvider = ({ children }) => {
|
|||||||
} else {
|
} else {
|
||||||
return { success: false, error: data.error || "Login failed" };
|
return { success: false, error: data.error || "Login failed" };
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
return { success: false, error: "Network error occurred" };
|
return { success: false, error: "Network error occurred" };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -171,7 +171,7 @@ export const AuthProvider = ({ children }) => {
|
|||||||
} else {
|
} else {
|
||||||
return { success: false, error: data.error || "Update failed" };
|
return { success: false, error: data.error || "Update failed" };
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
return { success: false, error: "Network error occurred" };
|
return { success: false, error: "Network error occurred" };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -197,7 +197,7 @@ export const AuthProvider = ({ children }) => {
|
|||||||
error: data.error || "Password change failed",
|
error: data.error || "Password change failed",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
return { success: false, error: "Network error occurred" };
|
return { success: false, error: "Network error occurred" };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ const Dashboard = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Chart click handlers
|
// Chart click handlers
|
||||||
const handleOSChartClick = (event, elements) => {
|
const handleOSChartClick = (_, elements) => {
|
||||||
if (elements.length > 0) {
|
if (elements.length > 0) {
|
||||||
const elementIndex = elements[0].index;
|
const elementIndex = elements[0].index;
|
||||||
const osName =
|
const osName =
|
||||||
@@ -113,7 +113,7 @@ const Dashboard = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdateStatusChartClick = (event, elements) => {
|
const handleUpdateStatusChartClick = (_, elements) => {
|
||||||
if (elements.length > 0) {
|
if (elements.length > 0) {
|
||||||
const elementIndex = elements[0].index;
|
const elementIndex = elements[0].index;
|
||||||
const statusName =
|
const statusName =
|
||||||
@@ -135,7 +135,7 @@ const Dashboard = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePackagePriorityChartClick = (event, elements) => {
|
const handlePackagePriorityChartClick = (_, elements) => {
|
||||||
if (elements.length > 0) {
|
if (elements.length > 0) {
|
||||||
const elementIndex = elements[0].index;
|
const elementIndex = elements[0].index;
|
||||||
const priorityName =
|
const priorityName =
|
||||||
@@ -210,7 +210,7 @@ const Dashboard = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Fetch user's dashboard preferences
|
// Fetch user's dashboard preferences
|
||||||
const { data: preferences, refetch: refetchPreferences } = useQuery({
|
const { data: preferences } = useQuery({
|
||||||
queryKey: ["dashboardPreferences"],
|
queryKey: ["dashboardPreferences"],
|
||||||
queryFn: () => dashboardPreferencesAPI.get().then((res) => res.data),
|
queryFn: () => dashboardPreferencesAPI.get().then((res) => res.data),
|
||||||
staleTime: 5 * 60 * 1000, // Consider data fresh for 5 minutes
|
staleTime: 5 * 60 * 1000, // Consider data fresh for 5 minutes
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ const HostDetail = () => {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [showCredentialsModal, setShowCredentialsModal] = useState(false);
|
const [showCredentialsModal, setShowCredentialsModal] = useState(false);
|
||||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||||
const [isEditingFriendlyName, setIsEditingFriendlyName] = useState(false);
|
|
||||||
const [editedFriendlyName, setEditedFriendlyName] = useState("");
|
|
||||||
const [showAllUpdates, setShowAllUpdates] = useState(false);
|
const [showAllUpdates, setShowAllUpdates] = useState(false);
|
||||||
const [activeTab, setActiveTab] = useState(() => {
|
const [activeTab, setActiveTab] = useState(() => {
|
||||||
// Restore tab state from localStorage
|
// Restore tab state from localStorage
|
||||||
@@ -482,7 +480,7 @@ const HostDetail = () => {
|
|||||||
DNS Servers
|
DNS Servers
|
||||||
</p>
|
</p>
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
{host.dns_servers.map((dns, index) => (
|
{host.dns_servers.map((dns) => (
|
||||||
<p
|
<p
|
||||||
key={dns}
|
key={dns}
|
||||||
className="font-medium text-secondary-900 dark:text-white font-mono text-sm"
|
className="font-medium text-secondary-900 dark:text-white font-mono text-sm"
|
||||||
@@ -502,7 +500,7 @@ const HostDetail = () => {
|
|||||||
Network Interfaces
|
Network Interfaces
|
||||||
</p>
|
</p>
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
{host.network_interfaces.map((iface, index) => (
|
{host.network_interfaces.map((iface) => (
|
||||||
<p
|
<p
|
||||||
key={iface.name}
|
key={iface.name}
|
||||||
className="font-medium text-secondary-900 dark:text-white text-sm"
|
className="font-medium text-secondary-900 dark:text-white text-sm"
|
||||||
@@ -815,7 +813,7 @@ const HostDetail = () => {
|
|||||||
{(showAllUpdates
|
{(showAllUpdates
|
||||||
? host.update_history
|
? host.update_history
|
||||||
: host.update_history.slice(0, 5)
|
: host.update_history.slice(0, 5)
|
||||||
).map((update, index) => (
|
).map((update) => (
|
||||||
<tr
|
<tr
|
||||||
key={update.id}
|
key={update.id}
|
||||||
className="hover:bg-secondary-50 dark:hover:bg-secondary-700"
|
className="hover:bg-secondary-50 dark:hover:bg-secondary-700"
|
||||||
@@ -1028,7 +1026,7 @@ const CredentialsModal = ({ host, isOpen, onClose }) => {
|
|||||||
if (!successful) {
|
if (!successful) {
|
||||||
throw new Error("Copy command failed");
|
throw new Error("Copy command failed");
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch {
|
||||||
// If all else fails, show the text in a prompt
|
// If all else fails, show the text in a prompt
|
||||||
prompt("Copy this command:", text);
|
prompt("Copy this command:", text);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1041,50 +1039,8 @@ const CredentialsModal = ({ host, isOpen, onClose }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSetupCommands = () => {
|
|
||||||
// Get current time for crontab scheduling
|
|
||||||
const now = new Date();
|
|
||||||
const currentMinute = now.getMinutes();
|
|
||||||
const currentHour = now.getHours();
|
|
||||||
|
|
||||||
return `# Run this on the target host: ${host?.friendly_name}
|
|
||||||
|
|
||||||
echo "🔄 Setting up PatchMon agent..."
|
|
||||||
|
|
||||||
# Download and install agent
|
|
||||||
echo "📥 Downloading agent script..."
|
|
||||||
curl -o /tmp/patchmon-agent.sh ${serverUrl}/api/v1/hosts/agent/download
|
|
||||||
sudo mkdir -p /etc/patchmon
|
|
||||||
sudo mv /tmp/patchmon-agent.sh /usr/local/bin/patchmon-agent.sh
|
|
||||||
sudo chmod +x /usr/local/bin/patchmon-agent.sh
|
|
||||||
|
|
||||||
# Configure credentials
|
|
||||||
echo "🔑 Configuring API credentials..."
|
|
||||||
sudo /usr/local/bin/patchmon-agent.sh configure "${host?.apiId}" "${host?.apiKey}"
|
|
||||||
|
|
||||||
# Test configuration
|
|
||||||
echo "🧪 Testing configuration..."
|
|
||||||
sudo /usr/local/bin/patchmon-agent.sh test
|
|
||||||
|
|
||||||
# Send initial update
|
|
||||||
echo "📊 Sending initial package data..."
|
|
||||||
sudo /usr/local/bin/patchmon-agent.sh update
|
|
||||||
|
|
||||||
# Setup crontab starting at current time
|
|
||||||
echo "⏰ Setting up hourly crontab starting at ${currentHour.toString().padStart(2, "0")}:${currentMinute.toString().padStart(2, "0")}..."
|
|
||||||
echo "${currentMinute} * * * * /usr/local/bin/patchmon-agent.sh update >/dev/null 2>&1" | sudo crontab -
|
|
||||||
|
|
||||||
echo "✅ PatchMon agent setup complete!"
|
|
||||||
echo " - Agent installed: /usr/local/bin/patchmon-agent.sh"
|
|
||||||
echo " - Config directory: /etc/patchmon/"
|
|
||||||
echo " - Updates: Every hour via crontab (starting at ${currentHour.toString().padStart(2, "0")}:${currentMinute.toString().padStart(2, "0")})"
|
|
||||||
echo " - View logs: tail -f /var/log/patchmon-agent.log"`;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!isOpen || !host) return null;
|
if (!isOpen || !host) return null;
|
||||||
|
|
||||||
const commands = getSetupCommands();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
|
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
|
||||||
<div className="bg-white dark:bg-secondary-800 rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto">
|
<div className="bg-white dark:bg-secondary-800 rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import { OSIcon } from "../utils/osIcons.jsx";
|
|||||||
// Add Host Modal Component
|
// Add Host Modal Component
|
||||||
const AddHostModal = ({ isOpen, onClose, onSuccess }) => {
|
const AddHostModal = ({ isOpen, onClose, onSuccess }) => {
|
||||||
const friendlyNameId = useId();
|
const friendlyNameId = useId();
|
||||||
const hostGroupId = useId();
|
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
friendly_name: "",
|
friendly_name: "",
|
||||||
hostGroupId: "",
|
hostGroupId: "",
|
||||||
@@ -277,7 +276,7 @@ const CredentialsModal = ({ host, isOpen, onClose }) => {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error("Copy command failed");
|
throw new Error("Copy command failed");
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch {
|
||||||
// If all else fails, show the text in a prompt
|
// If all else fails, show the text in a prompt
|
||||||
prompt(`Copy this ${label.toLowerCase()}:`, text);
|
prompt(`Copy this ${label.toLowerCase()}:`, text);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -796,7 +795,6 @@ const Hosts = () => {
|
|||||||
const hostGroupFilterId = useId();
|
const hostGroupFilterId = useId();
|
||||||
const statusFilterId = useId();
|
const statusFilterId = useId();
|
||||||
const osFilterId = useId();
|
const osFilterId = useId();
|
||||||
const bulkHostGroupId = useId();
|
|
||||||
const [showAddModal, setShowAddModal] = useState(false);
|
const [showAddModal, setShowAddModal] = useState(false);
|
||||||
const [selectedHosts, setSelectedHosts] = useState([]);
|
const [selectedHosts, setSelectedHosts] = useState([]);
|
||||||
const [showBulkAssignModal, setShowBulkAssignModal] = useState(false);
|
const [showBulkAssignModal, setShowBulkAssignModal] = useState(false);
|
||||||
@@ -915,7 +913,7 @@ const Hosts = () => {
|
|||||||
// Use the existing configuration
|
// Use the existing configuration
|
||||||
return savedConfig;
|
return savedConfig;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
// If there's an error parsing the config, clear it and use default
|
// If there's an error parsing the config, clear it and use default
|
||||||
localStorage.removeItem("hosts-column-config");
|
localStorage.removeItem("hosts-column-config");
|
||||||
return defaultConfig;
|
return defaultConfig;
|
||||||
@@ -952,7 +950,7 @@ const Hosts = () => {
|
|||||||
console.log("bulkUpdateGroupMutation success:", data);
|
console.log("bulkUpdateGroupMutation success:", data);
|
||||||
|
|
||||||
// Update the cache with the new host data
|
// Update the cache with the new host data
|
||||||
if (data && data.hosts) {
|
if (data?.hosts) {
|
||||||
queryClient.setQueryData(["hosts"], (oldData) => {
|
queryClient.setQueryData(["hosts"], (oldData) => {
|
||||||
if (!oldData) return oldData;
|
if (!oldData) return oldData;
|
||||||
return oldData.map((host) => {
|
return oldData.map((host) => {
|
||||||
@@ -976,17 +974,6 @@ const Hosts = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Toggle auto-update mutation
|
|
||||||
const toggleAutoUpdateMutation = useMutation({
|
|
||||||
mutationFn: ({ hostId, auto_update }) =>
|
|
||||||
adminHostsAPI
|
|
||||||
.toggleAutoUpdate(hostId, auto_update)
|
|
||||||
.then((res) => res.data),
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries(["hosts"]);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateFriendlyNameMutation = useMutation({
|
const updateFriendlyNameMutation = useMutation({
|
||||||
mutationFn: ({ hostId, friendlyName }) =>
|
mutationFn: ({ hostId, friendlyName }) =>
|
||||||
adminHostsAPI
|
adminHostsAPI
|
||||||
@@ -1522,24 +1509,6 @@ const Hosts = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const getStatusColor = (host) => {
|
|
||||||
if (host.isStale) return "text-danger-600";
|
|
||||||
if (host.updatesCount > 0) return "text-warning-600";
|
|
||||||
return "text-success-600";
|
|
||||||
};
|
|
||||||
|
|
||||||
const getStatusIcon = (host) => {
|
|
||||||
if (host.isStale) return <AlertTriangle className="h-5 w-5" />;
|
|
||||||
if (host.updatesCount > 0) return <Clock className="h-5 w-5" />;
|
|
||||||
return <CheckCircle className="h-5 w-5" />;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getStatusText = (host) => {
|
|
||||||
if (host.isStale) return "Stale";
|
|
||||||
if (host.updatesCount > 0) return "Needs Updates";
|
|
||||||
return "Up to Date";
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-[calc(100vh-7rem)] flex flex-col overflow-hidden">
|
<div className="h-[calc(100vh-7rem)] flex flex-col overflow-hidden">
|
||||||
{/* Page Header */}
|
{/* Page Header */}
|
||||||
@@ -2137,7 +2106,7 @@ const BulkAssignModal = ({
|
|||||||
{selectedHosts.length !== 1 ? "s" : ""}:
|
{selectedHosts.length !== 1 ? "s" : ""}:
|
||||||
</p>
|
</p>
|
||||||
<div className="max-h-32 overflow-y-auto bg-secondary-50 rounded-md p-3">
|
<div className="max-h-32 overflow-y-auto bg-secondary-50 rounded-md p-3">
|
||||||
{selectedHostNames.map((friendlyName, index) => (
|
{selectedHostNames.map((friendlyName) => (
|
||||||
<div key={friendlyName} className="text-sm text-secondary-700">
|
<div key={friendlyName} className="text-sm text-secondary-700">
|
||||||
• {friendlyName}
|
• {friendlyName}
|
||||||
</div>
|
</div>
|
||||||
@@ -2247,7 +2216,7 @@ const BulkDeleteModal = ({
|
|||||||
Hosts to be deleted:
|
Hosts to be deleted:
|
||||||
</p>
|
</p>
|
||||||
<div className="max-h-32 overflow-y-auto bg-secondary-50 dark:bg-secondary-700 rounded-md p-3">
|
<div className="max-h-32 overflow-y-auto bg-secondary-50 dark:bg-secondary-700 rounded-md p-3">
|
||||||
{selectedHostNames.map((friendlyName, index) => (
|
{selectedHostNames.map((friendlyName) => (
|
||||||
<div
|
<div
|
||||||
key={friendlyName}
|
key={friendlyName}
|
||||||
className="text-sm text-secondary-700 dark:text-secondary-300"
|
className="text-sm text-secondary-700 dark:text-secondary-300"
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ const Packages = () => {
|
|||||||
const handleAffectedHostsClick = (pkg) => {
|
const handleAffectedHostsClick = (pkg) => {
|
||||||
const affectedHosts = pkg.affectedHosts || [];
|
const affectedHosts = pkg.affectedHosts || [];
|
||||||
const hostIds = affectedHosts.map((host) => host.hostId);
|
const hostIds = affectedHosts.map((host) => host.hostId);
|
||||||
const hostNames = affectedHosts.map((host) => host.friendlyName);
|
|
||||||
|
|
||||||
// Create URL with selected hosts and filter
|
// Create URL with selected hosts and filter
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ const Profile = () => {
|
|||||||
text: result.error || "Failed to update profile",
|
text: result.error || "Failed to update profile",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
setMessage({ type: "error", text: "Network error occurred" });
|
setMessage({ type: "error", text: "Network error occurred" });
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
@@ -118,7 +118,7 @@ const Profile = () => {
|
|||||||
text: result.error || "Failed to change password",
|
text: result.error || "Failed to change password",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
setMessage({ type: "error", text: "Network error occurred" });
|
setMessage({ type: "error", text: "Network error occurred" });
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
@@ -545,7 +545,6 @@ const TfaTab = () => {
|
|||||||
const [verificationToken, setVerificationToken] = useState("");
|
const [verificationToken, setVerificationToken] = useState("");
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [backupCodes, setBackupCodes] = useState([]);
|
const [backupCodes, setBackupCodes] = useState([]);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
const [message, setMessage] = useState({ type: "", text: "" });
|
const [message, setMessage] = useState({ type: "", text: "" });
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
@@ -558,7 +557,7 @@ const TfaTab = () => {
|
|||||||
// Setup TFA mutation
|
// Setup TFA mutation
|
||||||
const setupMutation = useMutation({
|
const setupMutation = useMutation({
|
||||||
mutationFn: () => tfaAPI.setup().then((res) => res.data),
|
mutationFn: () => tfaAPI.setup().then((res) => res.data),
|
||||||
onSuccess: (data) => {
|
onSuccess: () => {
|
||||||
setSetupStep("setup");
|
setSetupStep("setup");
|
||||||
setMessage({
|
setMessage({
|
||||||
type: "info",
|
type: "info",
|
||||||
@@ -688,7 +687,7 @@ const TfaTab = () => {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error("Copy command failed");
|
throw new Error("Copy command failed");
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch {
|
||||||
// If all else fails, show the text in a prompt
|
// If all else fails, show the text in a prompt
|
||||||
prompt("Copy this text:", text);
|
prompt("Copy this text:", text);
|
||||||
setMessage({
|
setMessage({
|
||||||
|
|||||||
@@ -29,18 +29,13 @@ const Settings = () => {
|
|||||||
const repoPublicId = useId();
|
const repoPublicId = useId();
|
||||||
const repoPrivateId = useId();
|
const repoPrivateId = useId();
|
||||||
const useCustomSshKeyId = useId();
|
const useCustomSshKeyId = useId();
|
||||||
const isDefaultId = useId();
|
|
||||||
const protocolId = useId();
|
const protocolId = useId();
|
||||||
const hostId = useId();
|
const hostId = useId();
|
||||||
const portId = useId();
|
const portId = useId();
|
||||||
const updateIntervalId = useId();
|
const updateIntervalId = useId();
|
||||||
const defaultRoleId = useId();
|
const defaultRoleId = useId();
|
||||||
const repositoryTypeId = useId();
|
|
||||||
const githubRepoUrlId = useId();
|
const githubRepoUrlId = useId();
|
||||||
const sshKeyPathId = useId();
|
const sshKeyPathId = useId();
|
||||||
const versionId = useId();
|
|
||||||
const releaseNotesId = useId();
|
|
||||||
const scriptContentId = useId();
|
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
serverProtocol: "http",
|
serverProtocol: "http",
|
||||||
serverHost: "localhost",
|
serverHost: "localhost",
|
||||||
@@ -77,13 +72,6 @@ const Settings = () => {
|
|||||||
|
|
||||||
// Agent version management state
|
// Agent version management state
|
||||||
const [showAgentVersionModal, setShowAgentVersionModal] = useState(false);
|
const [showAgentVersionModal, setShowAgentVersionModal] = useState(false);
|
||||||
const [editingAgentVersion, setEditingAgentVersion] = useState(null);
|
|
||||||
const [agentVersionForm, setAgentVersionForm] = useState({
|
|
||||||
version: "",
|
|
||||||
releaseNotes: "",
|
|
||||||
scriptContent: "",
|
|
||||||
isDefault: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Version checking state
|
// Version checking state
|
||||||
const [versionInfo, setVersionInfo] = useState({
|
const [versionInfo, setVersionInfo] = useState({
|
||||||
@@ -147,7 +135,7 @@ const Settings = () => {
|
|||||||
mutationFn: (data) => {
|
mutationFn: (data) => {
|
||||||
return settingsAPI.update(data).then((res) => res.data);
|
return settingsAPI.update(data).then((res) => res.data);
|
||||||
},
|
},
|
||||||
onSuccess: (data) => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries(["settings"]);
|
queryClient.invalidateQueries(["settings"]);
|
||||||
setIsDirty(false);
|
setIsDirty(false);
|
||||||
setErrors({});
|
setErrors({});
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ const AddUserModal = ({ isOpen, onClose, onUserCreated, roles }) => {
|
|||||||
if (roles && Array.isArray(roles) && roles.length > 0) {
|
if (roles && Array.isArray(roles) && roles.length > 0) {
|
||||||
payload.role = formData.role;
|
payload.role = formData.role;
|
||||||
}
|
}
|
||||||
const response = await adminUsersAPI.create(payload);
|
await adminUsersAPI.create(payload);
|
||||||
onUserCreated();
|
onUserCreated();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err.response?.data?.error || "Failed to create user");
|
setError(err.response?.data?.error || "Failed to create user");
|
||||||
|
|||||||
Reference in New Issue
Block a user