2023-01-19 13:15:46 +00:00
|
|
|
import {
|
|
|
|
AppDetailsUrlQueryParams,
|
|
|
|
AppInstallUrlQueryParams,
|
2023-03-06 09:57:25 +00:00
|
|
|
} from "@dashboard/apps/urls";
|
|
|
|
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";
|
2023-06-27 07:29:40 +00:00
|
|
|
import {
|
|
|
|
AppInstallView,
|
|
|
|
AppListView,
|
|
|
|
AppManageView,
|
2023-07-25 08:45:34 +00:00
|
|
|
AppPermissionRequestView,
|
2023-06-27 07:29:40 +00:00
|
|
|
AppView,
|
|
|
|
} from "src/apps/views";
|
2023-01-10 10:04:30 +00:00
|
|
|
|
|
|
|
import { WindowTitle } from "../components/WindowTitle";
|
|
|
|
import { AppListUrlQueryParams, AppPaths } from "./urls";
|
|
|
|
|
2023-06-27 07:29:40 +00:00
|
|
|
const AppManageRoute: React.FC<RouteComponentProps<{ id: string }>> = ({
|
2023-01-19 13:15:46 +00:00
|
|
|
match,
|
|
|
|
}) => {
|
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: AppDetailsUrlQueryParams = qs;
|
|
|
|
|
|
|
|
return (
|
2023-06-27 07:29:40 +00:00
|
|
|
<AppManageView id={decodeURIComponent(match.params.id)} params={params} />
|
2023-01-19 13:15:46 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2023-06-27 07:29:40 +00:00
|
|
|
const AppInstallRoute: React.FC<RouteComponentProps> = props => {
|
2023-01-19 13:15:46 +00:00
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: AppInstallUrlQueryParams = qs;
|
|
|
|
|
|
|
|
return <AppInstallView params={params} {...props} />;
|
|
|
|
};
|
|
|
|
|
2023-06-27 07:29:40 +00:00
|
|
|
const AppListRoute: React.FC<RouteComponentProps> = () => {
|
2023-01-10 10:04:30 +00:00
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: AppListUrlQueryParams = qs;
|
|
|
|
|
|
|
|
return <AppListView params={params} />;
|
|
|
|
};
|
|
|
|
|
2023-06-27 07:29:40 +00:00
|
|
|
export const AppsSectionRoot = () => {
|
2023-01-10 10:04:30 +00:00
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<WindowTitle title={intl.formatMessage(sectionNames.apps)} />
|
|
|
|
<Switch>
|
2023-06-27 07:29:40 +00:00
|
|
|
<Route exact path={AppPaths.appListPath} component={AppListRoute} />
|
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
path={AppPaths.appInstallPath}
|
|
|
|
component={AppInstallRoute}
|
|
|
|
/>
|
2023-01-19 13:15:46 +00:00
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
path={AppPaths.resolveAppDetailsPath(":id")}
|
2023-06-27 07:29:40 +00:00
|
|
|
component={AppManageRoute}
|
2023-01-19 13:15:46 +00:00
|
|
|
/>
|
2023-07-25 08:45:34 +00:00
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
path={AppPaths.resolveRequestPermissionsPath(":id")}
|
|
|
|
component={AppPermissionRequestView}
|
|
|
|
/>
|
2023-02-27 15:35:35 +00:00
|
|
|
<Route path={AppPaths.resolveAppPath(":id")} component={AppViewRoute} />
|
2023-01-10 10:04:30 +00:00
|
|
|
</Switch>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|