git_ui: Update commit composer and git status entry UI (#22738)
Blocked on:
- No way to get # of lines changed (added/removed)
- Need methods for:
- `commit`
- `stage`
- `unstage`
- `revert_all` - Similar to Editor::RevertFile, but for all changes in
the project
TODO:
- [ ] Update checkbox visual style to match
[figma](https://www.figma.com/design/sKk3aa7XPwBoE8fdlgp7E8/Git-integration?node-id=804-9255&t=wsHFxPgYHEX78Ky1-11)
- [ ] Update panel button style to filled
- [ ] Panel header
- [x] Correct 1 change suffix (1 changes -> 1 change)
- [ ] Add lines changed badge
- [ ] Add context menu button (`...`)
- [ ] Add context menu
- [ ] Wire up Revert All
- [ ] Entry List
- [x] Revert unwanted ListItem styling
- [x] Add selected, hover states
- [ ] Add `scrolled_to_top`, `scrolled_to_bottom`
- [ ] Show gradient overflow indicator
- [ ] Add `JumpToTop`, `JumpToBottom` actions to the list, bind to shift
+ arrow keys
- [ ] Remove wrapping from keyboard movement
- [ ] Entry
- [x] Style deleted entries with a strikethrough
- [x] `...` on hover or selected
- [ ] Add context menu
- [ ] Composer
- Todo...
Release Notes:
- N/A
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use ::settings::Settings;
|
||||
use git::repository::GitFileStatus;
|
||||
use gpui::{actions, AppContext, Hsla};
|
||||
use gpui::{actions, AppContext, Context, Global, Hsla, Model};
|
||||
use settings::GitPanelSettings;
|
||||
use ui::{Color, Icon, IconName, IntoElement};
|
||||
use ui::{Color, Icon, IconName, IntoElement, SharedString};
|
||||
|
||||
pub mod git_panel;
|
||||
mod settings;
|
||||
@@ -12,14 +12,45 @@ actions!(
|
||||
[
|
||||
StageAll,
|
||||
UnstageAll,
|
||||
DiscardAll,
|
||||
RevertAll,
|
||||
CommitStagedChanges,
|
||||
CommitAllChanges
|
||||
CommitAllChanges,
|
||||
ClearMessage
|
||||
]
|
||||
);
|
||||
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
GitPanelSettings::register(cx);
|
||||
let git_state = cx.new_model(|_cx| GitState::new());
|
||||
cx.set_global(GlobalGitState(git_state));
|
||||
}
|
||||
|
||||
struct GlobalGitState(Model<GitState>);
|
||||
|
||||
impl Global for GlobalGitState {}
|
||||
|
||||
pub struct GitState {
|
||||
commit_message: Option<SharedString>,
|
||||
}
|
||||
|
||||
impl GitState {
|
||||
pub fn new() -> Self {
|
||||
GitState {
|
||||
commit_message: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_message(&mut self, message: Option<SharedString>) {
|
||||
self.commit_message = message;
|
||||
}
|
||||
|
||||
pub fn clear_message(&mut self) {
|
||||
self.commit_message = None;
|
||||
}
|
||||
|
||||
pub fn get_global(cx: &mut AppContext) -> Model<GitState> {
|
||||
cx.global::<GlobalGitState>().0.clone()
|
||||
}
|
||||
}
|
||||
|
||||
const ADDED_COLOR: Hsla = Hsla {
|
||||
@@ -51,6 +82,8 @@ pub fn git_status_icon(status: GitFileStatus) -> impl IntoElement {
|
||||
Icon::new(IconName::SquareDot).color(Color::Custom(MODIFIED_COLOR))
|
||||
}
|
||||
GitFileStatus::Conflict => Icon::new(IconName::Warning).color(Color::Custom(REMOVED_COLOR)),
|
||||
GitFileStatus::Deleted => Icon::new(IconName::Warning).color(Color::Custom(REMOVED_COLOR)),
|
||||
GitFileStatus::Deleted => {
|
||||
Icon::new(IconName::SquareMinus).color(Color::Custom(REMOVED_COLOR))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user