first pass of merging in warp (doesn't build)
This commit is contained in:
+12
-71
@@ -1,8 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use galaxy_core::context_flag::ContextFlag;
|
||||
use galaxy_core::features::FeatureFlag;
|
||||
use galaxyui::{AppContext, SingletonEntity};
|
||||
pub use cloud_object_models::{CloudWorkflow, CloudWorkflowModel, WorkflowId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod categories;
|
||||
@@ -19,25 +17,24 @@ pub mod workflow;
|
||||
pub mod workflow_enum;
|
||||
pub mod workflow_view;
|
||||
|
||||
use async_trait::async_trait;
|
||||
pub use categories::{CategoriesView, CategoriesViewEvent, WorkflowsViewAction};
|
||||
|
||||
use crate::appearance::Appearance;
|
||||
use crate::cloud_object::model::view::CloudViewModel;
|
||||
use crate::cloud_object::{
|
||||
CloudModelType, CloudObjectEventEntrypoint, CreateCloudObjectResult, CreateObjectRequest,
|
||||
GenericCloudObject, GenericServerObject, ObjectType, Revision, ServerCloudObject,
|
||||
UpdateCloudObjectResult,
|
||||
CloudModelType, CloudObjectEventEntrypoint, CloudObjectUpsertParams, CreateCloudObjectResult,
|
||||
CreateObjectRequest, GenericServerObject, ObjectType, Revision, UpdateCloudObjectResult,
|
||||
};
|
||||
use crate::server::cloud_objects::update_manager::InitiatedBy;
|
||||
|
||||
use crate::drive::items::workflow::WarpDriveWorkflow;
|
||||
use crate::drive::items::WarpDriveItem;
|
||||
use crate::drive::CloudObjectTypeAndId;
|
||||
use crate::notebooks::{NotebookId, NotebookLocation};
|
||||
use crate::persistence::ModelEvent;
|
||||
use crate::server::cloud_objects::update_manager::InitiatedBy;
|
||||
use crate::server::ids::{ServerId, SyncId};
|
||||
use crate::server::server_api::object::ObjectClient;
|
||||
use crate::server::sync_queue::{QueueItem, SerializedModel};
|
||||
use async_trait::async_trait;
|
||||
pub use categories::{CategoriesView, CategoriesViewEvent, WorkflowsViewAction};
|
||||
|
||||
pub fn init(app: &mut AppContext) {
|
||||
categories::init(app);
|
||||
@@ -81,7 +78,7 @@ pub enum WorkflowSelectionSource {
|
||||
Alias,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum WorkflowViewMode {
|
||||
View,
|
||||
Edit,
|
||||
@@ -138,10 +135,6 @@ impl WorkflowViewMode {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
|
||||
pub struct WorkflowId(ServerId);
|
||||
crate::server_id_traits! { WorkflowId, "Workflow" }
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum AIWorkflowOrigin {
|
||||
CommandSearch,
|
||||
@@ -214,21 +207,6 @@ impl WorkflowType {
|
||||
}
|
||||
}
|
||||
|
||||
/// The model for a `CloudWorkflow`.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct CloudWorkflowModel {
|
||||
pub data: Workflow,
|
||||
}
|
||||
|
||||
impl CloudWorkflowModel {
|
||||
pub fn new(workflow: Workflow) -> Self {
|
||||
Self { data: workflow }
|
||||
}
|
||||
}
|
||||
|
||||
/// `CloudWorkflow` is a workflow retrieved from the server.
|
||||
pub type CloudWorkflow = GenericCloudObject<WorkflowId, CloudWorkflowModel>;
|
||||
|
||||
#[cfg_attr(not(target_family = "wasm"), async_trait)]
|
||||
#[cfg_attr(target_family = "wasm", async_trait(?Send))]
|
||||
impl CloudModelType for CloudWorkflowModel {
|
||||
@@ -259,14 +237,14 @@ impl CloudModelType for CloudWorkflowModel {
|
||||
self.data.set_name(name);
|
||||
}
|
||||
|
||||
fn upsert_event(&self, workflow: &CloudWorkflow) -> ModelEvent {
|
||||
fn upsert_event(params: CloudObjectUpsertParams<Self>) -> ModelEvent {
|
||||
ModelEvent::UpsertWorkflow {
|
||||
workflow: workflow.clone(),
|
||||
workflow: CloudWorkflow::from(params),
|
||||
}
|
||||
}
|
||||
|
||||
fn bulk_upsert_event(objects: &[CloudWorkflow]) -> ModelEvent {
|
||||
ModelEvent::UpsertWorkflows(objects.to_vec())
|
||||
fn bulk_upsert_event(objects: Vec<CloudObjectUpsertParams<Self>>) -> ModelEvent {
|
||||
ModelEvent::UpsertWorkflows(objects.into_iter().map(CloudWorkflow::from).collect())
|
||||
}
|
||||
|
||||
fn create_object_queue_item(
|
||||
@@ -313,15 +291,6 @@ impl CloudModelType for CloudWorkflowModel {
|
||||
)
|
||||
}
|
||||
|
||||
fn new_from_server_update(&self, server_cloud_object: &ServerCloudObject) -> Option<Self> {
|
||||
if let ServerCloudObject::Workflow(server_workflow) = server_cloud_object {
|
||||
return Some(CloudWorkflowModel {
|
||||
data: server_workflow.model.data.clone(),
|
||||
});
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
async fn send_create_request(
|
||||
object_client: Arc<dyn ObjectClient>,
|
||||
request: CreateObjectRequest,
|
||||
@@ -364,31 +333,3 @@ impl CloudModelType for CloudWorkflowModel {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<Workflow> for CloudWorkflow {
|
||||
fn eq(&self, other: &Workflow) -> bool {
|
||||
self.model().data == *other
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<CloudWorkflow> for CloudWorkflow {
|
||||
fn eq(&self, other: &CloudWorkflow) -> bool {
|
||||
self.model().data == other.model().data && self.id == other.id
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CloudWorkflow> for Workflow {
|
||||
fn from(cloud_workflow: CloudWorkflow) -> Self {
|
||||
cloud_workflow.model().data.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&CloudWorkflow> for Workflow {
|
||||
fn from(cloud_workflow: &CloudWorkflow) -> Self {
|
||||
cloud_workflow.model().data.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "mod_test.rs"]
|
||||
mod tests;
|
||||
|
||||
Reference in New Issue
Block a user