Add copilot theme, start sketching out the auth modal
This commit is contained in:
parent
591e246450
commit
b57d5174aa
5 changed files with 57 additions and 5 deletions
20
crates/copilot/src/auth_modal.rs
Normal file
20
crates/copilot/src/auth_modal.rs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
use gpui::{elements::Label, Element, Entity, View};
|
||||||
|
use settings::Settings;
|
||||||
|
|
||||||
|
pub struct AuthModal {}
|
||||||
|
|
||||||
|
impl Entity for AuthModal {
|
||||||
|
type Event = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl View for AuthModal {
|
||||||
|
fn ui_name() -> &'static str {
|
||||||
|
"AuthModal"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render(&mut self, cx: &mut gpui::RenderContext<'_, Self>) -> gpui::ElementBox {
|
||||||
|
let style = &cx.global::<Settings>().theme.copilot;
|
||||||
|
|
||||||
|
Label::new("[COPILOT AUTH INFO]", style.auth_modal.clone()).boxed()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
|
mod auth_modal;
|
||||||
mod request;
|
mod request;
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use async_compression::futures::bufread::GzipDecoder;
|
use async_compression::futures::bufread::GzipDecoder;
|
||||||
|
use auth_modal::AuthModal;
|
||||||
use client::Client;
|
use client::Client;
|
||||||
use gpui::{actions, AppContext, Entity, ModelContext, ModelHandle, MutableAppContext, Task};
|
use gpui::{actions, AppContext, Entity, ModelContext, ModelHandle, MutableAppContext, Task};
|
||||||
use language::{point_from_lsp, point_to_lsp, Anchor, Bias, Buffer, BufferSnapshot, ToPointUtf16};
|
use language::{point_from_lsp, point_to_lsp, Anchor, Bias, Buffer, BufferSnapshot, ToPointUtf16};
|
||||||
|
@ -16,26 +18,36 @@ use std::{
|
||||||
use util::{
|
use util::{
|
||||||
fs::remove_matching, github::latest_github_release, http::HttpClient, paths, ResultExt,
|
fs::remove_matching, github::latest_github_release, http::HttpClient, paths, ResultExt,
|
||||||
};
|
};
|
||||||
|
use workspace::Workspace;
|
||||||
|
|
||||||
actions!(copilot, [SignIn, SignOut]);
|
actions!(copilot, [SignIn, SignOut, ToggleAuthStatus]);
|
||||||
|
|
||||||
pub fn init(client: Arc<Client>, cx: &mut MutableAppContext) {
|
pub fn init(client: Arc<Client>, cx: &mut MutableAppContext) {
|
||||||
let copilot = cx.add_model(|cx| Copilot::start(client.http_client(), cx));
|
let copilot = cx.add_model(|cx| Copilot::start(client.http_client(), cx));
|
||||||
cx.set_global(copilot);
|
cx.set_global(copilot.clone());
|
||||||
cx.add_global_action(|_: &SignIn, cx: &mut MutableAppContext| {
|
cx.add_action(|workspace: &mut Workspace, _: &SignIn, cx| {
|
||||||
if let Some(copilot) = Copilot::global(cx) {
|
if let Some(copilot) = Copilot::global(cx) {
|
||||||
|
if copilot.read(cx).status() == Status::Authorized {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
copilot
|
copilot
|
||||||
.update(cx, |copilot, cx| copilot.sign_in(cx))
|
.update(cx, |copilot, cx| copilot.sign_in(cx))
|
||||||
.detach_and_log_err(cx);
|
.detach_and_log_err(cx);
|
||||||
|
|
||||||
|
workspace.toggle_modal(cx, |_workspace, cx| cx.add_view(|_cx| AuthModal {}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cx.add_global_action(|_: &SignOut, cx: &mut MutableAppContext| {
|
cx.add_action(|_: &mut Workspace, _: &SignOut, cx| {
|
||||||
if let Some(copilot) = Copilot::global(cx) {
|
if let Some(copilot) = Copilot::global(cx) {
|
||||||
copilot
|
copilot
|
||||||
.update(cx, |copilot, cx| copilot.sign_out(cx))
|
.update(cx, |copilot, cx| copilot.sign_out(cx))
|
||||||
.detach_and_log_err(cx);
|
.detach_and_log_err(cx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
cx.add_action(|workspace: &mut Workspace, _: &ToggleAuthStatus, cx| {
|
||||||
|
workspace.toggle_modal(cx, |_workspace, cx| cx.add_view(|_cx| AuthModal {}))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CopilotServer {
|
enum CopilotServer {
|
||||||
|
@ -62,7 +74,7 @@ pub enum Event {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum Status {
|
pub enum Status {
|
||||||
Downloading,
|
Downloading,
|
||||||
Error(Arc<str>),
|
Error(Arc<str>),
|
||||||
|
@ -138,6 +150,7 @@ impl Copilot {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
server: CopilotServer::Downloading,
|
server: CopilotServer::Downloading,
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ pub struct Theme {
|
||||||
pub context_menu: ContextMenu,
|
pub context_menu: ContextMenu,
|
||||||
pub contacts_popover: ContactsPopover,
|
pub contacts_popover: ContactsPopover,
|
||||||
pub contact_list: ContactList,
|
pub contact_list: ContactList,
|
||||||
|
pub copilot: Copilot,
|
||||||
pub contact_finder: ContactFinder,
|
pub contact_finder: ContactFinder,
|
||||||
pub project_panel: ProjectPanel,
|
pub project_panel: ProjectPanel,
|
||||||
pub command_palette: CommandPalette,
|
pub command_palette: CommandPalette,
|
||||||
|
@ -115,6 +116,11 @@ pub struct AvatarStyle {
|
||||||
pub outer_corner_radius: f32,
|
pub outer_corner_radius: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Default)]
|
||||||
|
pub struct Copilot {
|
||||||
|
pub auth_modal: TextStyle,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Deserialize, Default)]
|
||||||
pub struct ContactsPopover {
|
pub struct ContactsPopover {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
|
|
|
@ -21,6 +21,7 @@ import incomingCallNotification from "./incomingCallNotification"
|
||||||
import { ColorScheme } from "../themes/common/colorScheme"
|
import { ColorScheme } from "../themes/common/colorScheme"
|
||||||
import feedback from "./feedback"
|
import feedback from "./feedback"
|
||||||
import welcome from "./welcome"
|
import welcome from "./welcome"
|
||||||
|
import copilot from "./copilot"
|
||||||
|
|
||||||
export default function app(colorScheme: ColorScheme): Object {
|
export default function app(colorScheme: ColorScheme): Object {
|
||||||
return {
|
return {
|
||||||
|
@ -34,6 +35,7 @@ export default function app(colorScheme: ColorScheme): Object {
|
||||||
incomingCallNotification: incomingCallNotification(colorScheme),
|
incomingCallNotification: incomingCallNotification(colorScheme),
|
||||||
picker: picker(colorScheme),
|
picker: picker(colorScheme),
|
||||||
workspace: workspace(colorScheme),
|
workspace: workspace(colorScheme),
|
||||||
|
copilot: copilot(colorScheme),
|
||||||
welcome: welcome(colorScheme),
|
welcome: welcome(colorScheme),
|
||||||
contextMenu: contextMenu(colorScheme),
|
contextMenu: contextMenu(colorScheme),
|
||||||
editor: editor(colorScheme),
|
editor: editor(colorScheme),
|
||||||
|
|
11
styles/src/styleTree/copilot.ts
Normal file
11
styles/src/styleTree/copilot.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { ColorScheme } from "../themes/common/colorScheme"
|
||||||
|
import { text } from "./components";
|
||||||
|
|
||||||
|
|
||||||
|
export default function copilot(colorScheme: ColorScheme) {
|
||||||
|
let layer = colorScheme.highest;
|
||||||
|
|
||||||
|
return {
|
||||||
|
authModal: text(layer, "sans")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue