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
15 changes: 12 additions & 3 deletions internal/api/confluence.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,24 @@ type UpdatePageRequest struct {
}

// UpdatePage updates an existing page.
func (s *ConfluenceService) UpdatePage(ctx context.Context, pageID, title, content string, version int, message string) (*Page, error) {
// status controls the resulting page status ("current" or "draft"). Empty defaults to "current".
func (s *ConfluenceService) UpdatePage(ctx context.Context, pageID, title, content string, version int, message string, status string) (*Page, error) {
path := fmt.Sprintf("%s/pages/%s", s.baseURL(), pageID)

if status == "" {
status = "current"
}

reqBody := UpdatePageRequest{
ID: pageID,
Status: "current",
Status: status,
Title: title,
}
reqBody.Version.Number = version + 1
if status == "draft" {
reqBody.Version.Number = version
} else {
reqBody.Version.Number = version + 1
}
reqBody.Version.Message = message
reqBody.Body.Representation = "storage"
reqBody.Body.Value = content
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/confluence/page/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func runEdit(opts *EditOptions) error {
currentVersion = currentPage.Version.Number
}

page, err := confluence.UpdatePage(ctx, opts.PageID, title, body, currentVersion, "Updated via atl CLI")
page, err := confluence.UpdatePage(ctx, opts.PageID, title, body, currentVersion, "Updated via atl CLI", currentPage.Status)
if err != nil {
return fmt.Errorf("failed to update page: %w", err)
}
Expand Down