Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
ba8dcad
Merge pull request #2233 from the-deep/feature/conditional-form
AdityaKhatri Nov 26, 2021
d022da5
Fix undiscard button request
AdityaKhatri Nov 26, 2021
e3b41cf
Add lead group edit functionality
AdityaKhatri Nov 27, 2021
157eadf
Update explore deep styling
AdityaKhatri Nov 29, 2021
1531c41
Fix export structure issue
AdityaKhatri Nov 29, 2021
5e4d2ce
Fix finalize button behavior
AdityaKhatri Nov 30, 2021
65cf5cf
Remove swap button from range inputs
AdityaKhatri Dec 1, 2021
ef8cb48
Add entry comment popup in entry edit page
AdityaKhatri Dec 1, 2021
eb07227
Add entry comment counts to source list and entry grid
AdityaKhatri Dec 1, 2021
17a2ca4
Assign sizes to modals
AdityaKhatri Dec 1, 2021
043152a
Merge branch 'fix/analysis-module-bugs' into develop-new
tnagorra Dec 1, 2021
24d1635
Add versioninig for analytical framework
tnagorra Nov 26, 2021
b14da39
Add validation functions for conditional widgets
tnagorra Nov 30, 2021
9df4ccc
Remove un-necessary fields on conditional
tnagorra Nov 30, 2021
01d7942
Enable overriding configurations
tnagorra Dec 1, 2021
2eccf50
Update widgetVersion on attribute creation
tnagorra Dec 1, 2021
f510f41
Show "extension" icon on conditional widget children
tnagorra Dec 2, 2021
4d95170
Merge pull request #2249 from the-deep/feature/widget-versioning
AdityaKhatri Dec 2, 2021
2d1857e
Hide child widgets according to defined condition
tnagorra Dec 2, 2021
a02f262
Merge pull request #2257 from the-deep/feature/widget-conditional
AdityaKhatri Dec 2, 2021
1d612fe
Add ary dashboard
AdityaKhatri Dec 2, 2021
803f5b1
Merge branch 'feature/add-ary-dashboard' into develop-new
tnagorra Dec 3, 2021
595feab
Change favicon for new deep
subinasr Dec 2, 2021
cf75b44
Add empty messages and icons in all ListViews
subinasr Dec 2, 2021
36f89fd
Add min height to listviews
AdityaKhatri Dec 3, 2021
fbb5b82
Add pending, filtered and empty messages in TableView and ListView
subinasr Dec 3, 2021
15b3452
Fix filtered logic in source tables
AdityaKhatri Dec 4, 2021
ce46185
Merge pull request #2256 from the-deep/feature/minor-fixes
AdityaKhatri Dec 4, 2021
183025f
Add public table and map for explore page
AdityaKhatri Dec 3, 2021
651a882
Merge branch 'feature/public-explore-page' into develop-new
tnagorra Dec 4, 2021
9bb501f
Add Assessment Registry using iframe
samshara Dec 1, 2021
7ed2d60
Change heirarchy of Assessment edit
tnagorra Dec 4, 2021
8128d00
Merge pull request #2254 from the-deep/feature/add-ary-iframe
AdityaKhatri Dec 5, 2021
df7d7f7
Fix Export related bugs
samshara Dec 2, 2021
f9e19e5
Merge pull request #2259 from the-deep/fix/export-page
AdityaKhatri Dec 5, 2021
9922886
Add default name to export title
AdityaKhatri Dec 5, 2021
14c17f1
Merge branch 'fix/default-query-title' into develop-new
tnagorra Dec 5, 2021
5cb0990
Update sub-sectors from matrix-2d
tnagorra Dec 3, 2021
eb284df
Implement 'apply to all' and 'apply to all below' on entry
tnagorra Dec 4, 2021
c57041f
Fix apply to all / apply to all below styling
AdityaKhatri Dec 6, 2021
c943c38
Merge pull request #2260 from the-deep/feature/matrix2d-sub-sectors
AdityaKhatri Dec 6, 2021
8380811
Add 'Copy lead to other projects' functionality in tagging page
subinasr Nov 10, 2021
0f91a00
Add mutation to copy leads to other projects
subinasr Nov 26, 2021
84eede2
Fix PR comments
subinasr Nov 30, 2021
7640da9
Fix leads copy modal
AdityaKhatri Dec 6, 2021
0523d1f
Merge pull request #2250 from the-deep/feature/copy-leads-to-project
AdityaKhatri Dec 6, 2021
7e6eb54
Refactor UserGroup view
samshara Dec 6, 2021
b4b7351
Update lead copy modal permissions
AdityaKhatri Dec 7, 2021
3901d1a
Fetch membership only if user-group is expanded
samshara Dec 7, 2021
96501f3
Merge pull request #2263 from the-deep/feature/refactor-user-group
AdityaKhatri Dec 7, 2021
ab34d96
Fetch project sources when entry is updated
samshara Dec 7, 2021
b04a2a2
Merge pull request #2264 from the-deep/fix/fetch-source-entry-edit
AdityaKhatri Dec 7, 2021
34fd77f
Show alert when password change is successful
samshara Dec 8, 2021
197f2bc
Merge pull request #2267 from the-deep/feature/show-alert-password-ch…
subinasr Dec 8, 2021
a1db8df
Persist data in listview and tableview during pagination
subinasr Dec 8, 2021
c409486
Merge pull request #2271 from the-deep/feature/persist-lists-and-tables
AdityaKhatri Dec 9, 2021
7239ce7
Implement logic to invert conditional validation
tnagorra Dec 7, 2021
a4eafb2
Merge pull request #2265 from the-deep/feature/conditional-invert
AdityaKhatri Dec 9, 2021
386fd87
Add delete functionalities in geo areas edit tab
AdityaKhatri Dec 7, 2021
b6c9a32
Change register request to gql
AdityaKhatri Dec 8, 2021
b8aeaca
Show only published areas in regions modal
AdityaKhatri Dec 8, 2021
19fb995
Add notification count
AdityaKhatri Dec 8, 2021
5e04495
Fix organigram expansion on children nodes
AdityaKhatri Dec 8, 2021
6667908
Add messages in preview
AdityaKhatri Dec 8, 2021
3512e4b
Merge pull request #2270 from the-deep/feature/geo-improvements
samshara Dec 9, 2021
e522d5d
Add errored state to list view and table views
AdityaKhatri Dec 9, 2021
f16438a
Merge branch 'feature/upgrade-deep-ui' into develop-new
tnagorra Dec 9, 2021
6962edf
Cleanup keys with empty object and undefined on matrices
tnagorra Dec 9, 2021
e8e9834
Merge pull request #2272 from the-deep/feature/conditional-matrix-cle…
AdityaKhatri Dec 9, 2021
0143948
Fix screenshot issues
AdityaKhatri Dec 9, 2021
531ea1b
Merge branch 'feature/fix-screenshots' into develop-new
tnagorra Dec 9, 2021
4e83e37
Fix entry excerpt redundant excerpt
AdityaKhatri Dec 9, 2021
a466a7a
Merge pull request #2276 from the-deep/fix/excerpt-input-stying
samshara Dec 9, 2021
8992d48
Clone analysis framework
samshara Dec 9, 2021
4829df7
Merge pull request #2275 from the-deep/feature/clone-analysis-framework
AdityaKhatri Dec 9, 2021
fc7aa21
Add error messages
subinasr Dec 7, 2021
00b3351
Remove gqlError from alerts.
subinasr Dec 9, 2021
a96a252
Merge pull request #2269 from the-deep/feature/add-error-messages
AdityaKhatri Dec 10, 2021
98be08a
Fix type issues on charts and map
tnagorra Dec 10, 2021
2fc48d9
Update rest request library
AdityaKhatri Dec 10, 2021
b7cdb45
Merge pull request #2280 from the-deep/fix/typing-charts-ts
AdityaKhatri Dec 10, 2021
7fedce7
Fix Recent Activity page
subinasr Dec 10, 2021
05d7c35
Move bulk delete action to table
AdityaKhatri Dec 10, 2021
fbda0cb
Fix link in sources table
AdityaKhatri Dec 12, 2021
668e6d7
Merge pull request #2281 from the-deep/fix/entry-comments-on-recent-a…
AdityaKhatri Dec 12, 2021
0ba29c2
Upgrade sentry to 6.16.0
thenav56 Dec 8, 2021
c54f405
Fix chart styling
tnagorra Dec 13, 2021
a948f7d
Merge branch 'feature/upgrade-sentry' into develop-new
tnagorra Dec 13, 2021
5656867
Change lead preview request to gql
AdityaKhatri Dec 12, 2021
941cf2a
Add title to every quick action button
AdityaKhatri Dec 12, 2021
dc8ad1a
Add apropriate messages in simplified lead preview
AdityaKhatri Dec 12, 2021
9db71b4
Merge pull request #2285 from the-deep/fix/matrix2d-sub-column
samshara Dec 13, 2021
11d9445
Hide exists filter for entries grid view
samshara Dec 13, 2021
e850d69
Merge pull request #2287 from the-deep/fix/entry-grid-exists-fitler
subinasr Dec 13, 2021
18571a9
Move parent widgets filtering logic inside WidgetConditionalEditor
tnagorra Dec 13, 2021
ce43440
Do not show prompt on hashchange
tnagorra Dec 13, 2021
02b738b
Disable google translate on html
tnagorra Dec 13, 2021
2af35bf
Show all entries tab when user clicks on add button from review page
AdityaKhatri Dec 13, 2021
6d529b7
Merge pull request #2286 from the-deep/feature/fix-parent-conditional…
AdityaKhatri Dec 13, 2021
4c5294d
Fix GeoLocationInput to build options locally from selected geojson
samshara Dec 10, 2021
5fa528d
Fix lead preview percentage symbol bug
AdityaKhatri Dec 14, 2021
9b4a525
Merge pull request #2282 from the-deep/fix/geolocation-input
AdityaKhatri Dec 14, 2021
1020c0f
Show message when there is no project activity
samshara Dec 13, 2021
acee395
Add message component in ngrams modal
AdityaKhatri Dec 14, 2021
f69e3c3
Merge pull request #2288 from the-deep/fix/no-activity-project
AdityaKhatri Dec 14, 2021
ff5a399
Fix naming inconsistencies in user group
AdityaKhatri Dec 14, 2021
e8b9827
Change classname to active classname in tab panels
AdityaKhatri Dec 14, 2021
f39f325
Merge pull request #2289 from the-deep/fix/naming-inconsistency
samshara Dec 15, 2021
68b71fe
Use graphql API to update user profile information
samshara Dec 14, 2021
ec5c002
Merge pull request #2290 from the-deep/feature/use-graphql-user-profile
AdityaKhatri Dec 15, 2021
4e4f2a5
Fix area chart sorting issue
AdityaKhatri Dec 15, 2021
92220d4
Fix drag and drop styling
AdityaKhatri Dec 15, 2021
c8c0883
Merge pull request #2291 from the-deep/fix/area-chart-sorting-issue
samshara Dec 15, 2021
e00bd82
Fix assignment item for entry comment
AdityaKhatri Dec 15, 2021
1484429
Merge pull request #2292 from the-deep/fix/assignment
samshara Dec 15, 2021
9f8dde3
Fix bug reports
AdityaKhatri Dec 16, 2021
f590685
Make home button clickable
AdityaKhatri Dec 16, 2021
562f4c1
Merge pull request #2293 from the-deep/fix/screenshot-issues
samshara Dec 16, 2021
d97698a
Add public options for organizations and analysis framework for public
subinasr Dec 16, 2021
ce0688d
Merge pull request #2295 from the-deep/feature/add-public-project-fil…
AdityaKhatri Dec 20, 2021
496d056
Hide assessment export if there is no ary attached to it
AdityaKhatri Dec 16, 2021
2cb49dd
Fix hidden matrix 2d
AdityaKhatri Dec 17, 2021
a6194e3
Add ability to add assessment from source groups
AdityaKhatri Dec 17, 2021
34f839f
Merge pull request #2297 from the-deep/fix/hide-assessment-export
samshara Dec 20, 2021
944231b
Use virtualize view on EntryEdit page
tnagorra Dec 16, 2021
120d40b
Update deep ui
tnagorra Dec 20, 2021
8448f8a
Merge pull request #2294 from the-deep/feature/virtualized-entries
samshara Dec 20, 2021
4edd011
Scroll to top entry after pagination
samshara Dec 23, 2021
887e70c
Show alert when user group is added, removed and modified
samshara Dec 24, 2021
adc36cc
Merge pull request #2302 from the-deep/feature/alert-user-group
AdityaKhatri Dec 27, 2021
ba1d6c9
Add autoformat button on excerpt
AdityaKhatri Dec 22, 2021
2a26f33
Fix link to assessments edit from lead groups
AdityaKhatri Dec 22, 2021
daef984
Merge pull request #2303 from the-deep/fix/auto-format-button
samshara Dec 28, 2021
efd301f
Use latest textarea and fix virtualization
AdityaKhatri Dec 27, 2021
8d312fe
Merge pull request #2304 from the-deep/fix/use-new-textarea
samshara Dec 28, 2021
14f61ca
Add proper notification for verified and control status
samshara Dec 22, 2021
5f7dd17
Merge pull request #2299 from the-deep/fix/entry-notification-verify-…
AdityaKhatri Dec 28, 2021
59f2a9d
Show latest sources and entries at first in list, table view
samshara Dec 22, 2021
9f5b851
Merge pull request #2300 from the-deep/fix/sources-entries-ordering
AdityaKhatri Dec 29, 2021
139a641
Add upload file size limit to file input
samshara Dec 29, 2021
afd5778
Merge pull request #2306 from the-deep/feature/add-size-limit-file-input
AdityaKhatri Dec 30, 2021
2416e4b
Reset active page when filter is applied in sources table
samshara Dec 29, 2021
2579432
Merge pull request #2305 from the-deep/fix/sources-pagination
AdityaKhatri Dec 30, 2021
834de81
Fix framework show more button
samshara Dec 29, 2021
6a0cc58
Merge pull request #2307 from the-deep/fix/show-more-framework-button
AdityaKhatri Dec 30, 2021
8da02bd
Set active project of user after project delete
samshara Dec 30, 2021
d84f034
Merge pull request #2308 from the-deep/fix/set-active-project-project…
AdityaKhatri Dec 31, 2021
c22b4f7
Fix limit framework image upload file size
samshara Dec 31, 2021
619e014
Merge pull request #2309 from the-deep/fix/limit-file-size-framework-…
AdityaKhatri Jan 4, 2022
20070c0
Add hide done notifications option
AdityaKhatri Jan 4, 2022
5c4e0c1
Merge pull request #2312 from the-deep/feature/hide-done-notifications
samshara Jan 4, 2022
0979b77
Add token for ngrams graph generation
priyesh777 Jan 3, 2022
70dcfd8
Merge pull request #2313 from the-deep/fix/n-grams-graph
samshara Jan 4, 2022
e500bd4
Add transition to Navbar
tnagorra Dec 20, 2021
4bd3d09
Update node version
tnagorra Dec 21, 2021
8be411c
Add eslint config for react keys
tnagorra Dec 21, 2021
60d692a
Update dependencies
tnagorra Dec 22, 2021
906d091
Use VirtualizedListView on EntryEdit
tnagorra Jan 4, 2022
ce819ac
Update babel polyfill options (add runtime)
tnagorra Jan 4, 2022
7c30b9a
Update deepui and fix SVG use
AdityaKhatri Jan 5, 2022
68a2879
Merge pull request #2298 from the-deep/fix/slow-entries-page
AdityaKhatri Jan 5, 2022
69c2f8c
Update react router to v6
tnagorra Jan 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 10 additions & 11 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
"@babel/preset-typescript",
],
"plugins": [
// Reuse babel"s injected headers
// Reuse babel's injected headers
"@babel/plugin-transform-runtime",

// Polyfill
["polyfill-corejs3", {
"method": "usage-global",
}],
["polyfill-regenerator", {
"method": "usage-global",
}],

// Handle absolute imports
["babel-plugin-module-resolver", {
"root": ["."],
Expand All @@ -27,21 +35,12 @@

// Extends javascript support
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-do-expressions",

// Extends react support
"@babel/plugin-transform-react-constant-elements",
"@babel/plugin-transform-react-inline-elements",
// "@babel/plugin-transform-react-inline-elements",

// Extends graphql support
'babel-plugin-graphql-tag',

// Polyfill
["polyfill-corejs3", {
"method": "usage-global",
}],
["polyfill-regenerator", {
"method": "usage-global",
}],
],
}
13 changes: 12 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const config = {
},
rules: {
strict: 1,
'default-param-last': 0,

'no-unused-vars': 0,
'@typescript-eslint/no-unused-vars': 1,
Expand Down Expand Up @@ -76,6 +77,12 @@ const config = {
'react/jsx-indent': [2, 4],
'react/jsx-indent-props': [2, 4],
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
'react/jsx-props-no-spreading': 0,
'react/jsx-key': ['warn', {
checkFragmentShorthand: true,
checkKeyMustBeforeSpread: true,
}],

'react/prop-types': [1, { ignore: [], customValidators: [], skipUndeclared: false }],
'react/forbid-prop-types': [1],
'react/destructuring-assignment': [1, 'always', { ignoreClassFields: true }],
Expand All @@ -89,12 +96,16 @@ const config = {
],
}],
'react/no-unused-state': 'warn',
'react/jsx-props-no-spreading': 0,
'react/require-default-props': ['warn', { ignoreFunctionalComponents: true }],
'react/default-props-match-prop-types': ['warn', {
allowRequiredDefaults: true,
}],


'react/function-component-definition': [2, {
'namedComponents': 'function-declaration',
'unnamedComponents': 'function-expression',
}],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',

Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM node:12.20-alpine
FROM node:lts-alpine

MAINTAINER togglecorp [email protected]

RUN apk update\
&& apk add --no-cache git bash
&& apk add --no-cache git bash python3 g++ make

WORKDIR /code

COPY ./package.json ./yarn.lock /code/
RUN yarn install --network-concurrency 1
RUN yarn install --frozen-lockfile

COPY . /code/
2 changes: 2 additions & 0 deletions app/Base/components/AuthPopup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function AuthPopup() {
return (
<Modal
heading="Invalid Session"
size="extraSmall"
freeHeight
onCloseButtonClick={onCancel}
footerClassName={styles.actionButtonsRow}
footer={(
Expand Down
95 changes: 76 additions & 19 deletions app/Base/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
import React, { useContext } from 'react';
import { _cs } from '@togglecorp/fujs';
import { gql, useMutation } from '@apollo/client';
import { Link } from 'react-router-dom';
import { useQuery, gql, useMutation } from '@apollo/client';
import {
ButtonLikeLink,
QuickActionLink,
QuickActionDropdownMenu,
DropdownMenu,
DropdownMenuItem,
useConfirmation,
useAlert,
Svg,
} from '@the-deep/deep-ui';
import {
IoHelp,
IoCompassOutline,
IoNotificationsOutline,
IoLogInOutline,
IoLogOutOutline,
} from 'react-icons/io5';

import Svg from '#components/Svg';
import Notifications from '#components/Notifications';
import SmartNavLink from '#base/components/SmartNavLink';
import SmartButtonLikeLink from '#base/components/SmartButtonLikeLink';
import Avatar from '#components/Avatar';
import { UserContext } from '#base/context/UserContext';
import route from '#base/configs/routes';
import { LogoutMutation } from '#generated/types';
import {
LogoutMutation,
UserNotificationsCountQuery,
UserNotificationsCountQueryVariables,
} from '#generated/types';
import deepLogo from '#resources/img/deep-logo-new.svg';

import styles from './styles.css';

const NOTIFICATION_POLL_INTERVAL = 60000;

const LOGOUT = gql`
mutation Logout {
logout {
Expand All @@ -35,29 +44,58 @@ const LOGOUT = gql`
}
`;

export const USER_NOTIFICATIONS_COUNT = gql`
query UserNotificationsCount {
notifications(
status: UNSEEN,
) {
totalCount
}
}
`;

interface Props {
className?: string;
}

function Navbar(props: Props) {
const { className } = props;
const alert = useAlert();

const {
authenticated,
user,
setUser,
} = useContext(UserContext);

const {
data: notifications,
} = useQuery<UserNotificationsCountQuery, UserNotificationsCountQueryVariables>(
USER_NOTIFICATIONS_COUNT,
{
pollInterval: NOTIFICATION_POLL_INTERVAL,
},
);

const [logout] = useMutation<LogoutMutation>(
LOGOUT,
{
onCompleted: (data) => {
if (data.logout?.ok) {
setUser(undefined);
} else {
alert.show(
'Failed to logout.',
{ variant: 'error' },
);
}
// FIXME: handle failure
},
// FIXME: handle failure
onError: () => {
alert.show(
'Failed to logout.',
{ variant: 'error' },
);
},
},
);

Expand All @@ -70,18 +108,22 @@ function Navbar(props: Props) {
message: 'Are you sure you want to logout?',
});

const notificationsCount = notifications?.notifications?.totalCount;

return (
<nav className={_cs(className, styles.navbar)}>
<div className={styles.appBrand}>
<Link
to={route.home.path}
className={styles.appBrand}
>
<Svg
className={styles.logo}
src={deepLogo}
/>
</div>
</Link>
<div className={styles.main}>
<div className={styles.navLinks}>
<SmartNavLink
exact
route={route.home}
className={styles.link}
/>
Expand All @@ -95,25 +137,40 @@ function Navbar(props: Props) {
/>
</div>
<div className={styles.actions}>
<ButtonLikeLink
to={route.explore.path}
<SmartButtonLikeLink
route={route.explore}
variant="tertiary"
icons={<IoCompassOutline />}
>
Explore DEEP
</ButtonLikeLink>
</SmartButtonLikeLink>
<SmartButtonLikeLink
route={route.login}
variant="tertiary"
icons={(
<IoLogInOutline />
)}
>
Login
</SmartButtonLikeLink>
<QuickActionLink
title="DEEP Support"
to="https://deephelp.zendesk.com/hc/en-us"
>
<IoHelp />
</QuickActionLink>
<QuickActionDropdownMenu
label={<IoNotificationsOutline />}
popupClassName={styles.popup}
persistent
>
<Notifications />
</QuickActionDropdownMenu>
{authenticated && (
<QuickActionDropdownMenu
label={(<IoNotificationsOutline />)}
className={styles.notificationButton}
actions={notificationsCount !== 0 ? notificationsCount : undefined}
popupClassName={styles.popup}
actionsContainerClassName={styles.notificationCount}
persistent
>
<Notifications />
</QuickActionDropdownMenu>
)}
</div>
</div>
{authenticated && user && (
Expand Down
25 changes: 22 additions & 3 deletions app/Base/components/Navbar/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,29 @@
display: flex;
align-items: center;
flex-shrink: 0;
padding: 0 calc(var(--dui-spacing-large) - var(--dui-spacing-small));
padding: var(--dui-spacing-large);
gap: var(--dui-spacing-small);

>* {
margin: 0 var(--dui-spacing-small);
.notification-button {
position: relative;
overflow: visible;

.notification-count {
display: flex;
position: absolute;
top: -0.5em;
right: -0.5em;
align-items: center;
justify-content: center;
/* NOTE: Want to move this a bit up */
border-radius: 1em;
background-color: var(--dui-color-danger);
padding: 2px;
min-width: 1.4em;
min-height: 1.4em;
color: var(--dui-color-text-on-dark);
font-size: var(--dui-font-size-extra-small);
}
}
}

Expand Down
16 changes: 9 additions & 7 deletions app/Base/components/Page/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect, useContext } from 'react';
import { Redirect } from 'react-router-dom';
import { Navigate } from 'react-router-dom';
import { isDefined } from '@togglecorp/fujs';

import FullPageErrorMessage from '#views/FullPageErrorMessage';
import { UserContext } from '#base/context/UserContext';
Expand All @@ -8,7 +9,6 @@ import { ProjectContext } from '#base/context/ProjectContext';
import PageTitle from '#base/components/PageTitle';
import { Project } from '#base/types/project';
import ErrorBoundary from '#base/components/ErrorBoundary';
import divingKraken from '#resources/img/diving-kraken.png';

import styles from './styles.css';

Expand All @@ -25,7 +25,7 @@ export interface Props<T extends { className?: string }> {
project: Project | undefined,
skipProjectPermissionCheck: boolean,
) => boolean | undefined,
navbarVisibility: boolean;
navbarVisibility: boolean | undefined;

path: string;
loginPage?: string;
Expand Down Expand Up @@ -65,7 +65,9 @@ function Page<T extends { className?: string }>(props: Props<T>) {
() => {
// NOTE: should not set visibility for redirection or, navbar will
// flash
if (!redirect) {
// NOTE: if navbarVisibility do not change navbar state
// useful for parent routes
if (!redirect && isDefined(navbarVisibility)) {
setNavbarVisibility(navbarVisibility);
}
},
Expand All @@ -78,14 +80,14 @@ function Page<T extends { className?: string }>(props: Props<T>) {
if (redirectToSignIn) {
// console.warn('Redirecting to sign-in');
return (
<Redirect to={loginPage} />
<Navigate to={loginPage} />
);
}

if (redirectToHome) {
// console.warn('Redirecting to dashboard');
return (
<Redirect to={defaultPage} />
<Navigate to={defaultPage} />
);
}

Expand All @@ -99,7 +101,7 @@ function Page<T extends { className?: string }>(props: Props<T>) {
<FullPageErrorMessage
errorTitle="403"
errorMessage="You do not have permission to access this page"
errorImage={divingKraken}
krakenVariant="hi"
/>
</>
);
Expand Down
Loading