Skip to content

Commit

Permalink
swap hardcoded strings for translated ones
Browse files Browse the repository at this point in the history
  • Loading branch information
eokoneyo committed Jun 7, 2024
1 parent 759b429 commit 3b5586d
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ export const ViewSpacePage: FC<PageProps> = (props) => {

// use href to force full page reload (needed in order to change spaces)
return (
<EuiButton iconType="merge" href={urlToSelectedSpace}>
<EuiButton iconType="merge" href={urlToSelectedSpace} data-test-subj="spaceSwitcherButton">
<FormattedMessage
id="viewSpace.switchToSpaceButton.label"
id="xpack.spaces.management.spaceDetails.space.switchToSpaceButton.label"
defaultMessage="Switch to this space"
/>
</EuiButton>
Expand All @@ -204,19 +204,19 @@ export const ViewSpacePage: FC<PageProps> = (props) => {
getUrlForApp={getUrlForApp}
>
<EuiText>
<EuiFlexGroup>
<EuiFlexGroup data-test-subj="spaceDetailsHeader">
<EuiFlexItem grow={false}>
<HeaderAvatar />
</EuiFlexItem>
<EuiFlexItem>
<EuiTitle size="l">
<h1>{space.name}</h1>
<h1 data-test-subj="spaceTitle">{space.name}</h1>
</EuiTitle>
<EuiText size="s">
<p>
{space.description ?? (
<FormattedMessage
id="viewSpace.description"
id="xpack.spaces.management.spaceDetails.space.description"
defaultMessage="Organize your saved objects and show related features for creating new content."
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ import {
EuiFlyoutBody,
EuiFlyoutFooter,
EuiFlyoutHeader,
EuiText,
EuiTitle,
} from '@elastic/eui';
import type { FC } from 'react';
import React, { useState } from 'react';

import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import type { Role } from '@kbn/security-plugin-types-common';

import type { Space } from '../../../common';
Expand Down Expand Up @@ -52,11 +55,15 @@ export const ViewSpaceAssignedRoles: FC<Props> = ({ space, roles }) => {
const columns: Array<EuiBasicTableColumn<Role>> = [
{
field: 'name',
name: 'Role',
name: i18n.translate('xpack.spaces.management.spaceDetails.roles.column.name.title', {
defaultMessage: 'Role',
}),
},
{
field: 'privileges',
name: 'Privileges',
name: i18n.translate('xpack.spaces.management.spaceDetails.roles.column.privileges.title', {
defaultMessage: 'Privileges',
}),
render: (_value, record) => {
return record.kibana.map((kibanaPrivilege) => {
return kibanaPrivilege.base.join(', ');
Expand All @@ -67,7 +74,12 @@ export const ViewSpaceAssignedRoles: FC<Props> = ({ space, roles }) => {
name: 'Actions',
actions: [
{
name: 'Remove from space',
name: i18n.translate(
'xpack.spaces.management.spaceDetails.roles.column.actions.remove.title',
{
defaultMessage: 'Remove from space',
}
),
description: 'Click this action to remove the role privileges from this space.',
onClick: () => {
window.alert('Not yet implemented.');
Expand Down Expand Up @@ -103,29 +115,43 @@ export const ViewSpaceAssignedRoles: FC<Props> = ({ space, roles }) => {
}}
/>
)}
<EuiFlexGroup>
<EuiFlexGroup direction="column">
<EuiFlexItem>
<p>Roles that can access this space. Privileges are managed at the role level.</p>
<EuiFlexGroup>
<EuiFlexItem>
<EuiText>
<p>
{i18n.translate('xpack.spaces.management.spaceDetails.roles.heading', {
defaultMessage:
'Roles that can access this space. Privileges are managed at the role level.',
})}
</p>
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false} color="primary">
<EuiButton
onClick={() => {
setShowRolesPrivilegeEditor(true);
}}
>
{i18n.translate('xpack.spaces.management.spaceDetails.roles.assign', {
defaultMessage: 'Assign role',
})}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem grow={false} color="primary">
<EuiButton
onClick={() => {
setShowRolesPrivilegeEditor(true);
}}
>
Assign role
</EuiButton>
<EuiFlexItem>
<EuiBasicTable
tableCaption="Demo of EuiBasicTable"
rowHeader="firstName"
columns={columns}
items={rolesInUse}
rowProps={getRowProps}
cellProps={getCellProps}
/>
</EuiFlexItem>
</EuiFlexGroup>

<EuiBasicTable
tableCaption="Demo of EuiBasicTable"
rowHeader="firstName"
columns={columns}
items={rolesInUse}
rowProps={getRowProps}
cellProps={getCellProps}
/>
</>
);
};
Expand All @@ -147,7 +173,9 @@ export const PrivilegesRolesForm: FC<PrivilegesRolesFormProps> = (props) => {
const getSaveButton = () => {
return (
<EuiButton onClick={onSaveClick} fill data-test-subj={'createRolesPrivilegeButton'}>
Assign roles
{i18n.translate('xpack.spaces.management.spaceDetails.roles.assignRoleButton', {
defaultMessage: 'Assign roles',
})}
</EuiButton>
);
};
Expand All @@ -160,10 +188,14 @@ export const PrivilegesRolesForm: FC<PrivilegesRolesFormProps> = (props) => {
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<p>
Roles will be granted access to the current space according to their default privileges.
Use the &lsquo;Customize&rsquo; option to override default privileges.
</p>
<EuiText>
<p>
<FormattedMessage
id="xpack.spaces.management.spaceDetails.privilegeForm.heading"
defaultMessage="Roles will be granted access to the current space according to their default privileges. Use the &lsquo;Customize&rsquo; option to override default privileges."
/>
</p>
</EuiText>
{getForm()}
</EuiFlyoutBody>
<EuiFlyoutFooter>
Expand All @@ -175,7 +207,9 @@ export const PrivilegesRolesForm: FC<PrivilegesRolesFormProps> = (props) => {
flush="left"
data-test-subj={'cancelRolesPrivilegeButton'}
>
Cancel
{i18n.translate('xpack.spaces.management.spaceDetails.roles.cancelRoleButton', {
defaultMessage: 'Cancel',
})}
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>{getSaveButton()}</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EuiNotificationBadge } from '@elastic/eui';
import React from 'react';

import type { KibanaFeature } from '@kbn/features-plugin/common';
import { i18n } from '@kbn/i18n';
import type { Role } from '@kbn/security-plugin-types-common';

import { TAB_ID_CONTENT, TAB_ID_FEATURES, TAB_ID_ROLES } from './constants';
Expand All @@ -33,12 +34,16 @@ export const getTabs = (space: Space, features: KibanaFeature[], roles: Role[]):
return [
{
id: TAB_ID_CONTENT,
name: 'Content',
name: i18n.translate('xpack.spaces.management.spaceDetails.contentTabs.feature.heading', {
defaultMessage: 'Content',
}),
content: <ViewSpaceContent space={space} />,
},
{
id: TAB_ID_FEATURES,
name: 'Features',
name: i18n.translate('xpack.spaces.management.spaceDetails.contentTabs.feature.heading', {
defaultMessage: 'Feature visibility',
}),
append: (
<EuiNotificationBadge className="eui-alignCenter" size="m">
{enabledFeatureCount} / {totalFeatureCount}
Expand All @@ -48,7 +53,9 @@ export const getTabs = (space: Space, features: KibanaFeature[], roles: Role[]):
},
{
id: TAB_ID_ROLES,
name: 'Assigned roles',
name: i18n.translate('xpack.spaces.management.spaceDetails.contentTabs.roles.heading', {
defaultMessage: 'Assigned roles',
}),
append: (
<EuiNotificationBadge className="eui-alignCenter" size="m">
{roles.length}
Expand Down

0 comments on commit 3b5586d

Please sign in to comment.