Skip to content

Commit

Permalink
feat: allow defining supported databases
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Jun 21, 2024
1 parent 50a23ff commit abc545f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions framework/core/js/src/admin/AdminApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type Extension = {
extra: {
'flarum-extension': {
title: string;
'database-support': undefined | string[];
};
};
require?: Record<string, string>;
Expand Down
21 changes: 21 additions & 0 deletions framework/core/js/src/admin/components/ExtensionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,27 @@ export default class ExtensionPage<Attrs extends ExtensionPageAttrs = ExtensionP
}
});

let supportedDatabases = this.extension.extra['flarum-extension']['database-support'] ?? null;
if (supportedDatabases && supportedDatabases.length) {
supportedDatabases = supportedDatabases.map((database: string) => {
return (
{
mysql: 'MySQL',
sqlite: 'SQLite',
pgsql: 'PostgreSQL',
}[database] || database
);
});

items.add(
'database-support',
<span className="LinkButton">
<Icon name="fas fa-database" />
{supportedDatabases.join(', ')}
</span>
);
}

const extension = this.extension;
items.add(
'readme',
Expand Down

0 comments on commit abc545f

Please sign in to comment.