File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed
assets/javascripts/discourse
connectors/reviewable-note-form-after-note Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ import Component from " @glimmer/component" ;
2
+ import { i18n } from " discourse-i18n" ;
3
+
4
+ export default class CopyReviewableNoteToUserOption extends Component {
5
+ static shouldRender (args , context ) {
6
+ return (
7
+ context .siteSettings .user_notes_enabled && context .currentUser ? .staff
8
+ );
9
+ }
10
+
11
+ <template >
12
+ <@ form.CheckboxGroup as | group | >
13
+ <group.Field
14
+ @ name =" copy_note_to_user"
15
+ @ title ={{i18n " user_notes.copy_reviewable_note" }}
16
+ @ format =" full"
17
+ as | field |
18
+ >
19
+ <field.Checkbox />
20
+ </group.Field >
21
+ </@ form.CheckboxGroup >
22
+ </template >
23
+ }
Original file line number Diff line number Diff line change
1
+ import { ajax } from "discourse/lib/ajax" ;
2
+ import { popupAjaxError } from "discourse/lib/ajax-error" ;
1
3
import { iconNode } from "discourse/lib/icon-library" ;
2
4
import { withPluginApi } from "discourse/lib/plugin-api" ;
3
5
import { showUserNotes } from "../lib/user-notes" ;
@@ -109,6 +111,31 @@ export default {
109
111
}
110
112
} ,
111
113
} ) ;
114
+
115
+ api . onAppEvent (
116
+ "reviewablenote:created" ,
117
+ async ( data , reviewable , formApi ) => {
118
+ if ( ! data . copy_note_to_user || ! reviewable . target_created_by ) {
119
+ return ;
120
+ }
121
+
122
+ try {
123
+ await ajax ( "/user_notes" , {
124
+ type : "POST" ,
125
+ data : {
126
+ user_note : {
127
+ user_id : reviewable . target_created_by . id ,
128
+ raw : data . content . trim ( ) ,
129
+ } ,
130
+ } ,
131
+ } ) ;
132
+
133
+ formApi . set ( "copy_note_to_user" , false ) ;
134
+ } catch ( error ) {
135
+ popupAjaxError ( error ) ;
136
+ }
137
+ }
138
+ ) ;
112
139
} ) ;
113
140
} ,
114
141
} ;
Original file line number Diff line number Diff line change 7
7
show : " User Notes (%{count})"
8
8
delete_confirm : " Are you sure you want to delete that user note?"
9
9
show_post : " Show Post"
10
+ copy_reviewable_note : " Copy note to user profile?"
You can’t perform that action at this time.
0 commit comments