Skip to content

Commit

Permalink
console,account: Remove and rewrite all message duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
kschiffer committed Oct 16, 2023
1 parent cc189e5 commit 1a3e837
Show file tree
Hide file tree
Showing 65 changed files with 587 additions and 935 deletions.
3 changes: 0 additions & 3 deletions pkg/webui/account/components/oauth-client-form/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default defineMessages({
clientDescDescription:
'The description is displayed to the user when authorizing the client. Use it to explain the purpose of your client.',
createClient: 'Create OAuth client',
deleteTitle: 'Are you sure you want to delete this account?',
deleteWarning:
'This will <strong>PERMANENTLY DELETE THIS OAUTH CLIENT</strong> and <strong>LOCK THE OAUTH ID</strong>. Make sure you assign new collaborators to such entities if you plan to continue using them.',
purgeWarning:
Expand All @@ -41,9 +40,7 @@ export default defineMessages({
'If set, the authorization page will visually indicate endorsement to improve trust',
grants: 'Grant types',
grantsDesc: 'OAuth flows that can be used for the client to get a token',
grantAuthorizationLabel: 'Authorization code',
grantRefreshTokenLabel: 'Refresh token',
grantPasswordLabel: 'Password',
deleteClient: 'Delete OAuth client',
urlsPlaceholder: 'https://example.com/oauth/callback',
rightsWarning:
Expand Down
10 changes: 2 additions & 8 deletions pkg/webui/account/containers/authorizations-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import React from 'react'
import { useSelector } from 'react-redux'
import { defineMessages } from 'react-intl'
import { createSelector } from 'reselect'

import FetchTable from '@ttn-lw/containers/fetch-table'
Expand All @@ -32,11 +31,6 @@ import {
} from '@account/store/selectors/authorizations'
import { selectUserId } from '@account/store/selectors/user'

const m = defineMessages({
clientId: 'Client ID',
tableTitle: 'OAuth client authorizations',
})

const getItemPathPrefix = item => `${item.client_ids.client_id}`

const OAuthClientAuthorizationsTable = () => {
Expand All @@ -46,7 +40,7 @@ const OAuthClientAuthorizationsTable = () => {
const baseHeaders = [
{
name: 'client_ids.client_id',
displayName: m.clientId,
displayName: sharedMessages.clientId,
width: 20,
},
{
Expand Down Expand Up @@ -84,7 +78,7 @@ const OAuthClientAuthorizationsTable = () => {
getItemsAction={getItems}
baseDataSelector={baseDataSelector}
getItemPathPrefix={getItemPathPrefix}
tableTitle={<Message content={m.tableTitle} />}
tableTitle={<Message content={sharedMessages.oauthClientAuthorizations} />}
clickable
/>
)
Expand Down
3 changes: 1 addition & 2 deletions pkg/webui/account/containers/clients-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const m = defineMessages({
restoreFail: 'There was an error and OAuth client could not be restored',
purgeSuccess: 'OAuth client purged',
purgeFail: 'There was an error and the OAuth client could not be purged',
addClient: 'Add OAuth client',
})

const OWNED_TAB = 'owned'
Expand Down Expand Up @@ -200,7 +199,7 @@ const ClientsTable = () => {
<FetchTable
entity="clients"
defaultOrder="-created_at"
addMessage={m.addClient}
addMessage={sharedMessages.addOAuthClient}
headers={headers}
getItemsAction={getItems}
baseDataSelector={baseDataSelector}
Expand Down
9 changes: 3 additions & 6 deletions pkg/webui/account/containers/collaborators-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,9 @@ import style from './client-collaborators.styl'
const RIGHT_TAG_MAX_WIDTH = 140

const m = defineMessages({
id: 'User / Organization ID',
addCollaborator: 'Add collaborator',
deleteCollaboratorError: 'There was an error and the collaborator could not be deleted',
deleteOnlyCollaboratorError:
'This collaborator could not be deleted because every client needs at least one collaborator with all rights',
removeButtonMessage: 'Remove',
})

const CollaboratorsTable = props => {
Expand Down Expand Up @@ -87,7 +84,7 @@ const CollaboratorsTable = props => {
const baseHeaders = [
{
name: 'ids',
displayName: m.id,
displayName: sharedMessages.userOrgId,
render: ids => {
const isUser = 'user_ids' in ids
const collaboratorId = getCollaboratorId({ ids })
Expand Down Expand Up @@ -144,7 +141,7 @@ const CollaboratorsTable = props => {
<Button
type="button"
onClick={details.delete}
message={m.removeButtonMessage}
message={sharedMessages.remove}
icon="delete"
danger
/>
Expand Down Expand Up @@ -188,7 +185,7 @@ const CollaboratorsTable = props => {
headers={headers}
rowKeySelector={rowKeySelector}
getItemPathPrefix={getCollaboratorPathPrefix}
addMessage={m.addCollaborator}
addMessage={sharedMessages.addCollaborator}
getItemsAction={getItems}
baseDataSelector={baseDataSelector}
tableTitle={<Message content={sharedMessages.collaborator} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ export default defineMessages({
successMessage: 'Profile updated',
deleteAccount: 'Delete account',
useGravatar: 'Use Gravatar',
uploadAnImage: 'Upload an image',
gravatarInfo:
"If available, we're using the <link>Gravatar</link> image associated with your email address. You can upload a different profile picture by selecting the option above.",
gravatarInfoGravatarOnly:
"If available, we're using the <link>Gravatar</link> image associated with your email address. Please follow the instructions on the Gravatar website to change your profile picture.",
primaryEmailAddressDescription: 'Primary email address associated with your account',
deleteAccountError: 'There was an error and your account could not be deleted',
deleteAccountSuccess: 'Account deleted',
imageRequired:
'Please select a file to use as your profile picture or choose "Gravatar" as source',
imageUpload: 'Image upload',
Expand Down
3 changes: 1 addition & 2 deletions pkg/webui/account/containers/sessions-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { selectUserSessions, selectUserSessionsTotalCount } from '@account/store
const m = defineMessages({
deleteSessionSuccess: 'Session removed successfully',
deleteSessionError: 'There was an error and the session could not be deleted',
sessionsTableTitle: 'Sessions',
removeButtonMessage: 'Remove this session',
noExpiryDate: 'No expiry date',
endSession: 'Logout to end this session',
Expand Down Expand Up @@ -183,7 +182,7 @@ const UserSessionsTable = () => {
headers={makeHeaders}
getItemsAction={getSessions}
baseDataSelector={baseDataSelector}
tableTitle={<Message content={m.sessionsTableTitle} />}
tableTitle={<Message content={sharedMessages.sessions} />}
getItemPathPrefix={getItemPathPrefix}
/>
)
Expand Down
6 changes: 2 additions & 4 deletions pkg/webui/account/containers/tokens-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ import { selectTokens, selectTokensTotalCount } from '@account/store/selectors/a
import { selectUserId } from '@account/store/selectors/user'

const m = defineMessages({
tableTitle: 'Access tokens',
deleteSuccess: 'Access token invalidated',
deleteFail: 'There was an error and the access token could not be invalidated',
deleteButton: 'Invalidate this access token',
deleteAllSuccess: 'All access tokens invalidated',
deleteAllFail: 'There was an error and the access tokens could not be invalidated',
deleteAllButton: 'Invalidate all access tokens',
expires: 'Expires',
accessTokens: 'Access tokens',
})

const TokensTable = () => {
Expand All @@ -67,7 +65,7 @@ const TokensTable = () => {
'client-authorizations.single.access-tokens',
<Breadcrumb
path={`/client-authorizations/${clientId}/access-tokens`}
content={m.accessTokens}
content={sharedMessages.accessTokens}
/>,
)

Expand Down Expand Up @@ -200,7 +198,7 @@ const TokensTable = () => {
baseDataSelector={baseDataSelector}
pageSize={PAGE_SIZES.SMALL}
actionItems={deleteAllButton}
tableTitle={<Message content={m.tableTitle} />}
tableTitle={<Message content={sharedMessages.accessTokens} />}
/>
</Col>
</Row>
Expand Down
2 changes: 0 additions & 2 deletions pkg/webui/account/views/code/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ import { selectApplicationSiteTitle } from '@ttn-lw/lib/selectors/env'
import style from './code.styl'

const m = defineMessages({
code: 'Authorization code',
codeDescription: 'Your authorization code is:',
backToAccount: 'Back to {siteTitle}',
})

const siteTitle = selectApplicationSiteTitle()
Expand Down
10 changes: 3 additions & 7 deletions pkg/webui/account/views/front-not-found/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2020 The Things Network Foundation, The Things Industries B.V.
// Copyright © 2023 The Things Network Foundation, The Things Industries B.V.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,6 @@
// limitations under the License.

import React from 'react'
import { defineMessages } from 'react-intl'

import Button from '@ttn-lw/components/button'

Expand All @@ -25,10 +24,7 @@ import style from '@account/views/front/front.styl'
import { selectApplicationSiteName, selectApplicationSiteTitle } from '@ttn-lw/lib/selectors/env'
import errorMessages from '@ttn-lw/lib/errors/error-messages'
import statusCodeMessages from '@ttn-lw/lib/errors/status-code-messages'

const m = defineMessages({
backToAccount: 'Back to {siteTitle}',
})
import sharedMessages from '@ttn-lw/lib/shared-messages'

const siteName = selectApplicationSiteName()
const siteTitle = selectApplicationSiteTitle()
Expand All @@ -51,7 +47,7 @@ const FrontNotFound = () => (
<Button.Link
to="/login"
icon="keyboard_arrow_left"
message={{ ...m.backToAccount, values: { siteTitle } }}
message={{ ...sharedMessages.backTo, values: { siteTitle } }}
/>
</div>
</React.Fragment>
Expand Down
6 changes: 2 additions & 4 deletions pkg/webui/account/views/login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ const m = defineMessages({
createAccount: 'Create an account',
forgotPassword: 'Forgot password?',
loginToContinue: 'Please login to continue',
loginFailed: 'Login failed',
accountDeleted: 'Account deleted',
})

const appRoot = selectApplicationRootPath()
Expand Down Expand Up @@ -114,7 +112,7 @@ const Login = () => {
} else if (!next || (next !== appRoot && !Boolean(error))) {
info = m.loginToContinue
} else if ('account-deleted' in Query.parse(location.search)) {
info = m.accountDeleted
info = sharedMessages.accountDeleted
}

return (
Expand All @@ -130,7 +128,7 @@ const Login = () => {
onSubmit={handleSubmit}
initialValues={initialValues}
error={error}
errorTitle={m.loginFailed}
errorTitle={sharedMessages.loginFailed}
info={info}
validationSchema={validationSchema}
horizontal={false}
Expand Down
9 changes: 3 additions & 6 deletions pkg/webui/account/views/oauth-client-add/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
import React from 'react'
import { useSelector } from 'react-redux'
import { Container, Col, Row } from 'react-grid-system'
import { defineMessages } from 'react-intl'

import PageTitle from '@ttn-lw/components/page-title'

import RequireRequest from '@ttn-lw/lib/components/require-request'

import ClientAdd from '@account/containers/oauth-client-add'

import sharedMessages from '@ttn-lw/lib/shared-messages'

import { getUserRights } from '@account/store/actions/user'

import {
Expand All @@ -32,10 +33,6 @@ import {
selectUserPseudoRights,
} from '@account/store/selectors/user'

const m = defineMessages({
addClient: 'Add OAuth client',
})

const OAuthClientAddInner = () => {
const userId = useSelector(selectUserId)
const isAdmin = useSelector(selectUserIsAdmin)
Expand All @@ -44,7 +41,7 @@ const OAuthClientAddInner = () => {

return (
<Container>
<PageTitle tall title={m.addClient} />
<PageTitle tall title={sharedMessages.addOAuthClient} />
<Row>
<Col lg={8} md={12}>
<ClientAdd
Expand Down
6 changes: 4 additions & 2 deletions pkg/webui/account/views/profile-settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const m = defineMessages({
profileEdit: 'Edit profile',
generalSettingsDescription:
'Change basic info such as your name, profile picture or email address.',
changePasswordTitle: 'Change password',
changePasswordDescription: 'Set up a new password for your account.',
})

Expand All @@ -55,7 +54,10 @@ const ProfileSettings = () => {
>
<ProfileSettingsForm />
</Collapse>
<Collapse title={m.changePasswordTitle} description={m.changePasswordDescription}>
<Collapse
title={sharedMessages.changePassword}
description={m.changePasswordDescription}
>
<ChangePasswordForm />
</Collapse>
</Overlay>
Expand Down
3 changes: 1 addition & 2 deletions pkg/webui/account/views/token-login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import sharedMessages from '@ttn-lw/lib/shared-messages'

const m = defineMessages({
loginToken: 'Login Token',
loginFailed: 'Login failed',
})

const appRoot = selectApplicationRootPath()
Expand Down Expand Up @@ -97,7 +96,7 @@ const TokenLogin = () => {
onSubmit={handleSubmit}
initialValues={initialValues}
error={error}
errorTitle={m.loginFailed}
errorTitle={sharedMessages.loginFailed}
validationSchema={validationSchema}
horizontal={false}
>
Expand Down
1 change: 0 additions & 1 deletion pkg/webui/components/file-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const m = defineMessages({
noFileSelected: 'No file selected',
fileProvided: 'A file has been provided',
tooBig: 'The selected file is too large',
remove: 'Remove',
})

const defaultDataTransform = content => content.replace(/^.*;base64,/, '')
Expand Down
3 changes: 1 addition & 2 deletions pkg/webui/components/qr-modal-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const QrScanDoc = (
)

const m = defineMessages({
scanEndDevice: 'Scan end device QR code',
scanEndDeviceContinue: 'Please scan the QR code to continue. {qrScanDoc}',
invalidData:
'Invalid QR code data. Please note that only TR005 LoRaWAN® Device Identification QR Code can be scanned. Some devices have unrelated QR codes printed on them that cannot be used.',
Expand Down Expand Up @@ -81,7 +80,7 @@ const QRModalButton = props => {
onApprove={onApprove}
message={message}
modalData={{
title: m.scanEndDevice,
title: sharedMessages.scanEndDevice,
children: modalData,
buttonMessage: m.apply,
approveButtonProps: {
Expand Down
1 change: 0 additions & 1 deletion pkg/webui/components/qr/require-permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import style from './qr.styl'
const m = defineMessages({
permissionDeniedError: 'Permission Denied: Please allow access to your camera or upload a photo',
fetchingPermission: 'Please set camera permissions',
uploadImage: 'Upload an image',
})

const RequirePermission = props => {
Expand Down
3 changes: 1 addition & 2 deletions pkg/webui/console/components/device-import-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const m = defineMessages({
formatInfo: 'Format information',
selectAFile: 'Please select a template file',
fileInfoPlaceholder: 'Please select a template format',
claiming: 'Claiming',
setClaimAuthCode: 'Set claim authentication code',
targetedComponents: 'Targeted components',
advancedSectionTitle: 'Advanced end device claiming settings',
Expand Down Expand Up @@ -143,7 +142,7 @@ const DeviceBulkCreateFormInner = props => {
<Form.CollapseSection id="advanced-settings" title={m.advancedSectionTitle}>
<Form.Field
disabled={!jsEnabled}
title={m.claiming}
title={sharedMessages.claiming}
label={m.setClaimAuthCode}
component={Checkbox}
name="set_claim_auth_code"
Expand Down
7 changes: 5 additions & 2 deletions pkg/webui/console/components/downlink-form/downlink-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const m = defineMessages({
bytes: 'Bytes',
replace: 'Replace downlink queue',
push: 'Push to downlink queue (append)',
confirmedDownlink: 'Confirmed downlink',
scheduleDownlink: 'Schedule downlink',
downlinkSuccess: 'Downlink scheduled',
bytesPayloadDescription: 'The desired payload bytes of the downlink message',
Expand Down Expand Up @@ -183,7 +182,11 @@ const DownlinkForm = ({ appId, devId, device, downlinkQueue, skipPayloadCrypto }
maxLines={14}
/>
)}
<Form.Field label={m.confirmedDownlink} name="confirmed" component={Checkbox} />
<Form.Field
label={sharedMessages.confirmedDownlink}
name="confirmed"
component={Checkbox}
/>
<SubmitBar>
<Form.Submit component={SubmitButton} message={m.scheduleDownlink} />
</SubmitBar>
Expand Down
Loading

0 comments on commit 1a3e837

Please sign in to comment.