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

Showing welcome header when there are no organisations #3133

Merged
merged 5 commits into from
Sep 3, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
### Changed

- The fallback segmentation layer attribute of volume tracings is now persisted to NML/ZIP files. Upon re-upload, only volume tracings with this attribute will show a fallback layer. Use `tools/volumeAddFallbackLayer.py` to add this attribute to existing volume tracings.
- The welcome header will now also show on the default page if there are no existing organisations. [#3133](https://github.com/scalableminds/webknossos/pull/3133)

### Fixed

Expand All @@ -27,7 +28,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).

### Removed

-
- Removed the automatic redirect to the onboarding page from the default page if there are no existing organisations. [#3133](https://github.com/scalableminds/webknossos/pull/3133)


## [18.09.0](https://github.com/scalableminds/webknossos/releases/tag/18.09.0) - 2018-08-20
Expand Down
25 changes: 7 additions & 18 deletions app/assets/javascripts/dashboard/spotlight_view.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// @flow
import * as React from "react";
import { Link, withRouter } from "react-router-dom";
import { Spin, Layout, message, Button, Row, Col } from "antd";
import { Spin, Layout, Button, Row, Col } from "antd";
import { connect } from "react-redux";
import GalleryDatasetView from "dashboard/gallery_dataset_view";
import { getOrganizations, getDatasets } from "admin/admin_rest_api";
import { handleGenericError } from "libs/error_handling";
import messages from "messages";
import * as Utils from "libs/utils";
import features from "features";
import type { RouterHistory } from "react-router-dom";
import type { OxalisState } from "oxalis/store";
Expand Down Expand Up @@ -117,36 +115,26 @@ type Props = {

type State = {
datasets: Array<APIMaybeUnimportedDatasetType>,
hasOrganisations: boolean,
isLoading: boolean,
};

class SpotlightView extends React.PureComponent<Props, State> {
state = {
datasets: [],
hasOrganisations: true,
isLoading: true,
};

componentDidMount() {
this.fetchData();
this.maybeRedirectToOnboarding();
}

async maybeRedirectToOnboarding() {
const organizations = await getOrganizations();
if (organizations.length > 0) {
return;
}

message.info(messages["setup.redirect"]);
await Utils.sleep(2000);
this.props.history.push("/onboarding");
}

async fetchData(): Promise<void> {
try {
this.setState({ isLoading: true });
const datasets = await getDatasets();
this.setState({ datasets });
const [datasets, organizations] = await Promise.all([getDatasets(), getOrganizations()]);
this.setState({ datasets, hasOrganisations: organizations.length > 0 });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to also use the american english spelling for organization here :)

} catch (error) {
handleGenericError(error);
} finally {
Expand All @@ -157,7 +145,8 @@ class SpotlightView extends React.PureComponent<Props, State> {
render() {
return (
<Layout>
{this.props.activeUser == null && features().allowOrganizationCreation ? (
{this.props.activeUser == null &&
(features().allowOrganizationCreation || !this.state.hasOrganisations) ? (
<WelcomeHeader history={this.props.history} />
) : (
<SimpleHeader />
Expand Down