diff --git a/src/i18n/en-US/home.ts b/src/i18n/en-US/home.ts deleted file mode 100644 index 56e4efc525..0000000000 --- a/src/i18n/en-US/home.ts +++ /dev/null @@ -1,85 +0,0 @@ -const home = { - title: 'Welcome to Model Innovation Tool (MINT)', - subheading: - 'The place to collaborate on new CMMI models and demonstrations and access resources to assist with your model plans.', - macSubheading: - 'The place to learn about upcoming CMMI models and demonstrations.', - signIn: 'Sign in to start', - mintPurpose: 'You can use MINT to:', - startNow: 'Start a new Model Plan', - previously: 'previously ', - viewMore: 'View {{-number}} more', - viewLess: 'View less', - more: 'more', - mintTasks: [ - 'collaborate on requirements for new CMMI models and demonstrations', - 'access resources to help you complete your model plans' - ], - newModelSummaryBox: { - copy: 'Have a new model or demonstration?', - cta: 'Start a new Model Plan' - }, - allModels: { - copy: 'Don’t see the model you’re looking for?', - cta: 'View all models', - heading: 'All models', - subheading: - 'Follow models that you want to stay up to date on by clicking the star icon.', - noResults: { - heading: 'We couldn’t find any matches for "{{-searchTerm}}".', - subheading: - 'Double check your search for typos or try a different search.' - } - }, - yourModels: 'You have been added as a team member to the model plans below.', - fetchError: 'There was an error fetching models plans. Please try again.', - downloadAllCSV: 'Download all plans as CSV', - downloadSingleCSV: 'Download this Model Plan (CSV)', - requestsTable: { - id: 'model-plans', - title: 'Model plans', - basic: { - heading: 'My model plans' - }, - admin: { - heading: 'All model plans' - }, - mac: { - heading: 'Upcoming models', - empty: { - heading: 'There aren’t any model plans with CRs or TDLs.', - body: - 'Check back later. When CR or TDL is added to a model plan, it will appear here.' - } - }, - empty: { - heading: 'You haven’t been added to any Model Plans yet.', - body: - 'Once you create one or are added as a team member to an existing plan, it will appear here.' - }, - caption: - 'Below is a list of governance requests that are in draft or submitted.', - headers: { - name: 'Model name', - category: 'Category', - abbreviation: 'Short name', - amsModelID: 'ID', - modelPoc: 'Model lead(s)', - clearanceDate: 'Anticipated clearance date', - startDate: 'Model start date', - paymentDate: 'Payment start date', - keyCharacteristics: 'Key characteristics', - demoCode: 'Demo code', - crTDLs: 'CRs and TDLs', - status: 'Status', - recentActivity: 'Recent activity' - }, - noneSelectedYet: 'None selected yet', - tbd: 'To be determined', - updated: 'Updated', - unansweredQuestion: 'unanswered question', - answeredQuestion: 'answered question' - } -}; - -export default home; diff --git a/src/i18n/en-US/index.ts b/src/i18n/en-US/index.ts index dcf50d6ac1..3623a8ddd2 100644 --- a/src/i18n/en-US/index.ts +++ b/src/i18n/en-US/index.ts @@ -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'; @@ -77,7 +76,6 @@ const enUS = { getAccess, header, helpAndKnowledge, - home, homepageSettings, landing, plan, diff --git a/src/types/flags.ts b/src/types/flags.ts index 32e9936c25..5f2970de8d 100644 --- a/src/types/flags.ts +++ b/src/types/flags.ts @@ -5,7 +5,6 @@ export type Flags = { helpScoutEnabled: boolean; feedbackEnabled: boolean; notificationsEnabled: boolean; - customHomepageEnabled: boolean; }; export type FlagsState = { diff --git a/src/utils/export/CsvExportLink.tsx b/src/utils/export/CsvExportLink.tsx index f85480eff1..4209de91f3 100644 --- a/src/utils/export/CsvExportLink.tsx +++ b/src/utils/export/CsvExportLink.tsx @@ -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(); diff --git a/src/utils/user.test.ts b/src/utils/user.test.ts index 52a4aaa0b0..885af022de 100644 --- a/src/utils/user.test.ts +++ b/src/utils/user.test.ts @@ -44,8 +44,7 @@ describe('user', () => { hideGroupView: true, helpScoutEnabled: false, feedbackEnabled: false, - notificationsEnabled: false, - customHomepageEnabled: false + notificationsEnabled: false }) ).toBe(false); }); diff --git a/src/views/App/index.tsx b/src/views/App/index.tsx index 26111f0641..e063f7a3c7 100644 --- a/src/views/App/index.tsx +++ b/src/views/App/index.tsx @@ -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'; @@ -117,18 +116,11 @@ const AppRoutes = () => { if (!authState?.isAuthenticated) { return ; } - if (flags.customHomepageEnabled) { - return ; - } return ; }} /> - + diff --git a/src/views/FlagsWrapper/index.tsx b/src/views/FlagsWrapper/index.tsx index 2ce36cf2fe..3408228f0c 100644 --- a/src/views/FlagsWrapper/index.tsx +++ b/src/views/FlagsWrapper/index.tsx @@ -42,8 +42,7 @@ const UserTargetingWrapper = ({ children }: WrapperProps) => { helpScoutEnabled: false, feedbackEnabled: false, downgradeNonCMS: false, - notificationsEnabled: false, - customHomepageEnabled: false + notificationsEnabled: false } }); diff --git a/src/views/HomeNew/Settings/__snapshots__/index.test.tsx.snap b/src/views/Home/Settings/__snapshots__/index.test.tsx.snap similarity index 100% rename from src/views/HomeNew/Settings/__snapshots__/index.test.tsx.snap rename to src/views/Home/Settings/__snapshots__/index.test.tsx.snap diff --git a/src/views/HomeNew/Settings/index.scss b/src/views/Home/Settings/index.scss similarity index 100% rename from src/views/HomeNew/Settings/index.scss rename to src/views/Home/Settings/index.scss diff --git a/src/views/HomeNew/Settings/index.test.tsx b/src/views/Home/Settings/index.test.tsx similarity index 100% rename from src/views/HomeNew/Settings/index.test.tsx rename to src/views/Home/Settings/index.test.tsx diff --git a/src/views/HomeNew/Settings/index.tsx b/src/views/Home/Settings/index.tsx similarity index 100% rename from src/views/HomeNew/Settings/index.tsx rename to src/views/Home/Settings/index.tsx diff --git a/src/views/HomeNew/Settings/selectSolutions.tsx b/src/views/Home/Settings/selectSolutions.tsx similarity index 100% rename from src/views/HomeNew/Settings/selectSolutions.tsx rename to src/views/Home/Settings/selectSolutions.tsx diff --git a/src/views/HomeNew/Settings/settings.tsx b/src/views/Home/Settings/settings.tsx similarity index 100% rename from src/views/HomeNew/Settings/settings.tsx rename to src/views/Home/Settings/settings.tsx diff --git a/src/views/HomeNew/Settings/settingsOrder.tsx b/src/views/Home/Settings/settingsOrder.tsx similarity index 100% rename from src/views/HomeNew/Settings/settingsOrder.tsx rename to src/views/Home/Settings/settingsOrder.tsx diff --git a/src/views/ModelPlan/HomeTable/index.scss b/src/views/Home/Table/index.scss similarity index 100% rename from src/views/ModelPlan/HomeTable/index.scss rename to src/views/Home/Table/index.scss diff --git a/src/views/ModelPlan/HomeTable/index.tsx b/src/views/Home/Table/index.tsx similarity index 93% rename from src/views/ModelPlan/HomeTable/index.tsx rename to src/views/Home/Table/index.tsx index 7f94867edd..30ea7417a1 100644 --- a/src/views/ModelPlan/HomeTable/index.tsx +++ b/src/views/Home/Table/index.tsx @@ -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, @@ -122,7 +112,10 @@ const ModelPlansTable = ({ const tableColumns: Record = { [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', @@ -337,8 +330,12 @@ const ModelPlansTable = ({ if (value) { return value .map(characteristics => { - return i18next.t( - `generalCharacteristics:keyCharacteristics.options.${characteristics}` + return ( +
+ {i18next.t( + `generalCharacteristics:keyCharacteristics.options.${characteristics}` + )} +
); }) .join(', '); @@ -363,7 +360,7 @@ const ModelPlansTable = ({ return (
    {value.map((crtdl: CRTDLType) => ( -
  • {crtdl.idNumber}
  • +
  • {crtdl.idNumber}
  • ))}
); @@ -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', @@ -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)} > - ) : ( - - ); - } - }, - modelName: { - id: 'modelName', - Header: homeT('requestsTable.headers.name'), - accessor: 'modelName', - Cell: ({ row, value }: any) => { - const filteredNameHistory: string[] = row.original.nameHistory?.slice( - 1 - ); - return ( - <> - - {value} - - {filteredNameHistory && filteredNameHistory.length > 0 && ( - - )} - - ); - } - }, - abbreviation: { - id: 'abbreviation', - Header: homeT('requestsTable.headers.abbreviation'), - accessor: 'abbreviation' - }, - amsModelID: { - id: 'amsModelID', - Header: homeT('requestsTable.headers.amsModelID'), - accessor: 'basics.amsModelID' - }, - modelCategory: { - id: 'modelCategory', - Header: homeT('requestsTable.headers.category'), - accessor: 'basics.modelCategory', - Cell: ({ row, value }: any) => { - const additionalModelCategory = - row.original.basics.additionalModelCategories; - - // Handle no value with an early return - if (!value) { - return
{homeT('requestsTable.tbd')}
; - } - - if (additionalModelCategory.length !== 0) { - const newArray = additionalModelCategory.map( - (group: ModelCategory) => { - return i18next.t( - `basics:additionalModelCategories.options.${group}` - ); - } - ); - - return `${i18next.t( - `basics:modelCategory.options.${value}` - )}, ${newArray.join(', ')}`; - } - return i18next.t(`basics:modelCategory.options.${value}`); - } - }, - status: { - id: 'status', - Header: homeT('requestsTable.headers.status'), - accessor: ({ status }: any) => { - return i18next.t(`modelPlan:status.options.${status}`); - }, - Cell: ({ value }: any) => { - return value; - } - }, - clearanceDate: { - id: 'clearanceDate', - Header: homeT('requestsTable.headers.clearanceDate'), - accessor: ({ basics: { clearanceStarts } }: any) => { - if (clearanceStarts) { - return formatDateUtc(clearanceStarts, 'MM/dd/yyyy'); - } - return null; - }, - Cell: ({ value }: { value: string }) => { - if (!value) { - return
{homeT('requestsTable.tbd')}
; - } - return value; - } - }, - startDate: { - id: 'startDate', - Header: homeT('requestsTable.headers.startDate'), - accessor: ({ basics: { performancePeriodStarts } }: any) => { - if (performancePeriodStarts) { - return formatDateUtc(performancePeriodStarts, 'MM/dd/yyyy'); - } - return null; - }, - Cell: ({ value }: any) => { - if (!value) { - return
{homeT('requestsTable.tbd')}
; - } - return value; - } - }, - recentActivity: { - id: 'recentActivity', - Header: homeT('requestsTable.headers.recentActivity'), - accessor: 'modifiedDts', - Cell: ({ row, value }: any) => { - const { discussions } = row.original; - const formattedUpdatedDate = `${homeT( - 'requestsTable.updated' - )} ${formatDateLocal( - value || row.original.createdDts, - 'MM/dd/yyyy' - )}`; - return ( - <> - {formattedUpdatedDate} - {discussions.length > 0 && ( -
- {' '} - {discussions.length}{' '} - {i18next.t('discussionsMisc:discussionBanner.discussion', { - count: discussions.length - })} -
- )} - - ); - } - }, - paymentDate: { - id: 'paymentDate', - Header: homeT('requestsTable.headers.paymentDate'), - accessor: ({ payments: { paymentStartDate } }: any) => { - if (paymentStartDate) { - return formatDateUtc(paymentStartDate, 'MM/dd/yyyy'); - } - return null; - }, - Cell: ({ value }: { value: string | null }) => { - if (!value) { - return
{homeT('requestsTable.tbd')}
; - } - return value; - } - }, - keyCharacteristics: { - id: 'keyCharacteristics', - Header: homeT('requestsTable.headers.keyCharacteristics'), - accessor: 'generalCharacteristics.keyCharacteristics', - Cell: ({ value }: { value: KeyCharacteristic[] }) => { - if (value) { - return value - .map(characteristics => { - return i18next.t( - `generalCharacteristics:keyCharacteristics.options.${characteristics}` - ); - }) - .join(', '); - } - return null; - } - }, - demoCode: { - id: 'demoCode', - Header: homeT('requestsTable.headers.demoCode'), - accessor: 'basics.demoCode' - }, - crTdls: { - id: 'crTdls', - Header: homeT('requestsTable.headers.crTDLs'), - accessor: 'crTdls', - Cell: ({ value }: { value: CRTDLType[] }) => { - if (!value || value.length === 0) { - return
{homeT('requestsTable.tbd')}
; - } - const crtdlIDs = value - .map((crtdl: CRTDLType) => crtdl.idNumber) - .join(', '); - return crtdlIDs; - } - }, - modelPoc: { - id: 'modelPoc', - Header: homeT('requestsTable.headers.modelPoc'), - accessor: 'collaborators', - Cell: ({ value }: any) => { - if (value) { - const leads = value.filter((item: CollaboratorsType) => { - return item.teamRoles.includes(TeamRole.MODEL_LEAD); - }); - return ( - <> - {leads.map((item: CollaboratorsType, index: number) => { - return `${item.userAccount.commonName}${ - index === leads.length - 1 ? '' : ', ' - }`; - })} - - ); - } - return ''; - } - } - }; - - const columnList: any = [...tableColumns[type]].map( - column => columnOptions[column] - ); - - return columnList; - }, [homeT, updateFavorite, type]); - - const { - getTableProps, - getTableBodyProps, - headerGroups, - canPreviousPage, - canNextPage, - pageOptions, - pageCount, - gotoPage, - nextPage, - previousPage, - setPageSize, - page, - setGlobalFilter, - state, - rows, - prepareRow - } = useTable( - { - columns, - data, - sortTypes: { - alphanumeric: (rowOne, rowTwo, columnName) => { - return sortColumnValues( - rowOne.values[columnName], - rowTwo.values[columnName] - ); - } - }, - globalFilter: useMemo(() => globalFilterCellText, []), - autoResetSortBy: false, - // Resets to page 1 upon client global filtering. False value if changing/filtering your data externally - autoResetPage: true, - initialState: { - sortBy: useMemo(() => [{ id: 'modelName', asc: true }], []), - pageIndex: 0 - } - }, - useFilters, - useGlobalFilter, - useSortBy, - usePagination - ); - - // Checking if the table is for Assessment and if they have no associated models - // If so, do not render the table at all - useEffect(() => { - if (!loading && isAssessment && userModels && data.length === 0) { - if (hideTable) hideTable(true); - } - }, [loading, isAssessment, userModels, data, hideTable]); - - if (tableHidden) { - return null; - } - - if (!data.length && loading) { - return ; - } - - if (error) { - return {homeT('fetchError')}; - } - - if (data.length === 0) { - return ( - - {homeT('requestsTable.empty.body')} - - ); - } - - rows.map(row => prepareRow(row)); - - const homeStyle = (index: number) => { - return { - minWidth: - (index === 0 && '170px') || - (index === 2 && '100px') || - (index === 1 && '110px') || - '138px', - paddingLeft: '0' - }; - }; - - const modelsStyle = (index: number) => { - return { - minWidth: - (type === 'models' && index === 0 && '50px') || - (type === 'models' && index === 2 && '100px') || - (type === 'models' && index === 3 && '100px') || - '138px', - padding: index === 0 ? '0' : 'auto', - paddingTop: index === 0 ? '0rem' : 'auto', - paddingLeft: '0', - paddingBottom: index === 0 ? '0rem' : '.5rem' - }; - }; - - return ( -
-
-
- {!userModels && ( - - )} - - {!userModels && ( - - )} -
- - <>{csvDownload && } -
- - - - {homeT('requestsTable.caption')} - - - - {headerGroups.map(headerGroup => ( - - {headerGroup.headers - // @ts-ignore - .filter((column, index) => !hiddenColumns?.includes(index)) - .map((column, index) => ( - - - - ))} - - ))} - - - - {page.map(row => { - return ( - - {row.cells - .filter((cell, index) => { - // @ts-ignore - return !hiddenColumns?.includes(index); - }) - .map((cell, i) => { - if (i === 0) { - return ( - - {cell.render('Cell')} - - ); - } - return ( - - {cell.render('Cell')} - - ); - })} - - ); - })} - - - - {state.globalFilter && page.length === 0 && ( - - {homeT('allModels.noResults.subheading')} - - )} - - {!userModels && ( - - )} - -
- {currentTableSortDescription(headerGroups[0])} -
-
- ); -}; - -const RenderFilteredNameHistory = ({ names }: { names: string[] }) => { - const { t } = useTranslation('home'); - const [isShowingAllNames, setShowAllNames] = useState(false); - - const firstThreeNames = names.slice(0, 3); - - return ( - <> -

- {t('previously')}{' '} - {isShowingAllNames - ? `${names.join(', ')}` - : `${firstThreeNames.join(', ')}`} -

- {names.length > 3 && ( - - )} - - ); -}; - -export default ModelPlansTable;