[ide-react] Notify about unsaved changes (#16163)

* Notify about unsaved changes
* Move system message components and types to shared folder
* Add system messages component

GitOrigin-RevId: ab81a24888847bd9a8a390fd1af6b58f471f7a4b
This commit is contained in:
Alf Eaton
2023-12-15 09:03:27 +00:00
committed by Copybot
parent a074054cc9
commit 8dbf2b64f8
21 changed files with 251 additions and 77 deletions
@@ -61,15 +61,28 @@ export class OpenDocuments {
})
}
private docsArray() {
return Array.from(this.openDocs.values())
}
hasUnsavedChanges() {
return this.docsArray().some(doc => doc.hasBufferedOps())
for (const doc of this.openDocs.values()) {
if (doc.hasBufferedOps()) {
return true
}
}
return false
}
flushAll() {
return this.docsArray().map(doc => doc.flush())
for (const doc of this.openDocs.values()) {
doc.flush()
}
}
unsavedDocIds() {
const ids = []
for (const [docId, doc] of this.openDocs) {
if (!doc.pollSavedStatus()) {
ids.push(docId)
}
}
return ids
}
}