2023-01-19 13:15:46 +00:00
|
|
|
import {
|
|
|
|
AppDetailsUrlQueryParams,
|
|
|
|
AppInstallUrlQueryParams,
|
|
|
|
} from "@dashboard/apps/urls";
|
|
|
|
import AppInstallView from "@dashboard/apps/views/AppInstall";
|
2023-01-16 09:45:12 +00:00
|
|
|
import { sectionNames } from "@dashboard/intl";
|
2023-01-10 10:04:30 +00:00
|
|
|
import { parse as parseQs } from "qs";
|
|
|
|
import React from "react";
|
|
|
|
import { useIntl } from "react-intl";
|
|
|
|
import { Route, RouteComponentProps, Switch } from "react-router-dom";
|
|
|
|
|
|
|
|
import { WindowTitle } from "../components/WindowTitle";
|
|
|
|
import { AppListUrlQueryParams, AppPaths } from "./urls";
|
2023-03-01 14:04:53 +00:00
|
|
|
import AppDetailsView from "./views/AppDetails";
|
2023-01-10 10:04:30 +00:00
|
|
|
import AppListView from "./views/AppList";
|
2023-02-28 13:20:17 +00:00
|
|
|
import AppView from "./views/AppView";
|
2023-01-10 10:04:30 +00:00
|
|
|
|
2023-01-19 13:15:46 +00:00
|
|
|
const AppDetails: React.FC<RouteComponentProps<{ id: string }>> = ({
|
|
|
|
match,
|
|
|
|
}) => {
|
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: AppDetailsUrlQueryParams = qs;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<AppDetailsView id={decodeURIComponent(match.params.id)} params={params} />
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-02-27 15:35:35 +00:00
|
|
|
const AppViewRoute: React.FC<RouteComponentProps<{ id: string }>> = ({
|
|
|
|
match,
|
|
|
|
}) => <AppView id={decodeURIComponent(match.params.id)} />;
|
2023-01-19 13:15:46 +00:00
|
|
|
|
|
|
|
const AppInstall: React.FC<RouteComponentProps> = props => {
|
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: AppInstallUrlQueryParams = qs;
|
|
|
|
|
|
|
|
return <AppInstallView params={params} {...props} />;
|
|
|
|
};
|
|
|
|
|
2023-01-10 10:04:30 +00:00
|
|
|
const AppList: React.FC<RouteComponentProps> = () => {
|
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: AppListUrlQueryParams = qs;
|
|
|
|
|
|
|
|
return <AppListView params={params} />;
|
|
|
|
};
|
|
|
|
|
|
|
|
const Apps = () => {
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<WindowTitle title={intl.formatMessage(sectionNames.apps)} />
|
|
|
|
<Switch>
|
|
|
|
<Route exact path={AppPaths.appListPath} component={AppList} />
|
2023-01-19 13:15:46 +00:00
|
|
|
<Route exact path={AppPaths.appInstallPath} component={AppInstall} />
|
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
path={AppPaths.resolveAppDetailsPath(":id")}
|
|
|
|
component={AppDetails}
|
|
|
|
/>
|
2023-02-27 15:35:35 +00:00
|
|
|
<Route path={AppPaths.resolveAppPath(":id")} component={AppViewRoute} />
|
2023-01-10 10:04:30 +00:00
|
|
|
</Switch>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Apps;
|