Skip to content

Commit 8e80a18

Browse files
committed
add allowedActions to live demo for translation
1 parent 68e70b4 commit 8e80a18

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

adminforth/types/Adapters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface EmailAdapter {
1212

1313
export interface CompletionAdapter {
1414

15-
validate(): Promise<void>;
15+
validate(): void;
1616

1717
complete(
1818
content: string,

live-demo/app/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

live-demo/app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
"startLive": "prisma migrate deploy && tsx index.ts"
1111
},
1212
"keywords": [],
13-
"author": "",
1413
"license": "ISC",
14+
"author": "",
1515
"description": "",
1616
"dependencies": {
1717
"@adminforth/audit-log": "^1.0.42",
1818
"@adminforth/chat-gpt": "^1.0.20",
1919
"@adminforth/completion-adapter-open-ai-chat-gpt": "^1.0.2",
2020
"@adminforth/email-password-reset": "^1.0.5",
2121
"@adminforth/foreign-inline-list": "^1.0.24",
22-
"@adminforth/i18n": "^1.0.19-next.0",
22+
"@adminforth/i18n": "^1.0.23-next.0",
2323
"@adminforth/import-export": "^1.0.2",
2424
"@adminforth/rich-editor": "^1.0.16",
2525
"@adminforth/two-factors-auth": "^1.0.21",

live-demo/app/resources/translations.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const blockDemoUsers = async ({ record, adminUser, resource }) => {
1111
return { ok: true };
1212
}
1313

14+
const isAdmin = ({ adminUser }) => {
15+
return adminUser.dbUser && adminUser.dbUser.role === 'superadmin';
16+
}
17+
1418
export default {
1519
dataSource: "maindb",
1620
table: "translations",
@@ -25,9 +29,6 @@ export default {
2529
edit: {
2630
beforeSave: blockDemoUsers,
2731
},
28-
create: {
29-
beforeSave: blockDemoUsers,
30-
},
3132
},
3233
plugins: [
3334
new I18nPlugin({
@@ -53,20 +54,23 @@ export default {
5354
// will hel to filter out incomplete translations
5455
completedFieldName: 'completedLangs',
5556

56-
// completeAdapter: new CompletionAdapterOpenAIChatGPT({
57-
// openAiApiKey: process.env.OPENAI_API_KEY as string,
58-
// model: 'gpt-4o-mini',
59-
// expert: {
60-
// // for UI translation it is better to lower down the temperature from default 0.7. Less creative and more accurate
61-
// temperature: 0.5,
62-
// },
63-
// }),
57+
completeAdapter: new CompletionAdapterOpenAIChatGPT({
58+
openAiApiKey: process.env.OPENAI_API_KEY as string,
59+
model: 'gpt-4o-mini',
60+
expert: {
61+
// for UI translation it is better to lower down the temperature from default 0.7. Less creative and more accurate
62+
temperature: 0.5,
63+
},
64+
}),
6465
}),
6566

6667
],
6768
options: {
6869
listPageSize: 30,
69-
70+
allowedActions: {
71+
create: false,
72+
edit: isAdmin,
73+
},
7074
},
7175
columns: [
7276
{

0 commit comments

Comments
 (0)