-
-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
227 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::path::PathBuf; | ||
|
||
use atuin_client::{encryption, record::sqlite_store::SqliteStore, settings::Settings}; | ||
use atuin_dotfiles::{shell::Alias, store::AliasStore}; | ||
|
||
#[tauri::command] | ||
pub async fn aliases() -> Result<Vec<Alias>, String> { | ||
let settings = Settings::new().map_err(|e| e.to_string())?; | ||
|
||
let record_store_path = PathBuf::from(settings.record_store_path.as_str()); | ||
let sqlite_store = SqliteStore::new(record_store_path, settings.local_timeout) | ||
.await | ||
.map_err(|e| e.to_string())?; | ||
|
||
let encryption_key: [u8; 32] = encryption::load_key(&settings) | ||
.map_err(|e| format!("could not load encryption key: {}", e.to_string()))? | ||
.into(); | ||
|
||
let host_id = Settings::host_id().expect("failed to get host_id"); | ||
|
||
let alias_store = AliasStore::new(sqlite_store, host_id, encryption_key); | ||
|
||
let aliases = alias_store | ||
.aliases() | ||
.await | ||
.map_err(|e| format!("failed to load aliases: {}", e.to_string()))?; | ||
|
||
Ok(aliases) | ||
} |
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 @@ | ||
pub mod aliases; |
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
Empty file.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,76 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { invoke } from "@tauri-apps/api/core"; | ||
|
||
function loadAliases(setAliases: React.Dispatch<React.SetStateAction<any[]>>) { | ||
invoke("aliases").then((aliases: any) => { | ||
setAliases(aliases); | ||
}); | ||
} | ||
|
||
export default function Aliases() { | ||
let [aliases, setAliases] = useState([]); | ||
|
||
useEffect(() => { | ||
loadAliases(setAliases); | ||
}, []); | ||
|
||
return ( | ||
<div className="pt-10"> | ||
<div className="sm:flex sm:items-center"> | ||
<div className="sm:flex-auto"> | ||
<h1 className="text-base font-semibold leading-6 text-gray-900"> | ||
Aliases | ||
</h1> | ||
<p className="mt-2 text-sm text-gray-700"> | ||
All configured shell aliases. Aliases allow you to condense long | ||
commands into short, easy-to-remember commands. | ||
</p> | ||
</div> | ||
<div className="mt-4 sm:ml-16 sm:mt-0 flex-row"> | ||
<button | ||
type="button" | ||
className="block rounded-md bg-indigo-600 px-3 py-2 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" | ||
> | ||
Add | ||
</button> | ||
</div> | ||
</div> | ||
<div className="mt-8 flow-root"> | ||
<div className="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> | ||
<div className="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8"> | ||
<table className="min-w-full divide-y divide-gray-300"> | ||
<thead> | ||
<tr className="divide-x divide-gray-200"> | ||
<th | ||
scope="col" | ||
className="py-3.5 pl-4 pr-4 text-left text-sm font-semibold text-gray-900 sm:pl-0" | ||
> | ||
Name | ||
</th> | ||
<th | ||
scope="col" | ||
className="px-4 py-3.5 text-left text-sm font-semibold text-gray-900" | ||
> | ||
Value | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody className="divide-y divide-gray-200 bg-white"> | ||
{aliases.map((person) => ( | ||
<tr key={person.name} className="divide-x divide-gray-200"> | ||
<td className="whitespace-nowrap py-4 pl-4 pr-4 text-sm font-medium text-gray-900 sm:pl-0"> | ||
{person.name} | ||
</td> | ||
<td className="whitespace-nowrap p-4 text-sm text-gray-500"> | ||
{person.value} | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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,35 @@ | ||
import { Cog6ToothIcon } from "@heroicons/react/24/outline"; | ||
|
||
import Aliases from "@/components/dotfiles/Aliases"; | ||
|
||
function Header() { | ||
return ( | ||
<div className="md:flex md:items-center md:justify-between"> | ||
<div className="min-w-0 flex-1"> | ||
<h2 className="text-2xl font-bold leading-7 text-gray-900 sm:truncate sm:text-3xl sm:tracking-tight"> | ||
Dotfiles | ||
</h2> | ||
</div> | ||
<div className="mt-4 flex md:ml-4 md:mt-0"> | ||
<button | ||
type="button" | ||
className="inline-flex items-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" | ||
> | ||
Import | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default function Dotfiles() { | ||
return <div></div>; | ||
return ( | ||
<div className="pl-60"> | ||
<div className="p-10"> | ||
<Header /> | ||
Manage your shell aliases, variables and paths | ||
<Aliases /> | ||
</div> | ||
</div> | ||
); | ||
} |
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
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