Skip to content

Commit d75e54e

Browse files
committed
console: Apply code suggestions
1 parent 718e33f commit d75e54e

File tree

8 files changed

+15
-19
lines changed

8 files changed

+15
-19
lines changed

pkg/webui/console/constants/entities.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,10 @@ export const entitySdkServiceMap = Object.freeze({
2929
users: 'Users',
3030
client: 'Clients',
3131
})
32+
33+
export const sdkServices = {
34+
[APPLICATION]: entitySdkServiceMap.application,
35+
[GATEWAY]: entitySdkServiceMap.gateway,
36+
[ORGANIZATION]: entitySdkServiceMap.organization,
37+
[USER]: entitySdkServiceMap.users,
38+
}

pkg/webui/console/containers/api-key-form/create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const CreateForm = ({ entity, entityId }) => {
9494
component={Input}
9595
/>
9696
<FormField
97-
title={'Expiry date'}
97+
title={sharedMessages.expiryDate}
9898
name="expires_at"
9999
type="date"
100100
encode={encodeExpiryDate}

pkg/webui/console/containers/api-key-form/edit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const ApiKeyEditForm = ({ entity, entityId }) => {
106106
component={Input}
107107
/>
108108
<FormField
109-
title={'Expiry date'}
109+
title={sharedMessages.expiryDate}
110110
name="expires_at"
111111
type="date"
112112
decode={decodeExpiryDate}

pkg/webui/console/containers/api-key-form/hooks.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { useSelector, useDispatch } from 'react-redux'
1616
import { useParams } from 'react-router-dom'
1717
import { useCallback } from 'react'
1818

19-
import { APPLICATION, GATEWAY, ORGANIZATION, USER } from '@console/constants/entities'
19+
import { APPLICATION, GATEWAY, ORGANIZATION, sdkServices, USER } from '@console/constants/entities'
2020
import tts from '@console/api/tts'
2121

2222
import attachPromise from '@ttn-lw/lib/store/actions/attach-promise'
@@ -35,13 +35,6 @@ import {
3535
} from '@console/store/selectors/organizations'
3636
import { selectUserRights, selectUserPseudoRights } from '@console/store/selectors/users'
3737

38-
const sdkServices = {
39-
[APPLICATION]: 'Applications',
40-
[GATEWAY]: 'Gateways',
41-
[ORGANIZATION]: 'Organizations',
42-
[USER]: 'Users',
43-
}
44-
4538
const useApiKeyData = (entity, entityId) => {
4639
const rightsSelector = {
4740
[APPLICATION]: selectApplicationRights,

pkg/webui/console/containers/api-key-modal-form/create.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import React, { useCallback } from 'react'
1616
import { defineMessages } from 'react-intl'
1717

1818
import tts from '@console/api/tts'
19-
import { APPLICATION, GATEWAY, ORGANIZATION, USER } from '@console/constants/entities'
19+
import { sdkServices } from '@console/constants/entities'
2020

2121
import FormField from '@ttn-lw/components/form/field'
2222
import FormSubmit from '@ttn-lw/components/form/submit'
@@ -34,13 +34,6 @@ import ApiKeyForm from './form'
3434
import validationSchema from './validation-schema'
3535
import { encodeExpiryDate, decodeExpiryDate } from './utils'
3636

37-
const sdkServices = {
38-
[APPLICATION]: 'Applications',
39-
[GATEWAY]: 'Gateways',
40-
[ORGANIZATION]: 'Organizations',
41-
[USER]: 'Users',
42-
}
43-
4437
const m = defineMessages({
4538
createApiKeyError: 'Failed to create API key',
4639
})
@@ -113,7 +106,7 @@ const CreateForm = ({ entity, entityId, handleCancel, rights, setApiKey }) => {
113106
fieldWidth="full"
114107
/>
115108
<FormField
116-
title={'Expiry date'}
109+
title={sharedMessages.expiryDate}
117110
name="expires_at"
118111
type="date"
119112
className="item-12 md-lg:item-6"

pkg/webui/lib/shared-messages.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ export default defineMessages({
267267
eventsCannotShow: 'Cannot show events',
268268
expand: 'Expand',
269269
expiry: 'Expiry',
270+
expiryDate: 'Expiry date',
270271
exportJson: 'Export as JSON',
271272
external: 'External',
272273
externalJoinServer: 'External Join Server',

pkg/webui/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,7 @@
14491449
"lib.shared-messages.eventsCannotShow": "Cannot show events",
14501450
"lib.shared-messages.expand": "Expand",
14511451
"lib.shared-messages.expiry": "Expiry",
1452+
"lib.shared-messages.expiryDate": "Expiry date",
14521453
"lib.shared-messages.exportJson": "Export as JSON",
14531454
"lib.shared-messages.external": "External",
14541455
"lib.shared-messages.externalJoinServer": "External Join Server",

pkg/webui/locales/ja.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,7 @@
14491449
"lib.shared-messages.eventsCannotShow": "イベントを表示できません",
14501450
"lib.shared-messages.expand": "",
14511451
"lib.shared-messages.expiry": "期限切れ",
1452+
"lib.shared-messages.expiryDate": "",
14521453
"lib.shared-messages.exportJson": "JSONとしてエクスポート",
14531454
"lib.shared-messages.external": "外部",
14541455
"lib.shared-messages.externalJoinServer": "外部Joinサーバー",

0 commit comments

Comments
 (0)