Implement a more robust Config (#60)
* Implement a more robust Config This moves the configuration variables from the `.env` file to a new `bewcloud.config.ts` file. Note that DB connection and secrets are still in the `.env` file. This will allow for more reliable and easier personalized configurations, and was a requirement to start working on adding SSO (#13). For now, `.env`-based config will still be allowed and respected (overriden by `bewcloud.config.ts`), but in the future I'll probably remove it (some major upgrade). * Update deploy script to also copy the new config file
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { convertObjectToFormData, helpEmail } from '/lib/utils/misc.ts';
|
||||
import { convertObjectToFormData } from '/lib/utils/misc.ts';
|
||||
import { FormField, generateFieldHtml, getFormDataField } from '/lib/form-utils.tsx';
|
||||
import { currencyMap, SupportedCurrencySymbol } from '/lib/types.ts';
|
||||
import { isAppEnabled } from '/lib/config.ts';
|
||||
|
||||
interface SettingsProps {
|
||||
formData: Record<string, any>;
|
||||
@@ -14,6 +13,8 @@ interface SettingsProps {
|
||||
message: string;
|
||||
};
|
||||
currency?: SupportedCurrencySymbol;
|
||||
isExpensesAppEnabled: boolean;
|
||||
helpEmail: string;
|
||||
}
|
||||
|
||||
export type Action =
|
||||
@@ -119,7 +120,9 @@ function formFields(action: Action, formData: FormData, currency?: SupportedCurr
|
||||
return fields;
|
||||
}
|
||||
|
||||
export default function Settings({ formData: formDataObject, error, notice, currency }: SettingsProps) {
|
||||
export default function Settings(
|
||||
{ formData: formDataObject, error, notice, currency, isExpensesAppEnabled, helpEmail }: SettingsProps,
|
||||
) {
|
||||
const formData = convertObjectToFormData(formDataObject);
|
||||
|
||||
const action = getFormDataField(formData, 'action') as Action;
|
||||
@@ -174,7 +177,7 @@ export default function Settings({ formData: formDataObject, error, notice, curr
|
||||
</section>
|
||||
</form>
|
||||
|
||||
{isAppEnabled('expenses')
|
||||
{isExpensesAppEnabled
|
||||
? (
|
||||
<>
|
||||
<h2 class='text-2xl mb-4 text-left px-4 max-w-screen-md mx-auto lg:min-w-96'>Change your currency</h2>
|
||||
|
||||
@@ -5,17 +5,19 @@ interface FilesWrapperProps {
|
||||
initialDirectories: Directory[];
|
||||
initialFiles: DirectoryFile[];
|
||||
initialPath: string;
|
||||
baseUrl: string;
|
||||
}
|
||||
|
||||
// This wrapper is necessary because islands need to be the first frontend component, but they don't support functions as props, so the more complex logic needs to live in the component itself
|
||||
export default function FilesWrapper(
|
||||
{ initialDirectories, initialFiles, initialPath }: FilesWrapperProps,
|
||||
{ initialDirectories, initialFiles, initialPath, baseUrl }: FilesWrapperProps,
|
||||
) {
|
||||
return (
|
||||
<MainFiles
|
||||
initialDirectories={initialDirectories}
|
||||
initialFiles={initialFiles}
|
||||
initialPath={initialPath}
|
||||
baseUrl={baseUrl}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user