Skip to content

Commit 8c6f0f1

Browse files
mfranciscDevtools
andauthored
fix(sandbox): fix page title (#765)
* fix page title --------- Co-authored-by: Devtools <devtools@redhat.com>
1 parent 810518d commit 8c6f0f1

4 files changed

Lines changed: 43 additions & 3 deletions

File tree

workspaces/sandbox/plugins/sandbox/src/api/RegistrationBackendClient.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,15 @@ export class RegistrationBackendClient implements RegistrationService {
140140
});
141141

142142
if (!response.ok) {
143-
throw new Error(
144-
'Invalid phone number. Please verify the country code and number format, then try again.',
145-
);
143+
const error: CommonResponse = await response.json();
144+
// handle backend error messages and make it more user-friendly
145+
if (error?.message.includes("Invalid 'To' Phone Number")) {
146+
throw new Error(
147+
'Invalid phone number. Please verify the country code and number format, then try again.',
148+
);
149+
} else {
150+
throw new Error(error?.message);
151+
}
146152
}
147153
};
148154

workspaces/sandbox/plugins/sandbox/src/components/SandboxActivities/SandboxActivitiesGrid.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const FeaturedArticles: React.FC = () => {
2929
sx={{
3030
alignItems: 'center',
3131
justifyContent: 'space-between',
32+
backgroundColor: theme.palette.background.paper,
3233
padding: '36px 60px 48px 60px',
3334
}}
3435
>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import { render, screen } from '@testing-library/react';
17+
import React from 'react';
18+
import { SandboxHeader } from './SandboxHeader';
19+
import { createTheme, ThemeProvider } from '@mui/material/styles';
20+
import { wrapInTestApp } from '@backstage/test-utils';
21+
22+
test('renders the modal with the correct title', () => {
23+
const theme = createTheme();
24+
render(
25+
wrapInTestApp(
26+
<ThemeProvider theme={theme}>
27+
<SandboxHeader pageTitle="My Page Title" />
28+
</ThemeProvider>,
29+
),
30+
);
31+
expect(screen.getByText('My Page Title')).toBeInTheDocument();
32+
});

workspaces/sandbox/plugins/sandbox/src/components/SandboxHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const SandboxHeader: React.FC<SandboxHeaderProps> = ({ pageTitle }) => {
3030
const theme = useTheme();
3131
return (
3232
<Header
33+
pageTitleOverride={pageTitle}
3334
title={
3435
<Typography
3536
color="textPrimary"

0 commit comments

Comments
 (0)