Skip to content

Commit

Permalink
Add DuplicateModel component to Settings page for dashboard duplicati…
Browse files Browse the repository at this point in the history
…on functionality
  • Loading branch information
simlarsen committed Nov 29, 2024
1 parent 32c0cbc commit 3e97d6b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
40 changes: 31 additions & 9 deletions Dashboard/src/Pages/Dashboards/View/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import PageMap from "../../../Utils/PageMap";
import RouteMap from "../../../Utils/RouteMap";
import RouteMap, { RouteUtil } from "../../../Utils/RouteMap";
import PageComponentProps from "../../PageComponentProps";
import Route from "Common/Types/API/Route";
import ObjectID from "Common/Types/ObjectID";
import ModelDelete from "Common/UI/Components/ModelDelete/ModelDelete";
import Navigation from "Common/UI/Utils/Navigation";
import Dashboard from "Common/Models/DatabaseModels/Dashboard";
import React, { Fragment, FunctionComponent, ReactElement } from "react";
import DuplicateModel from "Common/UI/Components/DuplicateModel/DuplicateModel";
import FormFieldSchemaType from "Common/UI/Components/Forms/Types/FormFieldSchemaType";

const DashboardDelete: FunctionComponent<
PageComponentProps
Expand All @@ -15,13 +16,34 @@ const DashboardDelete: FunctionComponent<

return (
<Fragment>
<ModelDelete
modelType={Dashboard}
modelId={modelId}
onDeleteSuccess={() => {
Navigation.navigate(RouteMap[PageMap.DASHBOARDS] as Route);
}}
/>
<div className="mt-5">
<DuplicateModel
modelId={modelId}
modelType={Dashboard}
fieldsToDuplicate={{
description: true,
labels: true,
dashboardViewConfig: true
}}
navigateToOnSuccess={RouteUtil.populateRouteParams(
RouteMap[PageMap.DASHBOARDS] as Route,
)}
fieldsToChange={[
{
field: {
name: true,
},
title: "New Dashboard Name",
fieldType: FormFieldSchemaType.Text,
required: true,
placeholder: "New Dashboard Name",
validation: {
minLength: 2,
},
}
]}
/>
</div>
</Fragment>
);
};
Expand Down
2 changes: 1 addition & 1 deletion Dashboard/src/Pages/Dashboards/View/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const DashboardSideMenu: FunctionComponent<ComponentProps> = (
</SideMenuSection>

<SideMenuSection title="Advanced">
<SideMenuItem
<SideMenuItem
link={{
title: "Settings",
to: RouteUtil.populateRouteParams(
Expand Down

0 comments on commit 3e97d6b

Please sign in to comment.