feat(config): add customizable footer

This commit is contained in:
Ali BARIN
2025-03-10 09:34:41 +00:00
parent 423317966e
commit 035ed6fee3
9 changed files with 172 additions and 0 deletions

View File

@@ -11,6 +11,15 @@ export default async (request, response) => {
const configParams = (request) => {
const {
enableFooter,
footerBackgroundColor,
footerCopyrightText,
footerDocsLink,
footerImprintLink,
footerLogoSvgData,
footerPrivacyPolicyLink,
footerTextColor,
footerTosLink,
logoSvgData,
palettePrimaryDark,
palettePrimaryLight,
@@ -19,6 +28,15 @@ const configParams = (request) => {
} = request.body;
return {
enableFooter,
footerBackgroundColor,
footerCopyrightText,
footerDocsLink,
footerImprintLink,
footerLogoSvgData,
footerPrivacyPolicyLink,
footerTextColor,
footerTosLink,
logoSvgData,
palettePrimaryDark,
palettePrimaryLight,

View File

@@ -25,6 +25,18 @@ describe('PATCH /api/v1/admin/config', () => {
const palettePrimaryMain = '#00adef';
const palettePrimaryDark = '#222222';
const palettePrimaryLight = '#f90707';
const enableFooter = true;
const footerCopyrightText = '© AB Software GmbH';
const footerBackgroundColor = '#FFFFFF';
const footerTextColor = '#000000';
const footerDocsLink = 'https://automatisch.io/docs';
const footerTosLink = 'https://automatisch.io/terms';
const footerPrivacyPolicyLink = 'https://automatisch.io/privacy';
const footerImprintLink = 'https://automatisch.io/imprint';
const footerLogoSvgData =
'<svg width="25" height="25" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100"><rect width="100%" height="100%" fill="white" /><text x="10" y="40" font-family="Arial" font-size="40" fill="black">Sample Footer Logo</text></svg>';
const logoSvgData =
'<svg width="25" height="25" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100"><rect width="100%" height="100%" fill="white" /><text x="10" y="40" font-family="Arial" font-size="40" fill="black">A</text></svg>';
@@ -34,6 +46,15 @@ describe('PATCH /api/v1/admin/config', () => {
palettePrimaryDark: palettePrimaryDark,
palettePrimaryLight: palettePrimaryLight,
logoSvgData: logoSvgData,
enableFooter,
footerCopyrightText,
footerBackgroundColor,
footerTextColor,
footerDocsLink,
footerTosLink,
footerPrivacyPolicyLink,
footerImprintLink,
footerLogoSvgData,
};
await updateConfig(appConfig);

View File

@@ -28,6 +28,15 @@ describe('GET /api/v1/automatisch/config', () => {
palettePrimaryMain: '#0059F7',
title: 'Sample Title',
enableTemplates: true,
enableFooter: true,
footerLogoSvgData: '<svg>Sample Footer Logo</svg>',
footerCopyrightText: '© AB Software GmbH',
footerBackgroundColor: '#FFFFFF',
footerTextColor: '#000000',
footerDocsLink: 'https://automatisch.io/docs',
footerTosLink: 'https://automatisch.io/terms',
footerPrivacyPolicyLink: 'https://automatisch.io/privacy',
footerImprintLink: 'https://automatisch.io/imprint',
});
const response = await request(app)
@@ -41,6 +50,16 @@ describe('GET /api/v1/automatisch/config', () => {
additionalDrawerLink: 'link',
additionalDrawerLinkIcon: 'icon',
additionalDrawerLinkText: 'text',
enableTemplates: true,
enableFooter: true,
footerLogoSvgData: '<svg>Sample Footer Logo</svg>',
footerCopyrightText: '© AB Software GmbH',
footerBackgroundColor: '#FFFFFF',
footerTextColor: '#000000',
footerDocsLink: 'https://automatisch.io/docs',
footerTosLink: 'https://automatisch.io/terms',
footerPrivacyPolicyLink: 'https://automatisch.io/privacy',
footerImprintLink: 'https://automatisch.io/imprint',
});
expect(response.body).toStrictEqual(expectedPayload);

View File

@@ -0,0 +1,27 @@
export async function up(knex) {
await knex.schema.table('config', (table) => {
table.boolean('enable_footer').defaultTo(false);
table.text('footer_logo_svg_data');
table.text('footer_copyright_text');
table.text('footer_background_color');
table.text('footer_text_color');
table.text('footer_docs_link');
table.text('footer_tos_link');
table.text('footer_privacy_policy_link');
table.text('footer_imprint_link');
});
}
export async function down(knex) {
await knex.schema.table('config', (table) => {
table.dropColumn('enable_footer');
table.dropColumn('footer_copyright_text');
table.dropColumn('footer_logo_svg_data');
table.dropColumn('footer_background_color');
table.dropColumn('footer_text_color');
table.dropColumn('footer_docs_link');
table.dropColumn('footer_tos_link');
table.dropColumn('footer_privacy_policy_link');
table.dropColumn('footer_imprint_link');
});
}

View File

@@ -6,12 +6,63 @@ exports[`Config model > jsonSchema should have correct validations 1`] = `
"createdAt": {
"type": "string",
},
"enableFooter": {
"type": "boolean",
},
"enableTemplates": {
"type": [
"boolean",
"null",
],
},
"footerBackgroundColor": {
"type": [
"string",
"null",
],
},
"footerCopyrightText": {
"type": [
"string",
"null",
],
},
"footerDocsLink": {
"type": [
"string",
"null",
],
},
"footerImprintLink": {
"type": [
"string",
"null",
],
},
"footerLogoSvgData": {
"type": [
"string",
"null",
],
},
"footerPrivacyPolicyLink": {
"type": [
"string",
"null",
],
},
"footerTextColor": {
"type": [
"string",
"null",
],
},
"footerTosLink": {
"type": [
"string",
"null",
],
},
"id": {
"format": "uuid",
"type": "string",

View File

@@ -16,6 +16,15 @@ class Config extends Base {
palettePrimaryMain: { type: ['string', 'null'] },
title: { type: ['string', 'null'] },
enableTemplates: { type: ['boolean', 'null'] },
enableFooter: { type: 'boolean' },
footerLogoSvgData: { type: ['string', 'null'] },
footerCopyrightText: { type: ['string', 'null'] },
footerBackgroundColor: { type: ['string', 'null'] },
footerTextColor: { type: ['string', 'null'] },
footerDocsLink: { type: ['string', 'null'] },
footerTosLink: { type: ['string', 'null'] },
footerPrivacyPolicyLink: { type: ['string', 'null'] },
footerImprintLink: { type: ['string', 'null'] },
createdAt: { type: 'string' },
updatedAt: { type: 'string' },
},

View File

@@ -15,6 +15,15 @@ const configSerializer = (config) => {
palettePrimaryLight: config.palettePrimaryLight,
installationCompleted: config.installationCompleted,
title: config.title,
enableFooter: config.enableFooter,
footerLogoSvgData: config.footerLogoSvgData,
footerCopyrightText: config.footerCopyrightText,
footerBackgroundColor: config.footerBackgroundColor,
footerTextColor: config.footerTextColor,
footerDocsLink: config.footerDocsLink,
footerTosLink: config.footerTosLink,
footerPrivacyPolicyLink: config.footerPrivacyPolicyLink,
footerImprintLink: config.footerImprintLink,
};
};

View File

@@ -24,6 +24,15 @@ describe('configSerializer', () => {
additionalDrawerLink: config.additionalDrawerLink,
additionalDrawerLinkIcon: config.additionalDrawerLinkIcon,
additionalDrawerLinkText: config.additionalDrawerLinkText,
enableFooter: config.enableFooter,
footerBackgroundColor: config.footerBackgroundColor,
footerCopyrightText: config.footerCopyrightText,
footerDocsLink: config.footerDocsLink,
footerImprintLink: config.footerImprintLink,
footerLogoSvgData: config.footerLogoSvgData,
footerPrivacyPolicyLink: config.footerPrivacyPolicyLink,
footerTextColor: config.footerTextColor,
footerTosLink: config.footerTosLink,
createdAt: config.createdAt.getTime(),
updatedAt: config.updatedAt.getTime(),
};

View File

@@ -16,6 +16,15 @@ const configMock = (config) => {
installationCompleted: config.installationCompleted || false,
title: config.title,
enableTemplates: config.enableTemplates,
enableFooter: config.enableFooter || false,
footerLogoSvgData: config.footerLogoSvgData,
footerCopyrightText: config.footerCopyrightText,
footerBackgroundColor: config.footerBackgroundColor,
footerTextColor: config.footerTextColor,
footerDocsLink: config.footerDocsLink,
footerTosLink: config.footerTosLink,
footerPrivacyPolicyLink: config.footerPrivacyPolicyLink,
footerImprintLink: config.footerImprintLink,
},
meta: {
count: 1,