Skip to content

Commit

Permalink
Settings: Scaffolding (#59)
Browse files Browse the repository at this point in the history
* Restructure settings files, rename, extract styles

* Refactor settings page and set up existing components in new structure

* Styling adjustment

* Change text to Your Account

* Settings: Metric Configuration (1/n) (#64)

* Initial work on metric config refactor in settings

* Continue iterating on refactor up to the breakdown page

* Remove routing to old metrics page - remove from menu

* Styling adjustment

* Fix key warning

Co-authored-by: Mahmoud <mahmoud@Mahmouds-MBP.cable.rcn.com>

Co-authored-by: Mahmoud <mahmoud@Mahmouds-MBP.cable.rcn.com>

Settings: Metric Configuration: Metric Details & Breakdowns (2/n) (#66)

* Initial work on metric config refactor in settings

* Continue iterating on refactor up to the breakdown page

* Styling adjustment

* Change MetricView to MetricConfiguration and update all imports - remove MetricViewMocks

Restyle metric details up to breakdown dimensions

New breakdown copy

Refactor breakdowns with toggles

* Refactor disaggregations to use checkboxes and remove toggle switch

* Add definitions panel, add icon

* Style clean up - comments

* Clean up

* Feedback: reduce height in metric boxes, only use filteredMetricSettings optimization

Co-authored-by: Mahmoud <mahmoud@Mahmouds-MBP.cable.rcn.com>

Settings: Metric Configuration: Definitions (3/n) (#83)

* Initial work on MetricDefinitions component

* Continue fleshing out definitions component, move metric context config to overall metric definition panel, set up mocks for definitions, add and update types, fix adjustments dependent on changes

* Adjust styles for scrolling

* Clean up

* Style and comment clean up

* Fix type

* Use undefined vs empty string

* Fix key warning

* Settings: Metric Configuration: Navigation (Table of Contents) (4/n)  (#85)

* Add table of contents navigation when inside of metric details, move shared state to settings page and pass state to menu and metric config, fix disaggregation issues, add styling for table of contents, fix bug in mocks, add types, various adjustments to accommodate new change

* Clean up

* Add comments

Co-authored-by: Mahmoud <mahmoud@Mahmouds-MBP.cable.rcn.com>

Co-authored-by: Mahmoud <mahmoud@Mahmouds-MBP.cable.rcn.com>

Settings: Metric Configuration: Refactor & Clean Up (5/n) (#91)

* Major clean up - separate components into their own files

* Fix dimension bug

* Fix switch agency bug

* Minor clean up

* Merge types with existing types and update all connected components

* Clean up

* Handle cases when settings array is empty or non-existent

* Handle cases when settings array is empty or non-existent

* Styling adjustments per prev feedback

* Recreate MetricsView Component for Data Visualization (#101)

* Recreate old MetricsView component
Update route and add to menu
Update styling
Remove unnecessary code - minor refactor
Clean up

* Fix styling issue

* Add spacing between header and data viz

* Add border top to data viz dropdown

* Update tooltip and link to direct users to Settings to change metric config

Co-authored-by: Mahmoud <mahmoud@Mahmouds-MBP.cable.rcn.com>

Co-authored-by: Mahmoud <mahmoud@Mahmouds-MBP.cable.rcn.com>

Settings: Metric Configuration: Save Definitions (and Replace Mocks) (6/n) (#108)

* [Summary] Remove mocks and implement definition saving functionality and UI update functionality

* Revert to default values functionality

* Fix revert to default for metric setting

* Clean up comment

* PR feedback: reverse the conditionals

* Settings: Metric Configuration: Playtesting Followups - Misc. Styling Adjustments (1/n) (#110)

* Remove tabs in metric list when agency has only one system

* Change casing to capitalized case on Monthly Annual badges

* Reduce spacing of Settings menu

* Scroll gap adjustment

* Settings: Metric Configuration: Playtesting Followups - Selection States (2/n) (#112)

* Add arrow vector, add logic for persisting on click, update hover and active states, clean up

* Settings: Metric Configuration: Playtesting Followups - Default Definition Hover State (3/n) (#113)

* Add hover feature to display the default settings when user hovers over the revert button

* Update to Choose instead of Revert per design

* Clean up

* Settings: Metric Configuration: Playtesting Followups - Enable Dimension Selection When Disaggregation is Off (4/n)  (#115)

* When disaggregation and dimensions are all off, checking on a dimension will turn on the disaggregation

* Styling bug fixes

* Implement responsiveness per design (#117)

Co-authored-by: Mahmoud <mahmoud@Mahmouds-MBP.cable.rcn.com>

Rebase adjustments - updating imports, types and other react upgrade related adjustments

Refactor settings to use routes
  • Loading branch information
mxosman authored and Mahmoud committed Nov 8, 2022
1 parent 2910171 commit b5b6da3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 57 deletions.
2 changes: 1 addition & 1 deletion publisher/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const App: React.FC = (): ReactElement => {
<Route path="/data" element={<MetricsView />} />
<Route path="/reports/create" element={<CreateReports />} />
<Route path="/reports/:id" element={<ReportDataEntry />} />
<Route path="/settings" element={<Settings />} />
<Route path="/settings/*" element={<Settings />} />
<Route path="/upload" element={<DataUpload />} />
<Route path="/review-metrics" element={<ReviewMetrics />} />
</Routes>
Expand Down
4 changes: 3 additions & 1 deletion publisher/src/components/Settings/Settings.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const SettingsContainer = styled.div`
align-items: flex-start;
padding: 48px 24px 0 24px;
position: fixed;
overflow-y: scroll;
`;

export const ContentDisplay = styled.div`
Expand All @@ -37,6 +38,7 @@ export const ContentDisplay = styled.div`
flex-direction: column;
justify-content: flex-start;
flex: 10 10 auto;
overflow-y: scroll;
`;

export const SettingsMenuContainer = styled.div`
Expand All @@ -46,7 +48,7 @@ export const SettingsMenuContainer = styled.div`
flex: 0 0 auto;
flex-direction: column;
gap: 16px;
margin-right: 70px;
margin-right: 100px;
`;

export const MenuItem = styled.div<{ selected?: boolean }>`
Expand Down
65 changes: 29 additions & 36 deletions publisher/src/components/Settings/SettingsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =============================================================================

import { observer } from "mobx-react-lite";
import React, { Fragment } from "react";
import { useLocation, useNavigate } from "react-router-dom";

import { MenuOptions, menuOptions } from "../../pages/Settings";
import { useStore } from "../../stores";
import { ListOfMetricsForNavigation, menuOptions } from "../../pages/Settings";
import {
MenuItem,
MetricsListContainer,
Expand All @@ -28,55 +27,49 @@ import {
} from ".";

export const SettingsMenu: React.FC<{
activeMenuItem: MenuOptions;
goToMenuItem: (destination: MenuOptions) => void;
}> = observer(({ activeMenuItem, goToMenuItem }) => {
const { metricConfigStore } = useStore();
const {
activeMetricKey,
activeSystem,
getMetricsBySystem,
updateActiveMetricKey,
} = metricConfigStore;
activeMetricKey: string | undefined;
setActiveMetricKey: React.Dispatch<React.SetStateAction<string | undefined>>;
listOfMetrics: ListOfMetricsForNavigation[] | undefined;
}> = ({ activeMetricKey, setActiveMetricKey, listOfMetrics }) => {
const navigate = useNavigate();
const location = useLocation();

return (
<SettingsMenuContainer>
{menuOptions.map((option) => (
<Fragment key={option}>
{Object.entries(menuOptions).map(([displayName, path]) => (
<Fragment key={path}>
<MenuItem
selected={option === activeMenuItem}
selected={location.pathname === path}
onClick={() => {
goToMenuItem(option);

if (option === "Metric Configuration") {
updateActiveMetricKey(undefined);
navigate(path);
if (location.pathname === "/settings/metric-config") {
setActiveMetricKey(undefined);
}
}}
>
{option}
{displayName}
</MenuItem>

{/* Metrics Navigation (appears when a metric has been
selected and allows users to toggle between metrics) */}
{option === "Metric Configuration" &&
activeMenuItem === "Metric Configuration" &&
activeMetricKey && (
{location.pathname === "/settings/metric-config" &&
path === "/settings/metric-config" &&
activeMetricKey &&
listOfMetrics && (
<MetricsListContainer>
{getMetricsBySystem(activeSystem)?.map(({ key, metric }) => {
return (
<MetricsListItem
key={key}
activeSection={key === activeMetricKey}
onClick={() => updateActiveMetricKey(key)}
>
{metric.label}
</MetricsListItem>
);
})}
{listOfMetrics.map((metric) => (
<MetricsListItem
key={metric.key}
activeSection={metric.key === activeMetricKey}
onClick={() => setActiveMetricKey(metric.key)}
>
{metric.display_name}
</MetricsListItem>
))}
</MetricsListContainer>
)}
</Fragment>
))}
</SettingsMenuContainer>
);
});
};
34 changes: 15 additions & 19 deletions publisher/src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// =============================================================================

import React, { useState } from "react";
import { Route, Routes } from "react-router-dom";

import { UploadedFiles } from "../components/DataUpload";
import { MetricConfiguration } from "../components/MetricConfiguration";
Expand All @@ -26,37 +27,32 @@ import {
SettingsMenu,
} from "../components/Settings";

export const menuOptions = [
"Your Account",
"Uploaded Files",
"Metric Configuration",
] as const;
export type MenuOptions = typeof menuOptions[number];
export const menuOptions = {
"Your Account": "/settings/account",
"Uploaded Files": "/settings/uploaded-files",
"Metric Configuration": "/settings/metric-config",
};
// export type MenuOptions = typeof menuOptions[number];

export type ListOfMetricsForNavigation = {
key: string;
display_name: string;
};

const Settings = () => {
const [activeMenuItem, setActiveMenuItem] = useState<MenuOptions>(
menuOptions[0]
);

const goToMenuItem = (destination: MenuOptions) =>
setActiveMenuItem(destination);
/** State specific to Metrics Configuration & Settings Menu */

return (
<SettingsContainer>
<SettingsMenu
activeMenuItem={activeMenuItem}
goToMenuItem={goToMenuItem}
/>
<SettingsMenu />

<ContentDisplay>
{activeMenuItem === "Your Account" && <AccountSettings />}
{activeMenuItem === "Uploaded Files" && <UploadedFiles />}
{activeMenuItem === "Metric Configuration" && <MetricConfiguration />}
<Routes>
<Route path="/" element={<AccountSettings />} />
<Route path="/account" element={<AccountSettings />} />
<Route path="/uploaded-files" element={<UploadedFiles />} />
<Route path="/metric-config" element={<MetricConfiguration />} />
</Routes>
</ContentDisplay>
</SettingsContainer>
);
Expand Down

0 comments on commit b5b6da3

Please sign in to comment.