-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Custom default messages implementation for single and multi-user modes #193
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
Conversation
…in admin settings
frontend/src/models/admin.js
Outdated
| method: "POST", | ||
| headers: { | ||
| ...baseHeaders(), | ||
| "Content-Type": "application/json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to specify the application/json here? All other calls are working without this?
frontend/src/models/admin.js
Outdated
| .then((res) => { | ||
| if (!res.ok) { | ||
| throw new Error(res.statusText || "Error setting welcome messages."); | ||
| } | ||
| return { success: true, ...res.json() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if success is a tag that should exist, return it from the response then. Can then just simplify this to
.then((res) => {
if(!res.ok) throw....
return res.json()
}
| return fetch(`${API_BASE}/system/set-welcome-messages`, { | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| }, | ||
| body: JSON.stringify({ messages }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setting welcome message, even in single user mode should add base headers because without that - even on a password protected instance anyone could update the messages if they knew the endpoint
server/endpoints/system.js
Outdated
| if (!request.body || !Array.isArray(request.body.messages)) { | ||
| return response.status(400).json({ | ||
| message: "Invalid message format. Expected an array of messages.", | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh this is why you are specifying the content-type in the POST.
Just use reqBody function - can then restructure the intended result automatically.
const { messages = [] } = reqBody(request);
| @@ -0,0 +1,89 @@ | |||
| const WelcomeMessages = { | |||
| tablename: "welcome_messages", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to use plural for tables
| }; | ||
|
|
||
| const handleBackNavigation = () => { | ||
| window.location.href = "/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
window.location = paths.home()
Mintplex-Labs#193) * added ui for custom welcome messages and added label for custom logo in admin settings * linting * fixing img to use light/dark modes * converted ChatBubble into component * implemented backend for welcome messages and admin appearance page * completed custom welcome messages for admin * finished custom messages for single user mode * merged with master and linted * improved UI for appearance settings pages * linted and merged with master * small updates --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
connect #165
New table created to store custom welcome messages and renders custom messages if they are set in appearance settings. If they are not set in appearance settings, it displays the default AnythingLLM welcome messages.