Skip to content

Commit

Permalink
Lock documents on other types of suggestions in the header (#212)
Browse files Browse the repository at this point in the history
* Lock documents on other types of suggestions in the header

* Separate log line for locked draft docs

* Add comments per PR feedback
  • Loading branch information
jfreda authored Jun 14, 2023
1 parent dc34c48 commit 4949cee
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/indexer/refresh_headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ func refreshDocumentHeaders(
}
lockedDocIDs = append(lockedDocIDs, d.GoogleFileID)
}
log.Info(fmt.Sprintf("locked document IDs: %v", lockedDocIDs))
if ft == draftsFolderType {
log.Info(fmt.Sprintf("locked draft document IDs: %v", lockedDocIDs))
} else {
log.Info(fmt.Sprintf("locked document IDs: %v", lockedDocIDs))
}

// Return if there are no updated documents.
if len(docs) == 0 {
Expand Down
28 changes: 27 additions & 1 deletion pkg/hashicorpdocs/locked.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,41 @@ func containsSuggestionInHeader(doc *docs.Document) bool {

// Navigate through all table contents to look for suggestions.
for _, row := range t.TableRows {
// Check table rows for suggestions.
if len(row.SuggestedDeletionIds) > 0 ||
len(row.SuggestedInsertionIds) > 0 ||
len(row.SuggestedTableRowStyleChanges) > 0 {
// We found a suggestion.
return true
}
for _, cell := range row.TableCells {
// Check table cells for suggestions.
if len(cell.SuggestedDeletionIds) > 0 ||
len(cell.SuggestedInsertionIds) > 0 ||
len(cell.SuggestedTableCellStyleChanges) > 0 {
return true
}
for _, content := range cell.Content {
// Check table cell content for suggestions.
if para := content.Paragraph; para != nil {
if len(para.SuggestedBulletChanges) > 0 ||
len(para.SuggestedParagraphStyleChanges) > 0 ||
len(para.SuggestedPositionedObjectIds) > 0 {
return true
}
for _, elem := range para.Elements {
// Check table cell paragraphs for suggestions.
if auto := elem.AutoText; auto != nil {
if len(auto.SuggestedDeletionIds) > 0 ||
len(auto.SuggestedInsertionIds) > 0 ||
len(auto.SuggestedTextStyleChanges) > 0 {
return true
}
}
if txt := elem.TextRun; txt != nil {
if len(txt.SuggestedDeletionIds) > 0 ||
len(txt.SuggestedInsertionIds) > 0 ||
len(txt.SuggestedTextStyleChanges) > 0 {
// We found a suggestion.
return true
}
}
Expand Down

0 comments on commit 4949cee

Please sign in to comment.