Use translation
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
This commit is contained in:
@@ -20,6 +20,8 @@ import {
|
||||
} from '@backstage/plugin-kubernetes-common';
|
||||
import { usePermission } from '@backstage/plugin-permission-react';
|
||||
import { WarningPanel } from '@backstage/core-components';
|
||||
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
||||
import { kubernetesTranslationRef } from './alpha/translation';
|
||||
|
||||
export type RequireKubernetesPermissionProps = {
|
||||
children: ReactNode;
|
||||
@@ -34,6 +36,7 @@ export function RequireKubernetesPermissions(
|
||||
const kubernetesResourcesPermissionResult = usePermission({
|
||||
permission: kubernetesResourcesReadPermission,
|
||||
});
|
||||
const { t } = useTranslationRef(kubernetesTranslationRef);
|
||||
|
||||
if (
|
||||
kubernetesClustersPermissionResult.loading ||
|
||||
@@ -51,9 +54,8 @@ export function RequireKubernetesPermissions(
|
||||
|
||||
return (
|
||||
<WarningPanel
|
||||
title="Permission required"
|
||||
message={`To view Kubernetes objects, contact your portal administrator to give you the
|
||||
'${kubernetesClustersReadPermission.name}' and '${kubernetesResourcesReadPermission.name}' permission.`}
|
||||
title={t('kubernetesContentPage.permissionAlert.title')}
|
||||
message={t('kubernetesContentPage.permissionAlert.message')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { kubernetesTranslationRef } from './translation';
|
||||
export { default } from './plugin';
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2025 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createTranslationRef } from '@backstage/core-plugin-api/alpha';
|
||||
|
||||
/** @alpha */
|
||||
export const kubernetesTranslationRef = createTranslationRef({
|
||||
id: 'kubernetes',
|
||||
messages: {
|
||||
kubernetesContentPage: {
|
||||
permissionAlert: {
|
||||
title: 'Permission required',
|
||||
message:
|
||||
"To view Kubernetes objects, contact your portal administrator to give you the 'kubernetes.clusters.read' and 'kubernetes.resources.read' permission.",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user