forked from oliverschwendener/ueli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Windows Application Search settings
- Loading branch information
1 parent
6610b8f
commit e534074
Showing
5 changed files
with
187 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/renderer/Extensions/ApplicationSearch/Windows/FileExtensions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { useExtensionSetting } from "@Core/Hooks"; | ||
import { Button, Field, Input, Tooltip } from "@fluentui/react-components"; | ||
import { AddRegular, DismissRegular } from "@fluentui/react-icons"; | ||
import { useState } from "react"; | ||
|
||
export const FileExtensions = () => { | ||
const [newFileExtension, setNewFileExtension] = useState<string>(""); | ||
|
||
const { value: fileExtensions, updateValue: setFileExtensions } = useExtensionSetting<string[]>({ | ||
extensionId: "ApplicationSearch", | ||
key: "windowsFileExtensions", | ||
}); | ||
|
||
const removeFileExtension = (fileExtension: string) => { | ||
setFileExtensions(fileExtensions.filter((f) => f !== fileExtension)); | ||
}; | ||
|
||
const addFileExtension = (fileExtension: string) => { | ||
setFileExtensions([...fileExtensions, fileExtension]); | ||
setNewFileExtension(""); | ||
}; | ||
|
||
return ( | ||
<Field label="File Extensions (e.g.: lnk, exe)"> | ||
<div style={{ display: "flex", flexDirection: "column", gap: 5 }}> | ||
{fileExtensions.map((fileExtension) => ( | ||
<Input | ||
readOnly | ||
value={fileExtension} | ||
contentAfter={ | ||
<Tooltip content="Remove" relationship="label"> | ||
<Button | ||
size="small" | ||
appearance="subtle" | ||
icon={<DismissRegular />} | ||
onClick={() => removeFileExtension(fileExtension)} | ||
/> | ||
</Tooltip> | ||
} | ||
/> | ||
))} | ||
<Input | ||
value={newFileExtension} | ||
placeholder="Add another file extension" | ||
onChange={(_, { value }) => setNewFileExtension(value)} | ||
contentAfter={ | ||
<Tooltip content="Add" relationship="label"> | ||
<Button | ||
appearance="subtle" | ||
size="small" | ||
icon={<AddRegular />} | ||
onClick={() => addFileExtension(newFileExtension)} | ||
/> | ||
</Tooltip> | ||
} | ||
/> | ||
</div> | ||
</Field> | ||
); | ||
}; |
79 changes: 79 additions & 0 deletions
79
src/renderer/Extensions/ApplicationSearch/Windows/Folders.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { useContextBridge, useExtensionSetting } from "@Core/Hooks"; | ||
import { Button, Field, Input, Tooltip } from "@fluentui/react-components"; | ||
import { AddRegular, DismissRegular, FolderRegular } from "@fluentui/react-icons"; | ||
import { useState } from "react"; | ||
|
||
export const Folders = () => { | ||
const { contextBridge } = useContextBridge(); | ||
|
||
const { value: folders, updateValue: setFolders } = useExtensionSetting<string[]>({ | ||
extensionId: "ApplicationSearch", | ||
key: "windowsFolders", | ||
}); | ||
|
||
const [newFolder, setNewFolder] = useState<string>(""); | ||
|
||
const removeFolder = (folder: string) => { | ||
setFolders(folders.filter((f) => f !== folder)); | ||
}; | ||
|
||
const addFolder = (folder: string) => { | ||
setFolders([...folders, folder]); | ||
setNewFolder(""); | ||
}; | ||
|
||
const chooseFolder = async () => { | ||
const result = await contextBridge.showOpenDialog({ properties: ["openDirectory"] }); | ||
if (!result.canceled && result.filePaths.length) { | ||
setNewFolder(result.filePaths[0]); | ||
} | ||
}; | ||
|
||
return ( | ||
<Field label="Folders"> | ||
<div style={{ display: "flex", flexDirection: "column", gap: 5 }}> | ||
{folders.map((folder) => ( | ||
<Input | ||
readOnly | ||
value={folder} | ||
contentAfter={ | ||
<Tooltip content="Remove" relationship="label"> | ||
<Button | ||
size="small" | ||
appearance="subtle" | ||
icon={<DismissRegular />} | ||
onClick={() => removeFolder(folder)} | ||
/> | ||
</Tooltip> | ||
} | ||
/> | ||
))} | ||
<Input | ||
value={newFolder} | ||
placeholder="Add another folder" | ||
onChange={(_, { value }) => setNewFolder(value)} | ||
contentAfter={ | ||
<> | ||
<Tooltip content="Choose folder" relationship="label"> | ||
<Button | ||
appearance="subtle" | ||
size="small" | ||
icon={<FolderRegular />} | ||
onClick={() => chooseFolder()} | ||
/> | ||
</Tooltip> | ||
<Tooltip content="Add" relationship="label"> | ||
<Button | ||
appearance="subtle" | ||
size="small" | ||
icon={<AddRegular />} | ||
onClick={() => addFolder(newFolder)} | ||
/> | ||
</Tooltip> | ||
</> | ||
} | ||
/> | ||
</div> | ||
</Field> | ||
); | ||
}; |
16 changes: 15 additions & 1 deletion
16
src/renderer/Extensions/ApplicationSearch/Windows/WindowsSettings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
import { Section } from "@Core/Settings/Section"; | ||
import { SectionList } from "@Core/Settings/SectionList"; | ||
import { FileExtensions } from "./FileExtensions"; | ||
import { Folders } from "./Folders"; | ||
|
||
export const WindowsSettings = () => { | ||
return <>TODO</>; | ||
return ( | ||
<SectionList> | ||
<Section> | ||
<Folders /> | ||
</Section> | ||
<Section> | ||
<FileExtensions /> | ||
</Section> | ||
</SectionList> | ||
); | ||
}; |