Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock documents on other types of suggestions in the header #212

Merged
merged 3 commits into from
Jun 14, 2023
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
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))
}
Comment on lines +92 to +96
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉


// 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 ||
jfreda marked this conversation as resolved.
Show resolved Hide resolved
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 ||
jfreda marked this conversation as resolved.
Show resolved Hide resolved
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 {
jfreda marked this conversation as resolved.
Show resolved Hide resolved
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