Skip to content

Commit

Permalink
Fix ary dashboard tab visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaKhatri committed Feb 15, 2024
1 parent 353e0e9 commit b71785a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 104 deletions.
153 changes: 59 additions & 94 deletions app/Base/configs/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,26 @@ const analysisDashboard = wrap({
visibility: 'is-authenticated',
});

const dashboard = wrap({
parent: { path: taggingRoute.path },
path: '/dashboard/',
title: 'Dashboard',
navbarVisibility: true,
component: lazy(() => import('#views/Dashboard')),
componentProps: {
},
visibility: 'is-authenticated',
checkPermissions: (_, project, skipProjectPermissionCheck) => {
if (skipProjectPermissionCheck) {
return true;
}
if (!project) {
return false;
}
return project.isVisualizationEnabled;
},
});

const assessments = wrap({
parent: { path: taggingRoute.path },
path: '/assessments/',
Expand All @@ -396,12 +416,13 @@ const assessments = wrap({
},
visibility: 'is-authenticated',
});
const leadGroups = wrap({

const aryDashboard = wrap({
parent: { path: taggingRoute.path },
path: '/source-groups/',
title: 'Source Groups',
path: '/assessment-dashboard/',
title: 'Assessments Dashboard',
navbarVisibility: true,
component: lazy(() => import('#views/LeadGroups')),
component: lazy(() => import('#views/AryDashboard')),
componentProps: {
},
checkPermissions: (_, project, skipProjectPermissionCheck) => {
Expand All @@ -415,12 +436,13 @@ const leadGroups = wrap({
},
visibility: 'is-authenticated',
});
const dashboard = wrap({
parent: { path: taggingRoute.path },
path: '/dashboard/',
title: 'Dashboard',
navbarVisibility: true,
component: lazy(() => import('#views/Dashboard')),

const newAssessmentEditRoute = wrap({
parent: { path: projectRoute.path },
path: '/assessments/:assessmentId(\\d+)/',
title: 'Edit Assessment',
navbarVisibility: false,
component: lazy(() => import('#views/EditAry')),
componentProps: {
},
visibility: 'is-authenticated',
Expand All @@ -431,19 +453,36 @@ const dashboard = wrap({
if (!project) {
return false;
}
return project.isVisualizationEnabled;
// NOTE: using permission for LEAD as we don't have one for assessment
return project.isAssessmentEnabled && (
project.allowedPermissions.includes('CREATE_LEAD')
|| project.allowedPermissions.includes('UPDATE_LEAD')
);
},
});

const aryDashboard = wrap({
parent: { path: taggingRoute.path },
path: '/assessment-dashboard/',
title: 'Assessments Dashboard',
navbarVisibility: true,
component: lazy(() => import('#views/AryDashboard')),
const createNewAssessmentRoute = wrap({
parent: { path: projectRoute.path },
path: '/assessments/new/',
title: 'Create Assessment',
navbarVisibility: false,
component: lazy(() => import('#views/EditAry')),
componentProps: {
},
visibility: 'is-authenticated',
checkPermissions: (_, project, skipProjectPermissionCheck) => {
if (skipProjectPermissionCheck) {
return true;
}
if (!project) {
return false;
}
// NOTE: using permission for LEAD as we don't have one for assessment
return project.isAssessmentEnabled && (
project.allowedPermissions.includes('CREATE_LEAD')
|| project.allowedPermissions.includes('UPDATE_LEAD')
);
},
});

const exportRoute = wrap({
Expand Down Expand Up @@ -504,78 +543,6 @@ const newAssessmentExportCreateRoute = wrap({
},
});

const newAssessmentEditRoute = wrap({
parent: { path: projectRoute.path },
path: '/assessments/:assessmentId(\\d+)/',
title: 'Edit Assessment',
navbarVisibility: false,
component: lazy(() => import('#views/EditAry')),
componentProps: {
},
visibility: 'is-authenticated',
checkPermissions: (_, project, skipProjectPermissionCheck) => {
if (skipProjectPermissionCheck) {
return true;
}
if (!project) {
return false;
}
// NOTE: using permission for LEAD as we don't have one for assessment
return project.isAssessmentEnabled && (
project.allowedPermissions.includes('CREATE_LEAD')
|| project.allowedPermissions.includes('UPDATE_LEAD')
);
},
});

const createNewAssessmentEditRoute = wrap({
parent: { path: projectRoute.path },
path: '/assessments/new/',
title: 'Create Assessment',
navbarVisibility: false,
component: lazy(() => import('#views/EditAry')),
componentProps: {
},
visibility: 'is-authenticated',
checkPermissions: (_, project, skipProjectPermissionCheck) => {
if (skipProjectPermissionCheck) {
return true;
}
if (!project) {
return false;
}
// NOTE: using permission for LEAD as we don't have one for assessment
return project.isAssessmentEnabled && (
project.allowedPermissions.includes('CREATE_LEAD')
|| project.allowedPermissions.includes('UPDATE_LEAD')
);
},
});

const groupAssessmentEditRoute = wrap({
parent: { path: projectRoute.path },
path: '/assessments/lead-groups/:leadGroupId(\\d+)/',
title: 'Edit Source Group Assessment',
navbarVisibility: false,
component: lazy(() => import('#views/EditGroupAssessment')),
componentProps: {
},
visibility: 'is-authenticated',
checkPermissions: (_, project, skipProjectPermissionCheck) => {
if (skipProjectPermissionCheck) {
return true;
}
if (!project) {
return false;
}
// NOTE: using permission for LEAD as we don't have one for assessment
return project.isAssessmentEnabled && (
project.allowedPermissions.includes('CREATE_LEAD')
|| project.allowedPermissions.includes('UPDATE_LEAD')
);
},
});

const documentViewer = wrap({
path: '/document-preview/:leadHash/',
title: 'Document Preview',
Expand Down Expand Up @@ -674,9 +641,7 @@ const routes = {
termsOfService,
extensionPrivacyPolicy,
sources,
assessments,
analysisDashboard,
leadGroups,
fourHundredFour,
dashboard,
aryDashboard,
Expand All @@ -685,11 +650,11 @@ const routes = {
reportEdit: reportEditRoute,
publicReportView: publicReportViewRoute,
newReport: newReportRoute,
assessmentExportCreate: newAssessmentExportCreateRoute,
entryEdit: entryEditRoute,
groupAssessmentEdit: groupAssessmentEditRoute,
newAssessmentEdit: newAssessmentEditRoute,
createNewAssessmentEdit: createNewAssessmentEditRoute,
createNewAssessment: createNewAssessmentRoute,
assessments,
assessmentExportCreate: newAssessmentExportCreateRoute,
entryEditRedirect,
documentViewerRedirect,
projectRedirect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,16 @@ function generateReportText(entry: Entry) {
?.map((author) => organizationTitleSelector(author)).join(', ');
const publisher = entry.lead.source ? organizationTitleSelector(entry.lead.source) : '';
const organizations = (authors?.length ?? 0) > 0 ? authors : publisher;
const entryCreatedDate = new Date(entry.createdAt);
const entryText = entry.excerpt.replace(/[.,\s]*$/, ' ');

const url = entry.lead.url.length > 0 ? entry.lead.url : entry.lead.shareViewUrl;

if (!entry.lead.publishedOn) {
return `${entryText}([${organizations}](${url})).`;
}

const entryCreatedDate = new Date(entry.lead.publishedOn);

return `${entryText}([${organizations}](${url}), ${encodeDate(entryCreatedDate)}).`;
}

Expand Down
10 changes: 2 additions & 8 deletions app/views/Project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,9 @@ function Project(props: Props) {
</Route>
<Route
exact
path={routes.createNewAssessmentEdit.path}
path={routes.createNewAssessment.path}
>
{routes.createNewAssessmentEdit.load({ className })}
</Route>
<Route
exact
path={routes.groupAssessmentEdit.path}
>
{routes.groupAssessmentEdit.load({ className })}
{routes.createNewAssessment.load({ className })}
</Route>
<Route
path={routes.projectEdit.path}
Expand Down
2 changes: 1 addition & 1 deletion app/views/Sources/SourcesTable/Actions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function Actions<T extends string>(props: Props<T>) {
variant="secondary"
title="Add assessment"
disabled={disabled}
route={routes.createNewAssessmentEdit}
route={routes.createNewAssessment}
attrs={{
projectId,
assessmentId,
Expand Down

0 comments on commit b71785a

Please sign in to comment.