Skip to content

Commit

Permalink
feat: new session start flow (#1990) (#2003)
Browse files Browse the repository at this point in the history
Fix #1990
  • Loading branch information
cramakri committed Aug 19, 2022
1 parent cd0b3d6 commit 83dce10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
12 changes: 7 additions & 5 deletions client/src/notebooks/Notebooks.present.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,21 @@ function ShowSession(props) {
return handlers.fetchLogs(notebook.data.name);
};

const urlList = Url.get(Url.pages.project.session, {
const urlList = Url.get(Url.pages.sessions);
const urlProject = Url.get(Url.pages.project.base, {
namespace: filters.namespace,
path: filters.project,
});

// redirect immediately if the session fail
if (props.history && notebook.data?.status?.state === SessionStatus.failed)
props.history.push(urlList);
props.history.push(urlProject);

// Always add all sub-components and hide them one by one to preserve the iframe navigation where needed
return (
<div className="bg-white">
<SessionInformation notebook={notebook} stopNotebook={handlers.stopNotebook} urlList={urlList} />
<SessionInformation notebook={notebook} stopNotebook={handlers.stopNotebook}
urlProject={urlProject} />
<div className="d-lg-flex">
<SessionNavbar fetchLogs={fetchLogs} setTab={setTab} tab={tab} />
<div className={`border sessions-iframe-border w-100`}>
Expand All @@ -123,14 +125,14 @@ function ShowSession(props) {
}

function SessionInformation(props) {
const { notebook, stopNotebook, urlList } = props;
const { notebook, stopNotebook, urlProject } = props;

const [stopping, setStopping] = useState(false);

const stop = async () => {
setStopping(true);
// ? no need to handle the error here since we use the notifications at container level
const success = await stopNotebook(notebook.data.name, urlList);
const success = await stopNotebook(notebook.data.name, urlProject);
if (success !== false)
return;
setStopping(false);
Expand Down
14 changes: 8 additions & 6 deletions client/src/project/Project.present.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,6 @@ class ProjectNav extends Component {
<NavItem>
<RenkuNavLink exact={false} to={this.props.datasetsUrl} title="Datasets" />
</NavItem>
<NavItem>
<RenkuNavLink exact={false} to={this.props.notebookServersUrl} title="Sessions" />
</NavItem>
<NavItem className="pe-0">
<RenkuNavLink exact={false} to={this.props.settingsUrl} title="Settings" />
</NavItem>
Expand Down Expand Up @@ -1076,8 +1073,8 @@ const ProjectSessions = (props) => {
const locationFrom = props.history?.location?.state?.from;
const filePath = props.history?.location?.state?.filePath;
const backNotebookLabel = filePath ? `Back to ${filePath}` : "Back to notebook file";
const backButtonLabel = locationFrom ? backNotebookLabel : "Back to sessions list";
const backUrl = locationFrom ?? props.notebookServersUrl;
const backButtonLabel = locationFrom ? backNotebookLabel : `Back to ${props.metadata.pathWithNamespace}`;
const backUrl = locationFrom ?? props.baseUrl;

const backButton = (<GoBackButton label={backButtonLabel} url={backUrl} />);

Expand Down Expand Up @@ -1403,9 +1400,14 @@ class ProjectView extends Component {
render={props => <ProjectViewHeader {...this.props} minimalistHeader={false}/>} />
<Route path={this.props.overviewUrl}
render={props => <ProjectViewHeader {...this.props} minimalistHeader={false}/>} />
<Route path={this.props.notebookServersUrl}
render={() => null} />
<Route component={()=><ProjectViewHeader {...this.props} minimalistHeader={true}/>} />
</Switch>
<ProjectNav key="nav" {...this.props} />
<Switch key="projectNav">
<Route path={this.props.notebookServersUrl} render={() => null} />
<Route component={() =><ProjectNav key="nav" {...this.props} />} />
</Switch>
<Row key="content">
<Switch>
<Route exact path={this.props.baseUrl}
Expand Down

0 comments on commit 83dce10

Please sign in to comment.