Skip to content

Commit d208ebf

Browse files
authored
fix(sandbox): handle signup case where defaultNamespace is not yet defined (#975)
* handle defaultNamespace being undefined
1 parent da403c1 commit d208ebf

8 files changed

Lines changed: 6089 additions & 4995 deletions

File tree

workspaces/sandbox/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ Please, note that every time you want to re deploy, you need to run:
3434

3535
NOTE: the app uses prod RH SSO as auth provider and sandbox stage backend by default
3636
( those can be configured in `deploy/app-config.yaml` )
37+
38+
Known issues:
39+
40+
- sometimes the local node build fails and you'll have to run `make stop-rhdh-local` and `make start-rhdh-local` again.
41+
This is what you will see when the build fails:
42+
![Known Issues](./images/known_build_issue.png)
301 KB
Loading

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { OAuthApi } from '@backstage/core-plugin-api/index';
16+
import { OAuthApi } from '@backstage/core-plugin-api';
1717

1818
export type SecureFetchClientOptions = {
1919
oauthApi: OAuthApi;

workspaces/sandbox/plugins/sandbox/src/components/Modals/PhoneVerificationSteps/VerificationCodeStep.tsx

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ export const VerificationCodeStep: React.FC<VerificationCodeProps> = ({
153153

154154
// Poll until user is found or max attempts reached
155155
let urlToOpen = '';
156-
let userFound = false;
157156
let userReady = false;
158157
for (let i = 0; i < maxAttempts; i++) {
159158
setRefetchingUserData(true);
@@ -162,29 +161,34 @@ export const VerificationCodeStep: React.FC<VerificationCodeProps> = ({
162161
// Fetch the latest user data and check if user is found
163162
const userData = await refetchUserData();
164163
if (userData) {
165-
userFound = true;
166164
const userStatus = signupDataToStatus(userData);
167165
userReady = userStatus === 'ready';
166+
167+
const verificationRequired = userStatus === 'verify';
168+
// if verification is required we can stop fetching the data
169+
if (verificationRequired) {
170+
break;
171+
}
172+
168173
// if user is ready we can stop fetching the data
169174
if (userReady) {
175+
// if namespace is not defined we can continue fetching the data
176+
if (!userData?.defaultUserNamespace) {
177+
// eslint-disable-next-line
178+
console.error(
179+
'user is ready but default namespace is not defined yet...',
180+
);
181+
continue;
182+
}
170183
const productURLs = productsURLMapping(userData);
171184
// find the link to open if any
172185
urlToOpen = productURLs.find(pu => pu.id === id)?.url || '';
173186
// User has signed up and the trial is ready and user selects the AAP Trial
174-
if (userFound && userReady) {
175-
if (pdt === Product.AAP) {
176-
if (!userData?.defaultUserNamespace) {
177-
// eslint-disable-next-line
178-
console.error(
179-
'unable to provision AAP. user namespace is not defined.',
180-
);
181-
return;
182-
}
183-
handleAAPInstance(userData.defaultUserNamespace);
184-
setAnsibleCredsModalOpen(true);
185-
} else if (urlToOpen) {
186-
window.open(urlToOpen, '_blank');
187-
}
187+
if (pdt === Product.AAP) {
188+
handleAAPInstance(userData.defaultUserNamespace as string);
189+
setAnsibleCredsModalOpen(true);
190+
} else if (urlToOpen) {
191+
window.open(urlToOpen, '_blank');
188192
}
189193
break;
190194
}
@@ -268,6 +272,7 @@ export const VerificationCodeStep: React.FC<VerificationCodeProps> = ({
268272

269273
<Typography
270274
data-testid="resend-code-link"
275+
component="div"
271276
variant="body2"
272277
color="primary"
273278
sx={{

0 commit comments

Comments
 (0)