Skip to content
Open
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
61 changes: 7 additions & 54 deletions alembic/versions/25f4e2a1c9d8_add_workspace_git_sync_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
WORKSPACE_SYNC_TABLES = (
"workspace_sync_state",
"workspace_sync_resource_mapping",
"workspace_sync_event",
"workspace_sync_changeset",
"workspace_sync_changeset_item",
"workspace_sync_materialization",
Expand Down Expand Up @@ -107,7 +106,6 @@ def upgrade() -> None:
*_timestamps(),
*_tenant_fks("workspace_sync_state"),
sa.PrimaryKeyConstraint("surrogate_id", name=op.f("pk_workspace_sync_state")),
sa.UniqueConstraint("id", name=op.f("uq_workspace_sync_state_id")),
sa.UniqueConstraint(
"workspace_id",
"provider",
Expand Down Expand Up @@ -142,6 +140,7 @@ def upgrade() -> None:
sa.Column("local_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("last_synced_commit_sha", sa.String(), nullable=True),
sa.Column("last_synced_spec_hash", sa.String(), nullable=True),
sa.Column("last_projected_spec_hash", sa.String(), nullable=True),
sa.Column(
"sync_status",
sa.String(length=32),
Expand All @@ -153,7 +152,6 @@ def upgrade() -> None:
sa.PrimaryKeyConstraint(
"surrogate_id", name=op.f("pk_workspace_sync_resource_mapping")
),
sa.UniqueConstraint("id", name=op.f("uq_workspace_sync_resource_mapping_id")),
sa.UniqueConstraint(
"workspace_id",
"provider",
Expand Down Expand Up @@ -182,53 +180,6 @@ def upgrade() -> None:
unique=False,
)

op.create_table(
"workspace_sync_event",
*_record_columns(),
*_tenant_columns(),
sa.Column(
"provider", sa.String(length=32), server_default="git", nullable=False
),
sa.Column("resource_type", sa.String(length=64), nullable=False),
sa.Column("source_id", sa.String(), nullable=True),
sa.Column("local_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("operation", sa.String(length=32), nullable=False),
sa.Column("actor_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("base_commit_sha", sa.String(), nullable=True),
sa.Column("before_spec_hash", sa.String(), nullable=True),
sa.Column("after_spec_hash", sa.String(), nullable=True),
sa.Column(
"affected_paths",
postgresql.JSONB(astext_type=sa.Text()),
server_default=sa.text("'[]'::jsonb"),
nullable=False,
),
sa.Column(
"metadata",
postgresql.JSONB(astext_type=sa.Text()),
server_default=sa.text("'{}'::jsonb"),
nullable=False,
),
sa.Column("superseded_by", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("changeset_id", postgresql.UUID(as_uuid=True), nullable=True),
*_timestamps(),
*_tenant_fks("workspace_sync_event"),
sa.PrimaryKeyConstraint("surrogate_id", name=op.f("pk_workspace_sync_event")),
sa.UniqueConstraint("id", name=op.f("uq_workspace_sync_event_id")),
)
op.create_index(
op.f("ix_workspace_sync_event_id"),
"workspace_sync_event",
["id"],
unique=True,
)
op.create_index(
op.f("ix_workspace_sync_event_workspace_id"),
"workspace_sync_event",
["workspace_id"],
unique=False,
)

op.create_table(
"workspace_sync_changeset",
*_record_columns(),
Expand All @@ -252,6 +203,12 @@ def upgrade() -> None:
server_default=sa.text("'[]'::jsonb"),
nullable=False,
),
sa.Column(
"rendered_files",
postgresql.JSONB(astext_type=sa.Text()),
server_default=sa.text("'{}'::jsonb"),
nullable=False,
),
sa.Column(
"validation_status",
sa.String(length=32),
Expand All @@ -273,7 +230,6 @@ def upgrade() -> None:
sa.PrimaryKeyConstraint(
"surrogate_id", name=op.f("pk_workspace_sync_changeset")
),
sa.UniqueConstraint("id", name=op.f("uq_workspace_sync_changeset_id")),
)
op.create_index(
op.f("ix_workspace_sync_changeset_id"),
Expand Down Expand Up @@ -318,7 +274,6 @@ def upgrade() -> None:
sa.PrimaryKeyConstraint(
"surrogate_id", name=op.f("pk_workspace_sync_changeset_item")
),
sa.UniqueConstraint("id", name=op.f("uq_workspace_sync_changeset_item_id")),
sa.UniqueConstraint(
"changeset_id",
"resource_type",
Expand Down Expand Up @@ -383,7 +338,6 @@ def upgrade() -> None:
sa.PrimaryKeyConstraint(
"surrogate_id", name=op.f("pk_workspace_sync_materialization")
),
sa.UniqueConstraint("id", name=op.f("uq_workspace_sync_materialization_id")),
)
op.create_index(
op.f("ix_workspace_sync_materialization_id"),
Expand Down Expand Up @@ -415,6 +369,5 @@ def downgrade() -> None:
op.drop_table("workspace_sync_materialization")
op.drop_table("workspace_sync_changeset_item")
op.drop_table("workspace_sync_changeset")
op.drop_table("workspace_sync_event")
op.drop_table("workspace_sync_resource_mapping")
op.drop_table("workspace_sync_state")

This file was deleted.

20 changes: 13 additions & 7 deletions frontend/src/components/organization/workspace-sync-staging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,22 @@ export function WorkspaceSyncStaging({
if (!pendingQuery.data) {
return
}
const sourceIds = new Set(changes.map((change) => change.source_id))
const exportableSourceIds = new Set(
changes
.filter((change) => change.exportable)
.map((change) => change.source_id)
)
setSelectedSourceIds((current) => {
if (sourceIds.size === 0) {
return sourceIds
if (exportableSourceIds.size === 0) {
return exportableSourceIds
}
if (!selectionInitializedRef.current) {
selectionInitializedRef.current = true
return sourceIds
return exportableSourceIds
}
return new Set([...current].filter((sourceId) => sourceIds.has(sourceId)))
return new Set(
[...current].filter((sourceId) => exportableSourceIds.has(sourceId))
)
})
}, [changes, pendingQuery.data])

Expand All @@ -148,8 +154,8 @@ export function WorkspaceSyncStaging({
)
}

const selectedChanges = changes.filter((change) =>
selectedSourceIds.has(change.source_id)
const selectedChanges = changes.filter(
(change) => change.exportable && selectedSourceIds.has(change.source_id)
)
const isBusy = createChangeset.isPending || exportChangeset.isPending
const canExport =
Expand Down
Loading
Loading