Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JupyterLab Not Started App Card Fix #554

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions jhub_apps/static/js/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/components/app-card/app-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const AppCard = ({
if (serverStatus === 'Running') {
// Redirect to the app's URL if it is already running
window.location.href = url;
} else if (app && serverStatus === 'Ready') {
} else if (app && serverStatus === 'Ready' && isAppCard) {
// Set the current app and open the Start modal
e.preventDefault();
setCurrentApp({
Expand Down
9 changes: 8 additions & 1 deletion ui/src/pages/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,14 @@ export const Home = (): React.ReactElement => {
data-testid="start-btn"
variant="contained"
color="primary"
onClick={handleStart}
onClick={() => {
clearAppToStart();
if (isDefaultApp(currentApp?.name || '')) {
handleStartNotRunning();
} else {
handleStart();
}
}}
disabled={submitting}
>
Start
Expand Down
28 changes: 24 additions & 4 deletions ui/src/pages/not-running/not-running.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { AppQueryGetProps } from '@src/types/api';
import { UserState } from '@src/types/user';
import axios from '@src/utils/axios';
import { APP_BASE_URL } from '@src/utils/constants';
import { getSpawnPendingUrl, storeAppToStart } from '@src/utils/jupyterhub';
import {
getSpawnPendingUrl,
isDefaultServer,
storeAppToStart,
} from '@src/utils/jupyterhub';
import { useQuery } from '@tanstack/react-query';
import React, { useEffect } from 'react';
import { useRecoilState } from 'recoil';
Expand Down Expand Up @@ -43,14 +47,30 @@ export const NotRunning = (): React.ReactElement => {
return;
}

// If app is started, redirect to the app
if (formData?.started) {
window.location.assign(window.location.href.replace('/hub', ''));
} else if (formData?.pending && currentUser && id) {
}
// If pending, redirect to spawn pending page
else if (formData?.pending && currentUser && id) {
window.location.assign(getSpawnPendingUrl(currentUser, id));
}
// If stopped and default server, redirect to spawn pending page
else if (
formData?.stopped &&
currentUser &&
id &&
isDefaultServer(formData.name)
) {
window.location.assign(getSpawnPendingUrl(currentUser, id));
} else if (formData?.stopped && id) {
}
// If stopped and not default server, redirect home store app id for automated start
else if (formData?.stopped && id && !isDefaultServer(formData.name)) {
storeAppToStart(id); // TODO: Update this to store in global state when everything is running in single react app
window.location.assign(APP_BASE_URL);
} else {
}
// If error, redirect to home page
else {
window.location.assign(APP_BASE_URL);
}
}, [formData, id, currentUser]);
Expand Down
8 changes: 8 additions & 0 deletions ui/src/utils/jupyterhub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ export const isDefaultApp = (name: string) => {
}
};

export const isDefaultServer = (name: string) => {
if (name === '') {
return true;
} else {
return false;
}
};

export const navigateToUrl = (url: string) => {
document.location.href = url;
};
Expand Down
Loading