Skip to content

Commit

Permalink
show warning when category was changed but document not saved
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Aug 10, 2023
1 parent 097ce40 commit 5262418
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/client/components/configuration/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@ export class Annotations extends LitElement {
if (this.annotations) {
this.annotations.category = category || this.annotations.category
this.requestUpdate()

/**
* make VS Code display warn message to save document
*/
const ctx = getContext()
postClientMessage(ctx, ClientMessages.onCategoryChange, undefined)

return this.#dispatch({
'runme.dev/uuid': this.annotations['runme.dev/uuid'],
category: this.categories.join(CATEGORY_SEPARATOR),
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum ClientMessages {
setState = 'common:setState',
getState = 'common:getState',
onGetState = 'common:onGetState',
onCategoryChange = 'common:onCategoryChange',
cloudApiRequest = 'common:cloudApiRequest',
cloudApiResponse = 'common:cloudApiResponse',
optionsMessage = 'common:optionsMessage',
Expand Down
7 changes: 7 additions & 0 deletions src/extension/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,13 @@ export class Kernel implements Disposable {
return
}
await setNotebookCategories(this.context, cell.notebook.uri, new Set(message.output.value))
} else if (message.type === ClientMessages.onCategoryChange) {
const btnSave = 'Save Now'
window.showWarningMessage('Save changes?', btnSave).then((val) => {
if (val === btnSave) {
commands.executeCommand('workbench.action.files.save')
}
})
} else if (message.type === ClientMessages.cloudApiRequest) {
return handleCloudApiMessage({
messaging: this.messaging,
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export interface ClientMessagePayload {
answer: string | undefined
uuid: string
}
[ClientMessages.onCategoryChange]: void
[ClientMessages.githubWorkflowDispatch]: {
inputs: Record<string, string>
repo: string
Expand Down

0 comments on commit 5262418

Please sign in to comment.