mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2026-01-15 12:15:02 +00:00
Don't allow launching dialogs from Run/Terminal
This commit is contained in:
@@ -152,9 +152,9 @@ export const autoComplete = (
|
||||
if (lowerCommand === "git") return Object.keys(gitCommands);
|
||||
if (directoryCommands.has(lowerCommand)) return directory;
|
||||
|
||||
const lowerProcesses = Object.keys(processDirectory).map((pid) =>
|
||||
pid.toLowerCase()
|
||||
);
|
||||
const lowerProcesses = Object.entries(processDirectory)
|
||||
.filter(([, { dialogProcess }]) => !dialogProcess)
|
||||
.map(([pid]) => pid.toLowerCase());
|
||||
|
||||
if (
|
||||
lowerProcesses.includes(lowerCommand) ||
|
||||
|
||||
@@ -768,7 +768,11 @@ const useCommandInterpreter = (
|
||||
|
||||
output.push(
|
||||
`Uptime: ${getUptime(true)}`,
|
||||
`Packages: ${Object.keys(processDirectory).length}`
|
||||
`Packages: ${
|
||||
Object.entries(processDirectory).filter(
|
||||
([, { dialogProcess }]) => !dialogProcess
|
||||
).length
|
||||
}`
|
||||
);
|
||||
|
||||
if (window.screen?.width && window.screen?.height) {
|
||||
@@ -1109,10 +1113,11 @@ const useCommandInterpreter = (
|
||||
}
|
||||
default:
|
||||
if (baseCommand) {
|
||||
const pid =
|
||||
Object.keys(processDirectory).find(
|
||||
(process) => process.toLowerCase() === lcBaseCommand
|
||||
) || resourceAliasMap[lcBaseCommand];
|
||||
const [pid] = Object.entries(processDirectory)
|
||||
.filter(([, { dialogProcess }]) => !dialogProcess)
|
||||
.find(([process]) => process.toLowerCase() === lcBaseCommand) || [
|
||||
resourceAliasMap[lcBaseCommand],
|
||||
];
|
||||
|
||||
if (pid) {
|
||||
const [file] = commandArgs;
|
||||
|
||||
@@ -115,7 +115,10 @@ const Run: FC<ComponentProcessProps> = ({ id }) => {
|
||||
}
|
||||
}
|
||||
|
||||
if ((await lstat(resourcePath)).isDirectory()) {
|
||||
if (
|
||||
resourcePid === "FileExplorer" &&
|
||||
(await lstat(resourcePath)).isDirectory()
|
||||
) {
|
||||
open("FileExplorer", { url: resourcePath }, "");
|
||||
addRunHistoryEntry();
|
||||
} else if (
|
||||
@@ -123,10 +126,13 @@ const Run: FC<ComponentProcessProps> = ({ id }) => {
|
||||
resourceUrl.length > 0 &&
|
||||
resourcePath !== resource
|
||||
) {
|
||||
const pid = Object.keys(processDirectory).find(
|
||||
(processName) =>
|
||||
processName.toLowerCase() === resourcePid.toLowerCase()
|
||||
);
|
||||
const [pid] =
|
||||
Object.entries(processDirectory)
|
||||
.filter(([, { dialogProcess }]) => !dialogProcess)
|
||||
.find(
|
||||
([processName]) =>
|
||||
processName.toLowerCase() === resourcePid.toLowerCase()
|
||||
) || [];
|
||||
|
||||
if (pid) {
|
||||
const openUrl =
|
||||
@@ -163,13 +169,16 @@ const Run: FC<ComponentProcessProps> = ({ id }) => {
|
||||
addRunHistoryEntry();
|
||||
}
|
||||
} else {
|
||||
const pid = Object.keys(processDirectory).find(
|
||||
(processName) =>
|
||||
processName.toLowerCase() ===
|
||||
(
|
||||
resourceAliasMap[resourcePath.toLowerCase()] || resourcePath
|
||||
).toLowerCase()
|
||||
);
|
||||
const [pid] =
|
||||
Object.entries(processDirectory)
|
||||
.filter(([, { dialogProcess }]) => !dialogProcess)
|
||||
.find(
|
||||
([processName]) =>
|
||||
processName.toLowerCase() ===
|
||||
(
|
||||
resourceAliasMap[resourcePath.toLowerCase()] || resourcePath
|
||||
).toLowerCase()
|
||||
) || [];
|
||||
|
||||
if (pid) {
|
||||
open(pid);
|
||||
|
||||
@@ -177,6 +177,7 @@ const directory: Processes = {
|
||||
height: 492,
|
||||
width: 392,
|
||||
},
|
||||
dialogProcess: true,
|
||||
hideTaskbarEntry: true,
|
||||
hideTitlebar: true,
|
||||
icon: "/System/Icons/unknown.webp",
|
||||
@@ -215,6 +216,7 @@ const directory: Processes = {
|
||||
height: 412,
|
||||
width: 361,
|
||||
},
|
||||
dialogProcess: true,
|
||||
hideMaximizeButton: true,
|
||||
hideMinimizeButton: true,
|
||||
icon: "",
|
||||
@@ -251,6 +253,7 @@ const directory: Processes = {
|
||||
height: 174,
|
||||
width: 397,
|
||||
},
|
||||
dialogProcess: true,
|
||||
hideMaximizeButton: true,
|
||||
hideMinimizeButton: true,
|
||||
icon: "/System/Icons/run.webp",
|
||||
@@ -327,6 +330,7 @@ const directory: Processes = {
|
||||
height: 163,
|
||||
width: 400,
|
||||
},
|
||||
dialogProcess: true,
|
||||
icon: "/System/Icons/copying.webp",
|
||||
title: "",
|
||||
},
|
||||
|
||||
@@ -75,6 +75,7 @@ export type Process = ProcessArguments &
|
||||
Component: React.ComponentType<ComponentProcessProps>;
|
||||
closing?: boolean;
|
||||
defaultSize?: Size;
|
||||
dialogProcess?: boolean;
|
||||
hasWindow?: boolean;
|
||||
icon: string;
|
||||
maximized?: boolean;
|
||||
|
||||
@@ -211,7 +211,11 @@ test.describe("has commands", () => {
|
||||
await sendToTerminal({ page }, "neofetch");
|
||||
await terminalHasText(
|
||||
{ page },
|
||||
`Packages: ${Object.keys(directory).length}`
|
||||
`Packages: ${
|
||||
Object.entries(directory).filter(
|
||||
([, { dialogProcess }]) => !dialogProcess
|
||||
).length
|
||||
}`
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -43,7 +43,9 @@ const useUrlLoader = (): void => {
|
||||
|
||||
if (app) {
|
||||
const lcAppNames = Object.fromEntries(
|
||||
Object.keys(processDirectory).map((name) => [name.toLowerCase(), name])
|
||||
Object.entries(processDirectory)
|
||||
.filter(([, { dialogProcess }]) => !dialogProcess)
|
||||
.map(([name]) => [name.toLowerCase(), name])
|
||||
);
|
||||
|
||||
loadInitialApp(lcAppNames[app.toLowerCase()]);
|
||||
|
||||
Reference in New Issue
Block a user