Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ yarn-error.log*

.eslintcache
tsconfig.tsbuildinfo

.idea
4 changes: 2 additions & 2 deletions app/Base/configs/env.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const myApp = process.env.MY_APP_ID;
export const appCommitHash = process.env.REACT_APP_COMMITHASH;

export const deepEnvironment = process.env.REACT_APP_DEEP_ENVIRONMENT || 'dev';
export const isDebugMode = process.env.REACT_APP_DEBUG_MODE?.toLowerCase() === 'true';
export const deepEnvironment = process.env.REACT_APP_DEEP_ENVIRONMENT || 'prod';
export const isDebugMode = process.env.REACT_APP_DEBUG_MODE?.toLowerCase() === 'false';

// Endpoints
// TODO: Make api endpoint environment variables consistent with protocol and domain
Expand Down
8 changes: 6 additions & 2 deletions app/Base/configs/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ const analysis = wrap({
},
visibility: 'is-authenticated',
checkPermissions: (user, project, skipProjectPermissionCheck) => {
const accessAnalysisModule = !!user?.accessibleFeatures?.some((f) => f.key === 'ANALYSIS');
// const accessAnalysisModule =
// !!user?.accessibleFeatures?.some((f) => f.key === 'ANALYSIS');
const accessAnalysisModule = true;
if (!accessAnalysisModule) {
return false;
}
Expand All @@ -339,7 +341,9 @@ const pillarAnalysis = wrap({
},
visibility: 'is-authenticated',
checkPermissions: (user, project, skipProjectPermissionCheck) => {
const accessAnalysisModule = !!user?.accessibleFeatures?.some((f) => f.key === 'ANALYSIS');
// const accessAnalysisModule =
// !!user?.accessibleFeatures?.some((f) => f.key === 'ANALYSIS');
const accessAnalysisModule = true;
if (!accessAnalysisModule) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from 'react';
import {
TextInput,
DateDualRangeInput,
} from '@the-deep/deep-ui';

import {
SetValueArg,
Error,
useFormObject,
getErrorObject,
getErrorString,
} from '@togglecorp/toggle-form';

import NonFieldError from '#components/NonFieldError';

import {
KoboParams,
} from '../../../types';

const koboDefaultValues: KoboParams = {};

interface Props<T extends string> {
name: T;
value: KoboParams | undefined | null;
error: Error<KoboParams>;
onChange: (val: SetValueArg<KoboParams>, name: T) => void;
disabled?: boolean;
}

function KoboParamsInput<T extends string>(props: Props<T>) {
const {
name,
value,
error: riskyError,
onChange,
disabled,
} = props;
const error = getErrorObject(riskyError);
const setParamsFieldValue = useFormObject(name, onChange, value ?? koboDefaultValues);

return (
<>
<NonFieldError error={error} />
<TextInput
name="project_id"
label="Project ID"
value={value?.project_id}
onChange={setParamsFieldValue}
error={getErrorString(error?.project_id)}
disabled={disabled}
/>
<TextInput
name="token"
label="Token"
value={value?.token}
onChange={setParamsFieldValue}
error={getErrorString(error?.token)}
disabled={disabled}
/>
</>
);
}

export default KoboParamsInput;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import AtomFeedParamsInput from './AtomFeedParamsInput';
import UnhcrParams from './UnhcrParamsInput';
import HumanitarianResponseParamsInput from './HumanitarianResponseParamsInput';
import PdnaParamsInput from './PdnaParamsInput';
import KoboParamsInput from './KoboToolboxParamsInput';

import styles from './styles.css';

Expand Down Expand Up @@ -91,6 +92,15 @@ function ConnectorSourceForm<T extends number>(props: Props<T>) {
disabled={disabled}
/>
)}
{value.source === 'KOBO' && (
<KoboParamsInput
name="params"
value={value.params}
onChange={setFieldValue}
error={error?.params}
disabled={disabled}
/>
)}
{value.source === 'HUMANITARIAN_RESP' && (
<HumanitarianResponseParamsInput
name="params"
Expand Down
5 changes: 3 additions & 2 deletions app/views/ProjectEdit/Connector/EditConnectorModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ import ConnectorSourceForm from './ConnectorSourceForm';

import styles from './styles.css';

type SupportedSource = 'RELIEF_WEB' | 'UNHCR' | 'RSS_FEED' | 'ATOM_FEED' | 'HUMANITARIAN_RESP' | 'PDNA';
const supportedSources = ['RELIEF_WEB', 'UNHCR', 'RSS_FEED', 'ATOM_FEED', 'HUMANITARIAN_RESP', 'PDNA'];
type SupportedSource = 'RELIEF_WEB' | 'UNHCR' | 'RSS_FEED' | 'ATOM_FEED' | 'HUMANITARIAN_RESP' | 'PDNA' | 'KOBO';
const supportedSources = ['RELIEF_WEB', 'UNHCR', 'RSS_FEED', 'ATOM_FEED', 'HUMANITARIAN_RESP', 'PDNA', 'KOBO'];

const sourcesLabel: { [key in SupportedSource]: string } = {
RELIEF_WEB: 'Relief Web',
Expand All @@ -59,6 +59,7 @@ const sourcesLabel: { [key in SupportedSource]: string } = {
ATOM_FEED: 'ATOM Feed',
HUMANITARIAN_RESP: 'Humanitarian Response',
PDNA: 'PDNA',
KOBO: 'KoboToolbox',
};

const sourceKeySelector = (item: SupportedSource) => item;
Expand Down
28 changes: 27 additions & 1 deletion app/views/ProjectEdit/Connector/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,34 @@ export const sourceSchema:SourceFormSchema = {
case 'UNHCR': {
const params: ObjectSchema<PartialForm<UnhcrParams>> = {
fields: () => ({
country: [],
date_from: [],
date_to: [],
country: [],
}),
validation: (paramsValue) => {
if (
paramsValue
&& paramsValue.date_to
&& paramsValue.date_from
&& new Date(paramsValue.date_from) > new Date(paramsValue.date_to)
) {
return '"From" date should be smaller than "To" date';
}
return undefined;
},
};
return {
...baseSchema,
params,
};
}
case 'KOBO': {
const params: ObjectSchema<PartialForm<UnhcrParams>> = {
fields: () => ({
date_from: [],
date_to: [],
project_id: [requiredStringCondition],
token: [requiredStringCondition],
}),
validation: (paramsValue) => {
if (
Expand Down Expand Up @@ -140,6 +165,7 @@ export const sourceSchema:SourceFormSchema = {
'url-field': [requiredStringCondition],
}),
};

return {
...baseSchema,
params,
Expand Down
10 changes: 10 additions & 0 deletions app/views/ProjectEdit/Connector/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,13 @@ export interface AtomFeedParams {
'url-field': string;
}

export interface KoboParams {
project_id?: string;
token?: string;
date_from?: string;
date_to?: string;
}

export interface HumanitarianResponseParams {
country?: string;
}
Expand Down Expand Up @@ -745,6 +752,9 @@ export type SourceInput = Omit<DeepMandatory<PurgeNull<ConnectorSourceGqInputTyp
} | {
source: 'UNHCR';
params: UnhcrParams;
} | {
source: 'KOBO';
params: KoboParams;
});

export type ConnectorInputType = DeepReplace<
Expand Down
6 changes: 4 additions & 2 deletions app/views/ProjectEdit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ function ProjectEdit() {
const { projectId } = useParams<{ projectId: string | undefined }>();
const userId = user?.id;

const isConnectorsAccessible = !!user
?.accessibleFeatures?.some((feature) => feature.key === 'CONNECTORS');
const isConnectorsAccessible = true;

// const isConnectorsAccessible = !!user
// ?.accessibleFeatures?.some((feature) => feature.key === 'CONNECTORS');

const handleCreate = useCallback(
(newProjectId: string) => {
Expand Down
38 changes: 36 additions & 2 deletions app/views/Tagging/UnifiedConnectorModal/LeadsPane/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ interface Props {
setFormFieldValue: (...entries: EntriesAsList<PartialFormType>) => void;
disabled: boolean;
}
let csvUrlDerived: string | undefined;

function LeadsPane(props: Props) {
const {
Expand Down Expand Up @@ -299,7 +300,16 @@ function LeadsPane(props: Props) {
}

const suggestedLead = connectorSourceLead.connectorLead;

let urlDerived;

try {
const urlObject = JSON.parse(suggestedLead.url.replace(/'/g, '"'));
urlDerived = urlObject.pdf;
csvUrlDerived = urlObject.csv;
} catch (error) {
urlDerived = suggestedLead.url;
csvUrlDerived = undefined;
}
const newLead = {
clientId: randomString(),
sourceType: 'WEBSITE' as const,
Expand All @@ -308,7 +318,8 @@ function LeadsPane(props: Props) {
isAssessmentLead: false,
assignee: user?.id,

url: suggestedLead.url,
url: urlDerived,
csvUrl: csvUrlDerived,
title: suggestedLead.title,
publishedOn: suggestedLead.publishedOn,
authors: suggestedLead.authors.map((item) => item.id),
Expand Down Expand Up @@ -724,6 +735,25 @@ function LeadsPane(props: Props) {
contentClassName={styles.content}
headerActions={(
<>
{getCsvUrlDerived() && (
<Button
name={undefined}
onClick={() => {
const csvUrl = getCsvUrlDerived();
if (csvUrl) {
const link = document.createElement('a');
link.href = csvUrl;
link.download = 'leads.csv';
link.click();
} else {
console.error('CSV URL is not available');
}
}}
csv
>
CSV
</Button>
)}
<Button
name={selectedConnectorSourceLead}
onClick={handleIgnoreLeadButtonClick}
Expand Down Expand Up @@ -791,4 +821,8 @@ function LeadsPane(props: Props) {
);
}

export function getCsvUrlDerived() {
return csvUrlDerived;
}

export default LeadsPane;
6 changes: 4 additions & 2 deletions app/views/Tagging/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ function Tagging(props: Props) {
hideSingleSourceAddModal();
}, [hideSingleSourceAddModal]);

const isConnectorsAccessible = !!user
?.accessibleFeatures?.some((feature) => feature.key === 'CONNECTORS');
const isConnectorsAccessible = true;

// const isConnectorsAccessible = !!user
// ?.accessibleFeatures?.some((feature) => feature.key === 'CONNECTORS');

const newSourcesCount = data?.project?.unifiedConnector?.sourceCountWithoutIngnoredAndAdded;

Expand Down
60 changes: 60 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Changes Report

This report lists the files that have changed between the local HEAD and the remote branch `origin/develop`.

## Files Changed
| File Path | Change Type |
|-----------------|---------------|
| .idea/.gitignore | Deleted |
| .idea/client.iml | Deleted |
| .idea/inspectionProfiles/Project_Default.xml | Deleted |
| .idea/inspectionProfiles/profiles_settings.xml | Deleted |
| .idea/misc.xml | Deleted |
| .idea/modules.xml | Deleted |
| .idea/vcs.xml | Deleted |
| app/Base/components/Init/index.tsx | Modified |
| app/Base/components/Init/styles.css | Added |
| app/Base/configs/env.ts | Modified |
| app/Base/configs/routes.tsx | Modified |
| app/components/LeftPaneEntries/AssistItem/AssistPopup/index.tsx | Modified |
| app/components/LeftPaneEntries/AssistItem/index.tsx | Modified |
| app/components/LeftPaneEntries/AssistItem/utils.ts | Modified |
| app/components/LeftPaneEntries/AutoEntriesModal/index.tsx | Modified |
| app/components/LeftPaneEntries/SimplifiedTextView/index.tsx | Modified |
| app/components/LeftPaneEntries/TableAndVisualItem/index.tsx | Modified |
| app/components/LeftPaneEntries/TableAndVisualItem/styles.css | Added |
| app/components/LeftPaneEntries/index.tsx | Modified |
| app/components/LeftPaneEntries/styles.css | Modified |
| app/components/entry/CompactSection/index.tsx | Modified |
| app/components/entry/EntryInput/index.tsx | Modified |
| app/components/entry/types.ts | Modified |
| app/components/framework/CompactAttributeInput/Matrix2dWidgetInput/index.tsx | Modified |
| app/components/framework/CompactAttributeInput/Matrix2dWidgetInput/styles.css | Modified |
| app/components/framework/CompactAttributeInput/index.tsx | Modified |
| app/components/framework/CompactAttributeInput/utils.ts | Modified |
| app/components/selections/RegionSelectInput/index.tsx | Modified |
| app/gqlFragments.ts | Modified |
| app/types/index.tsx | Modified |
| app/types/newAnalyticalFramework.ts | Modified |
| app/types/project.tsx | Modified |
| app/views/ExploreDeepContent/ProjectContent/ActionCell/index.tsx | Modified |
| app/views/ExploreDeepContent/ProjectContent/ActionCell/styles.css | Modified |
| app/views/Home/ProjectItem/index.tsx | Modified |
| app/views/Home/ProjectItem/styles.css | Modified |
| app/views/Home/index.tsx | Modified |
| app/views/PillarAnalysis/index.tsx | Modified |
| app/views/ProjectEdit/Connector/EditConnectorModal/ConnectorSourceForm/KoboToolboxParamsInput/index.tsx | Deleted |
| app/views/ProjectEdit/Connector/EditConnectorModal/ConnectorSourceForm/index.tsx | Modified |
| app/views/ProjectEdit/Connector/EditConnectorModal/index.tsx | Modified |
| app/views/ProjectEdit/Connector/schema.ts | Modified |
| app/views/ProjectEdit/Connector/types.ts | Modified |
| app/views/ProjectEdit/Framework/FrameworkDetail/ExportModal/index.tsx | Added |
| app/views/ProjectEdit/Framework/FrameworkDetail/ExportModal/styles.css | Added |
| app/views/ProjectEdit/Framework/FrameworkDetail/index.tsx | Modified |
| app/views/ProjectEdit/index.tsx | Modified |
| app/views/ReportEdit/index.tsx | Modified |
| app/views/Tagging/UnifiedConnectorModal/LeadsPane/index.tsx | Modified |
| app/views/Tagging/UnifiedConnectorModal/index.tsx | Modified |
| app/views/Tagging/index.tsx | Modified |
| package.json | Modified |
| yarn.lock | Modified |
Loading