Skip to content

Commit 5bbc698

Browse files
committed
Several improvements and reviewer's suggestions resolved
1 parent 136a37a commit 5bbc698

File tree

8 files changed

+28
-42
lines changed

8 files changed

+28
-42
lines changed

admin/src/Hooks/useCollection.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ export function useCollection() {
1818

1919
const hookingTextRendering = ({ indexed, listened }) => {
2020
if (indexed && listened)
21-
return i18n("plugin.table.td.hookingText.hooked", "Hooked")
21+
return i18n('plugin.table.td.hookingText.hooked', 'Hooked')
2222

23-
if (!indexed && !listened)
24-
return "/"
25-
26-
return i18n("plugin.table.td.hookingText.reload", "Reload needed")
27-
};
23+
if (!indexed && !listened) return '/'
24+
25+
return i18n('plugin.table.td.hookingText.reload', 'Reload needed')
26+
}
2827

2928
const fetchCollections = async () => {
3029
const { data, error } = await request(`/${pluginId}/content-type/`, {
@@ -46,7 +45,9 @@ export function useCollection() {
4645
return collection
4746
})
4847
const reload = collections.find(
49-
col => col.reloadNeeded === 'Reload needed',
48+
col =>
49+
col.reloadNeeded ===
50+
i18n('plugin.table.td.hookingText.reload', 'Reload needed'),
5051
)
5152

5253
const isIndexing = collections.find(col => col.isIndexing === true)

admin/src/Hooks/useI18n.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { useIntl } from 'react-intl'
2-
3-
import getTrad from '../utils/getTrad'
2+
import pluginId from '../pluginId'
43

54
export const useI18n = () => {
65
const { formatMessage } = useIntl()
76

87
const i18n = (key, defaultMessage) => {
98
return formatMessage({
10-
id: getTrad(key),
9+
id: `${pluginId}.${key}`,
1110
defaultMessage,
1211
})
1312
}

admin/src/containers/Settings/Credentials.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,12 @@ const Credentials = () => {
1414
<Box>
1515
<Box padding={2}>
1616
<TextInput
17-
placeholder={i18n(
18-
'plugin.tab.settings.input.host.placeholder',
19-
'Host',
20-
)}
21-
label={i18n(
22-
'plugin.tab.settings.input.host.label',
23-
'Meilisearch Host',
24-
)}
17+
placeholder={i18n('plugin.tab.settings.input.url.placeholder', 'URL')}
18+
label={i18n('plugin.tab.settings.input.url.label', 'Meilisearch URL')}
2519
name="host"
2620
hint={i18n(
27-
'plugin.tab.settings.input.host.hint',
28-
'The host on which your Meilisearch is running',
21+
'plugin.tab.settings.input.url.hint',
22+
'The URL on which your Meilisearch is running',
2923
)}
3024
value={host}
3125
onChange={e => setHost(e.target.value)}

admin/src/index.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { prefixPluginTranslations } from '@strapi/helper-plugin'
22

33
import pluginPkg from '../../package.json'
44
import pluginId from './pluginId'
5-
import getTrad from './utils/getTrad'
65
import PluginIcon from './components/PluginIcon'
76
import Initializer from './components/Initializer'
87
import { PERMISSIONS } from './constants'
@@ -22,8 +21,8 @@ export default {
2221
to: `/plugins/${pluginId}`,
2322
icon: PluginIcon,
2423
intlLabel: {
25-
id: getTrad(`plugin.name`),
26-
defaultMessage: 'Meilisearch',
24+
id: `${pluginId}.plugin.name`,
25+
defaultMessage: name,
2726
},
2827
Component: async () => {
2928
const component = await import(
@@ -39,15 +38,12 @@ export default {
3938
async registerTrads({ locales }) {
4039
const importedTrads = await Promise.all(
4140
locales.map(locale => {
42-
return Promise.all([import(`./translations/${locale}.json`)])
43-
.then(([pluginTranslations]) => {
41+
return import(
42+
/* webpackChunkName: "[pluginId]-[request]" */ `./translations/${locale}.json`
43+
)
44+
.then(({ default: data }) => {
4445
return {
45-
data: {
46-
...prefixPluginTranslations(
47-
pluginTranslations.default,
48-
pluginId,
49-
),
50-
},
46+
data: prefixPluginTranslations(data, pluginId),
5147
locale,
5248
}
5349
})
@@ -59,6 +55,7 @@ export default {
5955
})
6056
}),
6157
)
58+
6259
return Promise.resolve(importedTrads)
6360
},
6461
}

admin/src/translations/en.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"plugin.reload-server": "Reload server",
1818
"plugin.tab.collections": "Collections",
1919
"plugin.tab.settings": "Settings",
20-
"plugin.tab.settings.input.host.placeholder": "Host",
21-
"plugin.tab.settings.input.host.label": "Meilisearch Host",
22-
"plugin.tab.settings.input.host.hint": "The host on which your Meilisearch is running",
20+
"plugin.tab.settings.input.url.placeholder": "URL",
21+
"plugin.tab.settings.input.url.label": "Meilisearch URL",
22+
"plugin.tab.settings.input.url.hint": "The URL on which your Meilisearch is running",
2323
"plugin.tab.settings.input.apiKey.placeholder": "API key",
2424
"plugin.tab.settings.input.apiKey.label": "Meilisearch API Key",
2525
"plugin.tab.settings.input.apiKey.hint": "A valid API key with enough permission to create indexes (or the master key).",

admin/src/translations/es.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"plugin.reload-server": "Recargar el servidor",
1818
"plugin.tab.collections": "Colecciones",
1919
"plugin.tab.settings": "Configuraciones",
20-
"plugin.tab.settings.input.host.placeholder": "Servidor",
21-
"plugin.tab.settings.input.host.label": "Servidor Meilisearch",
22-
"plugin.tab.settings.input.host.hint": "El servidor en el que se ejecuta su Meilisearch",
20+
"plugin.tab.settings.input.url.placeholder": "URL",
21+
"plugin.tab.settings.input.url.label": "URL del Meilisearch",
22+
"plugin.tab.settings.input.url.hint": "La URL donde se ejecuta su Meilisearch",
2323
"plugin.tab.settings.input.apiKey.placeholder": "Clave API",
2424
"plugin.tab.settings.input.apiKey.label": "Clave API de Meilisearch",
2525
"plugin.tab.settings.input.apiKey.hint": "Una clave API válida con permiso suficiente para crear índices (o la clave maestra).",

admin/src/utils/getTrad.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

playground/.tmp/data.db

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)