-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Feat] Create settings route and class #48
Conversation
classes/Settings.js
Outdated
}) | ||
const { content: socialMediaResp, sha: socialMediaSha } = await socialMedia | ||
|
||
return ({ configResp, socialMediaResp, configSha, socialMediaSha }) |
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.
I don't think we should dump the entire content of _config.yml
and pass it to the frontend. Since some of the data in the .yml file is meant to be read only, we should just provide data that is sufficient for the frontend's settings page.
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.
Modified to transmit only relevant fields
classes/Settings.js
Outdated
// update files | ||
const newConfigContent = base64.encode(yaml.safeDump(configSettings)) | ||
const newSocialMediaContent = base64.encode(yaml.safeDump(socialMediaSettings)) | ||
await config.update(newConfigContent, configSha) |
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.
likewise when updating, I feel that the frontend should only send in selective fields and not the entire file content to the backend.
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.
Modified to receive only relevant fields
This commit limits the response being sent to the frontend to the relevant fields (title, favicon, resources_name, colors) from the config.yml file. It also modifies the code to receive these same fields and make updates to the config file as opposed to rewriting it completely. This commit also switches out the base64 library for the js-base64 library for the Settings file as we had some problems with encoding/decoding with this library in the past
Made changes so that only the relevant fields are transmitted - please remember to pull from the latest |
* feat: add settings router to server file * feat: add OtherType file type to File class * feat: add GET settings route * feat: Create a separate Settings class * feat: Create a new POST method for settings route * fix: defer content decoding to frontend * refactor: remove unnecessary file type in File class * refactor: general cleanup * fix: retintroduce yaml package import * refactor: rename variables for clarity * feat: send and receive only fields that the frontend requires This commit limits the response being sent to the frontend to the relevant fields (title, favicon, resources_name, colors) from the config.yml file. It also modifies the code to receive these same fields and make updates to the config file as opposed to rewriting it completely. This commit also switches out the base64 library for the js-base64 library for the Settings file as we had some problems with encoding/decoding with this library in the past * feat: remove transmission of config sha to frontend
Note
This PR is to be reviewed with PR#99 in the frontend.
Overview
This PR introduces the
settings
route andSettings
class which will retrieve the relevant settings information to be rendered in the frontend. The type of settings data falls into two classes:_config.yml
)_data/social-media.yml
)This PR resolves issue #15