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
592 changes: 348 additions & 244 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ version = "0.0.1"
[workspace.dependencies]
async-trait = "0.1.83"
bytes = { version = "1.1" }
chrono = { version = "0.4.38", features = ["serde"] }
chrono = { version = "0.4.38, <0.4.40", features = ["serde"] }
clap = { version = "4.5", features = ["derive"] }
delta_kernel = { version = "0.5.0", features = [
delta_kernel = { version = "0.7", features = [
"tokio",
"developer-visibility",
"default-engine",
"arrow_54",
] }
futures = { version = "0.3.31" }
http = { version = "1.2" }
Expand Down
141 changes: 141 additions & 0 deletions app/src-tauri/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
use delta_sharing_common::models::catalogs::v1::{CatalogInfo, CreateCatalogRequest};
use delta_sharing_common::models::credentials::v1::{
CreateCredentialRequest, CredentialInfo, Purpose,
};
use delta_sharing_common::models::external_locations::v1::{
CreateExternalLocationRequest, ExternalLocationInfo,
};
use delta_sharing_common::models::recipients::v1::{CreateRecipientRequest, RecipientInfo};
use delta_sharing_common::models::schemas::v1::{CreateSchemaRequest, SchemaInfo};
use delta_sharing_common::models::shares::v1::{CreateShareRequest, ShareInfo};
use delta_sharing_common::rest::client::UnityCatalogClient;
use futures::TryStreamExt;
use tauri::State;
Expand Down Expand Up @@ -78,3 +86,136 @@ pub async fn delete_schema(
) -> Result<()> {
Ok(state.schemas().delete(catalog, name, force).await?)
}

#[tauri::command]
pub async fn list_credentials(
state: State<'_, UnityCatalogClient>,
purpose: Option<Purpose>,
max_results: Option<i32>,
) -> Result<Vec<CredentialInfo>> {
Ok(state
.credentials()
.list(purpose, max_results)
.try_collect()
.await?)
}

#[tauri::command]
pub async fn get_credential(
state: State<'_, UnityCatalogClient>,
name: String,
) -> Result<CredentialInfo> {
Ok(state.credentials().get(name).await?)
}

#[tauri::command]
pub async fn create_credential(
state: State<'_, UnityCatalogClient>,
request: CreateCredentialRequest,
) -> Result<CredentialInfo> {
Ok(state.credentials().create_credential(&request).await?)
}

#[tauri::command]
pub async fn delete_credential(state: State<'_, UnityCatalogClient>, name: String) -> Result<()> {
Ok(state.credentials().delete(name).await?)
}

#[tauri::command]
pub async fn list_external_locations(
state: State<'_, UnityCatalogClient>,
max_results: Option<i32>,
) -> Result<Vec<ExternalLocationInfo>> {
Ok(state
.external_locations()
.list(max_results)
.try_collect()
.await?)
}

#[tauri::command]
pub async fn get_external_location(
state: State<'_, UnityCatalogClient>,
name: String,
) -> Result<ExternalLocationInfo> {
Ok(state.external_locations().get(name).await?)
}

#[tauri::command]
pub async fn create_external_location(
state: State<'_, UnityCatalogClient>,
request: CreateExternalLocationRequest,
) -> Result<ExternalLocationInfo> {
Ok(state
.external_locations()
.create_external_location(&request)
.await?)
}

#[tauri::command]
pub async fn delete_external_location(
state: State<'_, UnityCatalogClient>,
name: String,
force: Option<bool>,
) -> Result<()> {
Ok(state.external_locations().delete(name, force).await?)
}

#[tauri::command]
pub async fn list_recipients(
state: State<'_, UnityCatalogClient>,
max_results: Option<i32>,
) -> Result<Vec<RecipientInfo>> {
Ok(state.recipients().list(max_results).try_collect().await?)
}

#[tauri::command]
pub async fn get_recipient(
state: State<'_, UnityCatalogClient>,
name: String,
) -> Result<RecipientInfo> {
Ok(state.recipients().get(name).await?)
}

#[tauri::command]
pub async fn create_recipient(
state: State<'_, UnityCatalogClient>,
request: CreateRecipientRequest,
) -> Result<RecipientInfo> {
Ok(state.recipients().create_recipient(&request).await?)
}

#[tauri::command]
pub async fn delete_recipient(state: State<'_, UnityCatalogClient>, name: String) -> Result<()> {
Ok(state.recipients().delete(name).await?)
}

#[tauri::command]
pub async fn list_shares(
state: State<'_, UnityCatalogClient>,
max_results: Option<i32>,
) -> Result<Vec<ShareInfo>> {
Ok(state.shares().list(max_results).try_collect().await?)
}

#[tauri::command]
pub async fn get_share(
state: State<'_, UnityCatalogClient>,
name: String,
include_shared_data: Option<bool>,
) -> Result<ShareInfo> {
Ok(state.shares().get(name, include_shared_data).await?)
}

#[tauri::command]
pub async fn create_share(
state: State<'_, UnityCatalogClient>,
request: CreateShareRequest,
) -> Result<ShareInfo> {
Ok(state.shares().create_share(&request).await?)
}

#[tauri::command]
pub async fn delete_share(state: State<'_, UnityCatalogClient>, name: String) -> Result<()> {
Ok(state.shares().delete(name).await?)
}
16 changes: 16 additions & 0 deletions app/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ pub fn run() {
client::get_schema,
client::create_schema,
client::delete_schema,
client::list_credentials,
client::get_credential,
client::create_credential,
client::delete_credential,
client::list_external_locations,
client::get_external_location,
client::create_external_location,
client::delete_external_location,
client::list_recipients,
client::get_recipient,
client::create_recipient,
client::delete_recipient,
client::list_shares,
client::get_share,
client::create_share,
client::delete_share,
])
.setup(|app| {
app.manage(unity_client);
Expand Down
137 changes: 26 additions & 111 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,142 +1,57 @@
import { useState, useRef, useCallback, useEffect } from "react";
import "./App.css";
import {
DrawerBody,
DrawerHeader,
DrawerHeaderTitle,
InlineDrawer,
makeStyles,
mergeClasses,
tokens,
Toolbar,
ToolbarButton,
shorthands,
} from "@fluentui/react-components";
import TreeView from "./components/TreeView";
import Explorer from "./components/Explorer";
import { SettingsRegular } from "@fluentui/react-icons";

const useStyles = makeStyles({
root: {
// border: "2px solid #ccc",
overflow: "hidden",

display: "flex",
height: "100vh",
width: "100vw",
// backgroundColor: "#fff",
userSelect: "auto",
},

rootResizerActive: {
userSelect: "none",
},

container: {
position: "relative",
flexDirection: "column",
},

drawer: {
willChange: "width",
transitionProperty: "width",
transitionDuration: "16.666ms", // 60fps
toolbar: {
borderBottomColor: tokens.colorNeutralForeground4,
borderBottomWidth: "1px",
borderBottomStyle: "solid",
},

resizer: {
borderRight: `1px solid ${tokens.colorNeutralBackground5}`,

width: "8px",
position: "absolute",
top: 0,
right: 0,
bottom: 0,
cursor: "col-resize",
resize: "horizontal",

button: {
...shorthands.borderColor(tokens.colorBrandStroke2),
":hover": {
borderRightWidth: "4px",
...shorthands.borderColor(tokens.colorNeutralStroke1),
},
},

resizerActive: {
borderRightWidth: "4px",
borderRightColor: tokens.colorNeutralBackground5Pressed,
},

content: {
margin: `${tokens.spacingVerticalXL} ${tokens.spacingHorizontalXL}`,
flex: "1",
flex: 1,
},
});

function App() {
const styles = useStyles();

const animationFrame = useRef<number>(0);
const sidebarRef = useRef<HTMLDivElement>(null);
const [isResizing, setIsResizing] = useState(false);
const [sidebarWidth, setSidebarWidth] = useState(320);

const startResizing = useCallback(() => setIsResizing(true), []);
const stopResizing = useCallback(() => setIsResizing(false), []);

const resize = useCallback(
({ clientX }: { clientX: number }) => {
animationFrame.current = requestAnimationFrame(() => {
if (isResizing && sidebarRef.current) {
setSidebarWidth(
clientX -
sidebarRef.current.getBoundingClientRect().left,
);
}
});
},
[isResizing],
);

const ResizeComponent: React.FC = () => (
<div
className={mergeClasses(
styles.resizer,
isResizing && styles.resizerActive,
)}
onMouseDown={startResizing}
/>
);

useEffect(() => {
window.addEventListener("mousemove", resize);
window.addEventListener("mouseup", stopResizing);

return () => {
cancelAnimationFrame(animationFrame.current);
window.removeEventListener("mousemove", resize);
window.removeEventListener("mouseup", stopResizing);
};
}, [resize, stopResizing]);

return (
<div
className={mergeClasses(
styles.root,
isResizing && styles.rootResizerActive,
)}
>
<div className={styles.container}>
<InlineDrawer
open
ref={sidebarRef}
className={styles.drawer}
style={{ width: `${sidebarWidth}px` }}
onMouseDown={(e) => e.preventDefault()}
>
<DrawerHeader>
<DrawerHeaderTitle>Catalog Browser</DrawerHeaderTitle>
</DrawerHeader>
<DrawerBody>
<TreeView />
</DrawerBody>
</InlineDrawer>
<ResizeComponent />
<div className={styles.root}>
<div className={styles.toolbar}>
<Toolbar size="medium">
<ToolbarButton
className={styles.button}
appearance="subtle"
icon={<SettingsRegular />}
/>
</Toolbar>
</div>
<div className={styles.content}>
<Explorer />
</div>
<p className={styles.content}>
Resize the drawer to see the change
</p>
</div>
);
}
Expand Down
Loading
Loading