Skip to content

Commit

Permalink
[MINT-2208] Homepage refactor (#1245)
Browse files Browse the repository at this point in the history
* Changed file names, minor refactor

* Fixed route and models favorites props

* Remove feature flag

* Targeted first table in cypress

* Merge in main, resolved conflicts, move HomeTable

* Removed unneeded flag

* Updated snapshots
  • Loading branch information
patrickseguraoddball authored Jul 29, 2024
1 parent 3265370 commit 005b51b
Show file tree
Hide file tree
Showing 33 changed files with 489 additions and 1,560 deletions.
85 changes: 0 additions & 85 deletions src/i18n/en-US/home.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/i18n/en-US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import feedback from './feedback';
import footer from './footer';
import general from './general';
import header from './header';
import home from './home';
import landing from './landing';
import plan from './modelPlan';
import modelPlanTaskList from './modelPlanTaskList';
Expand All @@ -77,7 +76,6 @@ const enUS = {
getAccess,
header,
helpAndKnowledge,
home,
homepageSettings,
landing,
plan,
Expand Down
1 change: 0 additions & 1 deletion src/types/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export type Flags = {
helpScoutEnabled: boolean;
feedbackEnabled: boolean;
notificationsEnabled: boolean;
customHomepageEnabled: boolean;
};

export type FlagsState = {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/export/CsvExportLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type CsvExportLinkType = {
export const CsvExportLink = ({
modelPlanID
}: CsvExportLinkType): React.ReactElement => {
const { t } = useTranslation('home');
const { t } = useTranslation('customHome');

const { fetchSingleData, fetchAllData } = useFetchCSVData();

Expand Down
3 changes: 1 addition & 2 deletions src/utils/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ describe('user', () => {
hideGroupView: true,
helpScoutEnabled: false,
feedbackEnabled: false,
notificationsEnabled: false,
customHomepageEnabled: false
notificationsEnabled: false
})
).toBe(false);
});
Expand Down
12 changes: 2 additions & 10 deletions src/views/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ import FlagsWrapper from 'views/FlagsWrapper';
import HelpAndKnowledge from 'views/HelpAndKnowledge';
import GetAccess from 'views/HelpAndKnowledge/Articles/GetAccess';
import Home from 'views/Home';
import HomeNew from 'views/HomeNew';
import HomePageSettings from 'views/HomeNew/Settings';
import HomePageSettings from 'views/Home/Settings';
import Landing from 'views/Landing';
import Login from 'views/Login';
import ModelAccessWrapper from 'views/ModelAccessWrapper';
Expand Down Expand Up @@ -117,18 +116,11 @@ const AppRoutes = () => {
if (!authState?.isAuthenticated) {
return <Landing />;
}
if (flags.customHomepageEnabled) {
return <HomeNew />;
}
return <Home />;
}}
/>

<ProtectedRoute
path="/homepage-settings"
enabled={flags.customHomepageEnabled}
component={HomePageSettings}
/>
<ProtectedRoute path="/homepage-settings" component={HomePageSettings} />

<ProtectedRoute path="/notifications" component={Notifications} />

Expand Down
3 changes: 1 addition & 2 deletions src/views/FlagsWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ const UserTargetingWrapper = ({ children }: WrapperProps) => {
helpScoutEnabled: false,
feedbackEnabled: false,
downgradeNonCMS: false,
notificationsEnabled: false,
customHomepageEnabled: false
notificationsEnabled: false
}
});

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,15 @@ type CRTDLType =
| GetCrtdLsQuery['modelPlan']['crs'][0]
| GetCrtdLsQuery['modelPlan']['tdls'][0];

type ModelPlansTableProps =
| {
id: string;
type: ViewCustomizationType;
updateFavorite?: never;
hiddenColumns?: number[]; // indexes of columns to be hidden
canSearch?: boolean;
isHome?: boolean;
isAssessment?: boolean;
}
| {
id: string;
type: ViewCustomizationType.FOLLOWED_MODELS;
updateFavorite: (modelPlanID: string, type: UpdateFavoriteProps) => void;
hiddenColumns?: number[]; // indexes of columns to be hidden
canSearch?: boolean;
isHome?: boolean;
isAssessment?: boolean;
};
type ModelPlansTableProps = {
id: string;
type: ViewCustomizationType;
updateFavorite?: (modelPlanID: string, type: UpdateFavoriteProps) => void;
hiddenColumns?: number[]; // indexes of columns to be hidden
canSearch?: boolean;
isHome?: boolean;
isAssessment?: boolean;
};

const ModelPlansTable = ({
id,
Expand Down Expand Up @@ -122,7 +112,10 @@ const ModelPlansTable = ({

const tableColumns: Record<ViewCustomizationType, string[]> = {
[ViewCustomizationType.MY_MODEL_PLANS]: [...homeColumns],
[ViewCustomizationType.ALL_MODEL_PLANS]: [...homeColumns],
[ViewCustomizationType.ALL_MODEL_PLANS]: [
...(!isHome ? ['isFavorite'] : []),
...homeColumns
],
[ViewCustomizationType.FOLLOWED_MODELS]: ['isFavorite', ...homeColumns],
[ViewCustomizationType.MODELS_WITH_CR_TDL]: [
'modelName',
Expand Down Expand Up @@ -337,8 +330,12 @@ const ModelPlansTable = ({
if (value) {
return value
.map(characteristics => {
return i18next.t(
`generalCharacteristics:keyCharacteristics.options.${characteristics}`
return (
<div key={characteristics}>
{i18next.t(
`generalCharacteristics:keyCharacteristics.options.${characteristics}`
)}
</div>
);
})
.join(', ');
Expand All @@ -363,7 +360,7 @@ const ModelPlansTable = ({
return (
<ul className="margin-0">
{value.map((crtdl: CRTDLType) => (
<li>{crtdl.idNumber}</li>
<li key={crtdl.idNumber}>{crtdl.idNumber}</li>
))}
</ul>
);
Expand Down Expand Up @@ -476,15 +473,9 @@ const ModelPlansTable = ({
const modelsStyle = (index: number) => {
return {
minWidth:
(type === ViewCustomizationType.FOLLOWED_MODELS &&
index === 0 &&
'50px') ||
(type === ViewCustomizationType.FOLLOWED_MODELS &&
index === 2 &&
'100px') ||
(type === ViewCustomizationType.FOLLOWED_MODELS &&
index === 3 &&
'100px') ||
(!isHome && index === 0 && '50px') ||
(!isHome && index === 2 && '100px') ||
(!isHome && index === 3 && '100px') ||
'138px',
padding: index === 0 ? '0' : 'auto',
paddingTop: index === 0 ? '0rem' : 'auto',
Expand Down Expand Up @@ -542,11 +533,7 @@ const ModelPlansTable = ({
aria-sort={getColumnSortStatus(column)}
className="table-header"
scope="col"
style={
type === ViewCustomizationType.FOLLOWED_MODELS
? modelsStyle(index)
: homeStyle(index)
}
style={!isHome ? modelsStyle(index) : homeStyle(index)}
>
<button
className={classNames(
Expand Down Expand Up @@ -649,7 +636,7 @@ const ModelPlansTable = ({
};

const RenderFilteredNameHistory = ({ names }: { names: string[] }) => {
const { t } = useTranslation('home');
const { t } = useTranslation('customHome');
const [isShowingAllNames, setShowAllNames] = useState(false);

const firstThreeNames = names.slice(0, 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,9 @@ exports[`The home page > matches setting snapshot 1`] = `
>
Did you know you can customize this page?
</p>
<div
class="row-reverse"
>
<div>
<a
class="display-flex flex-align-center usa-button--unstyled"
class="display-flex flex-align-center"
href="/homepage-settings"
>
<svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ModelBySolutionStatus, OperationalSolutionKey } from 'gql/gen/graphql';

import useCheckResponsiveScreen from 'hooks/useCheckMobile';
import { helpSolutions } from 'views/HelpAndKnowledge/SolutionsHelp/solutionsMap';
import { ModelsBySolutionType } from 'views/HomeNew/components/ModelsBySolutions/table';
import { ModelsBySolutionType } from 'views/Home/components/ModelsBySolutions/table';

import './index.scss';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
HelpSolutionBaseType,
helpSolutions
} from 'views/HelpAndKnowledge/SolutionsHelp/solutionsMap';
import ModelsBySolutionTable from 'views/HomeNew/components/ModelsBySolutions/table';
import ModelsBySolutionTable from 'views/Home/components/ModelsBySolutions/table';

import './index.scss';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { TranslationBasics } from 'types/translation';
import { formatDateUtc } from 'utils/date';
import ModelsBySolutionsBanner, {
StatusCategories
} from 'views/HomeNew/components/ModelsBySolutions/banner';
} from 'views/Home/components/ModelsBySolutions/banner';

import ModelSolutionCard from './card';

Expand Down
15 changes: 12 additions & 3 deletions src/views/Home/index.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
@use 'uswds-core' as *;

.home {
&__hr {
border-top: 1px solid color('base-light');
}
&__card {
flex-direction: row-reverse;

.usa-card__container {
padding: 1rem;
border-radius: .25rem;
border: 2px solid color('base-lighter');
box-shadow: 0 4px 8px 0px rgba(0, 0, 0, 0.1);
height: auto !important;
margin: 0 !important;
}
}
}
Loading

0 comments on commit 005b51b

Please sign in to comment.