Skip to content

Commit

Permalink
Use new assessment selection in project form
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaKhatri authored and subinasr committed Nov 29, 2023
1 parent 763b2ed commit e88518a
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 18 deletions.
14 changes: 7 additions & 7 deletions app/Base/configs/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ const assessments = wrap({
if (!project) {
return false;
}
return project.hasAssessmentTemplate;
return project.isAssessmentEnabled;
},
visibility: 'is-authenticated',
});
Expand All @@ -341,7 +341,7 @@ const leadGroups = wrap({
if (!project) {
return false;
}
return project.hasAssessmentTemplate;
return project.isAssessmentEnabled;
},
visibility: 'is-authenticated',
});
Expand Down Expand Up @@ -384,7 +384,7 @@ const aryDashboard = wrap({
return (
// project.isVisualizationEnabled
// && project.isVisualizationAvailable
project.hasAssessmentTemplate
project.isAssessmentEnabled
);
},
});
Expand Down Expand Up @@ -462,7 +462,7 @@ const newAssessmentEditRoute = wrap({
return false;
}
// NOTE: using permission for LEAD as we don't have one for assessment
return project.hasAssessmentTemplate && (
return project.isAssessmentEnabled && (
project.allowedPermissions.includes('CREATE_LEAD')
|| project.allowedPermissions.includes('UPDATE_LEAD')
);
Expand All @@ -486,7 +486,7 @@ const createNewAssessmentEditRoute = wrap({
return false;
}
// NOTE: using permission for LEAD as we don't have one for assessment
return project.hasAssessmentTemplate && (
return project.isAssessmentEnabled && (
project.allowedPermissions.includes('CREATE_LEAD')
|| project.allowedPermissions.includes('UPDATE_LEAD')
);
Expand All @@ -510,7 +510,7 @@ const assessmentEditRoute = wrap({
return false;
}
// NOTE: using permission for LEAD as we don't have one for assessment
return project.hasAssessmentTemplate && (
return project.isAssessmentEnabled && (
project.allowedPermissions.includes('CREATE_LEAD')
|| project.allowedPermissions.includes('UPDATE_LEAD')
);
Expand All @@ -534,7 +534,7 @@ const groupAssessmentEditRoute = wrap({
return false;
}
// NOTE: using permission for LEAD as we don't have one for assessment
return project.hasAssessmentTemplate && (
return project.isAssessmentEnabled && (
project.allowedPermissions.includes('CREATE_LEAD')
|| project.allowedPermissions.includes('UPDATE_LEAD')
);
Expand Down
2 changes: 1 addition & 1 deletion app/components/general/BulkUploadModal/LeadsPane/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function LeadsPane(props: Props) {
// onLeadGroupOptionsChange={setLeadGroupOptions}
assigneeOptions={projectUserOptions}
onAssigneeOptionChange={setProjectUserOptions}
hasAssessment={project?.hasAssessmentTemplate}
hasAssessment={project?.isAssessmentEnabled}
/>
{selectedLeadAttachment && (
<LeadPreview
Expand Down
2 changes: 1 addition & 1 deletion app/components/general/LeadEditModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ function LeadEditModal(props: Props) {
// onLeadGroupOptionsChange={setLeadGroupOptions}
assigneeOptions={projectUserOptions}
onAssigneeOptionChange={setProjectUserOptions}
hasAssessment={project?.hasAssessmentTemplate}
hasAssessment={project?.isAssessmentEnabled}
/>
</Card>
</Modal>
Expand Down
2 changes: 1 addition & 1 deletion app/gqlFragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export const LAST_ACTIVE_PROJECT_FRAGMENT = gql`
analysisFramework {
id
}
hasAssessmentTemplate
isAssessmentEnabled
id
isPrivate
title
Expand Down
2 changes: 1 addition & 1 deletion app/views/EntryEdit/SourceDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function SourceDetails(props: Props) {
confidentialityOptions={
leadOptions?.leadConfidentialityOptions?.enumValues
}
hasAssessment={project?.hasAssessmentTemplate}
hasAssessment={project?.isAssessmentEnabled}
/>
</Card>
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/views/Export/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Export() {
>
Export History
</Tab>
{project?.hasAssessmentTemplate && (
{project?.isAssessmentEnabled && (
<Tab
name="export-assessment-history"
transparentBorder
Expand All @@ -75,7 +75,7 @@ function Export() {
>
New Export
</SmartButtonLikeLink>
{project?.hasAssessmentTemplate && (
{project?.isAssessmentEnabled && (
<SmartButtonLikeLink
variant="secondary"
icons={(<IoAdd />)}
Expand All @@ -102,7 +102,7 @@ function Export() {
/>
)}
</TabPanel>
{project?.hasAssessmentTemplate && (
{project?.isAssessmentEnabled && (
<TabPanel
name="export-assessment-history"
activeClassName={styles.tabPanel}
Expand Down
37 changes: 37 additions & 0 deletions app/views/ProjectEdit/ProjectDetailsForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import RequestPrivateProjectButton from './RequestPrivateProjectButton';
import styles from './styles.css';

const privacyTooltip = 'Public projects will be visible in the "Explore DEEP" section. Any registered users will be able to see the project name, the target country, a scheenshot of the framework and the number of users, entries and sources it contains. This is the default option in DEEP as to foster collaboration and avoid duplication or efforts. Private projects will not be visible in the "Explore DEEP" section. This feature can be exceptionally requested for projects dealing with sensitive information or topics. Requests are assessed case by case and the feature is activated only in the case specific harm to the users, data or the platform itself is possible.';
const assessmentTooltip = 'Enable assessment tagging.';

const DELETE_PROJECT = gql`
mutation deleteProject($projectId: ID!) {
Expand Down Expand Up @@ -172,6 +173,7 @@ const schema: FormSchema = {
hasPubliclyViewableRestrictedLeads: [requiredCondition],
hasPubliclyViewableConfidentialLeads: [requiredCondition],
isPrivate: [],
isAssessmentEnabled: [],
isTest: [],
}),
validation: (value) => {
Expand All @@ -192,6 +194,7 @@ const initialValue: PartialFormType = {
title: '',
isPrivate: false,
isTest: false,
isAssessmentEnabled: false,
hasPubliclyViewableUnprotectedLeads: false,
hasPubliclyViewableConfidentialLeads: false,
hasPubliclyViewableRestrictedLeads: false,
Expand All @@ -215,9 +218,11 @@ const LAST_ACTIVE_PROJECT = gql`
`;

const CURRENT_PROJECT = gql`
${LAST_ACTIVE_PROJECT_FRAGMENT}
query UserCurrentProject($projectId: ID!) {
project(id: $projectId) {
id
...LastActiveProjectResponse
title
startDate
endDate
Expand All @@ -228,6 +233,7 @@ const CURRENT_PROJECT = gql`
description
isPrivate
isTest
isAssessmentEnabled
hasPubliclyViewableUnprotectedLeads
hasPubliclyViewableConfidentialLeads
hasPubliclyViewableRestrictedLeads
Expand All @@ -251,14 +257,17 @@ const CURRENT_PROJECT = gql`
`;

const PROJECT_CREATE = gql`
${LAST_ACTIVE_PROJECT_FRAGMENT}
mutation ProjectCreate($data: ProjectCreateInputType!) {
projectCreate(data: $data) {
ok
result {
...LastActiveProjectResponse
id
title
startDate
endDate
isAssessmentEnabled
hasPubliclyViewableUnprotectedLeads
hasPubliclyViewableConfidentialLeads
hasPubliclyViewableRestrictedLeads
Expand Down Expand Up @@ -289,12 +298,14 @@ mutation ProjectCreate($data: ProjectCreateInputType!) {
`;

const PROJECT_UPDATE = gql`
${LAST_ACTIVE_PROJECT_FRAGMENT}
mutation ProjectUpdate($projectId: ID!, $data: ProjectUpdateInputType!) {
project(id: $projectId) {
projectUpdate(data: $data) {
ok
result {
id
...LastActiveProjectResponse
title
startDate
endDate
Expand All @@ -305,6 +316,7 @@ mutation ProjectUpdate($projectId: ID!, $data: ProjectUpdateInputType!) {
description
isPrivate
isTest
isAssessmentEnabled
hasPubliclyViewableUnprotectedLeads
hasPubliclyViewableConfidentialLeads
hasPubliclyViewableRestrictedLeads
Expand Down Expand Up @@ -475,6 +487,10 @@ function ProjectDetailsForm(props: Props) {
{ variant: 'error' },
);
} else if (ok) {
setPristine(true);
if (response?.project?.projectUpdate?.result) {
setProject(response?.project?.projectUpdate?.result);
}
alert.show(
'Successfully updated project!',
{ variant: 'success' },
Expand Down Expand Up @@ -763,6 +779,27 @@ function ProjectDetailsForm(props: Props) {
</ContainerCard>
</div>
<div className={styles.right}>
<Container
className={styles.visibility}
headingSize="extraSmall"
contentClassName={styles.items}
heading="Assessment Registry"
inlineHeadingDescription
headerDescriptionClassName={styles.infoIconContainer}
headingDescription={(
<IoInformationCircleOutline
className={styles.infoIcon}
title={assessmentTooltip}
/>
)}
>
<Switch
name="isAssessmentEnabled"
label="Is Assessment Enabled"
value={value?.isAssessmentEnabled}
onChange={setFieldValue}
/>
</Container>
<Container
className={styles.visibility}
headingSize="extraSmall"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const LEAD_OPTIONS = gql`
}
project(id: $projectId) {
id
hasAssessmentTemplate
isAssessmentEnabled
}
}
`;
Expand Down Expand Up @@ -292,7 +292,7 @@ function FormLeadsPane(props: Props) {
// onLeadGroupOptionsChange={onLeadGroupOptionsChange}
assigneeOptions={assigneeOptions}
onAssigneeOptionChange={onAssigneeOptionChange}
hasAssessment={leadOptionsData?.project?.hasAssessmentTemplate}
hasAssessment={leadOptionsData?.project?.isAssessmentEnabled}
disabled={disabled}
/>
<LeadPreview
Expand Down
4 changes: 2 additions & 2 deletions app/views/Tagging/UnifiedConnectorModal/LeadsPane/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const PROJECT_CONNECTOR_DETAILS = gql`
}
project(id: $projectId) {
id
hasAssessmentTemplate
isAssessmentEnabled
unifiedConnector {
unifiedConnector(id: $connectorId) {
id
Expand Down Expand Up @@ -771,7 +771,7 @@ function LeadsPane(props: Props) {
// onLeadGroupOptionsChange={onLeadGroupOptionsChange}
assigneeOptions={assigneeOptions}
onAssigneeOptionChange={onAssigneeOptionChange}
hasAssessment={connectorDetailsData?.project?.hasAssessmentTemplate}
hasAssessment={connectorDetailsData?.project?.isAssessmentEnabled}
disabled={disabled}
/>
<LeadPreview
Expand Down

0 comments on commit e88518a

Please sign in to comment.