Skip to content

725 add checkbox for create communities #728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
17 changes: 14 additions & 3 deletions backend/src/shared/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,26 @@
CALL {{
WITH selectedChunks
UNWIND selectedChunks as c

OPTIONAL MATCH entities=(c:Chunk)-[:HAS_ENTITY]->(e)
OPTIONAL MATCH entityRels=(e)--(e2:!Chunk) WHERE exists {{
(e2)<-[:HAS_ENTITY]-(other) WHERE other IN selectedChunks
}}
RETURN collect(entities) as entities, collect(entityRels) as entityRels
RETURN entities , entityRels, collect(DISTINCT e) as entity
}}
WITH docs,chunks,chunkRels, collect(entities) as entities, collect(entityRels) as entityRels,entity

WITH *

CALL {{
with entity
unwind entity as n
OPTIONAL MATCH community=(n:__Entity__)-[:IN_COMMUNITY]->(p:__Community__)
OPTIONAL MATCH parentcommunity=(p)-[:PARENT_COMMUNITY]->(p2:__Community__)
return community,parentcommunity
}}

WITH apoc.coll.flatten(docs + chunks + chunkRels + entities + entityRels, true) as paths
WITH apoc.coll.flatten(docs + chunks + chunkRels + entities + entityRels + community+ parentcommunity, true) as paths

// distinct nodes and rels
CALL {{ WITH paths UNWIND paths AS path UNWIND nodes(path) as node WITH distinct node
Expand Down
54 changes: 27 additions & 27 deletions frontend/src/components/ChatBot/ChatModeToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CustomMenu from '../UI/Menu';
import { chatModes } from '../../utils/Constants';
import { capitalize } from '@mui/material';
import { capitalizeWithPlus } from '../../utils/Utils';

import { useCredentials } from '../../context/UserCredentials';
export default function ChatModeToggle({
menuAnchor,
closeHandler = () => {},
Expand All @@ -21,7 +21,8 @@ export default function ChatModeToggle({
}) {
const { setchatMode, chatMode, postProcessingTasks } = useFileContext();
const isCommunityAllowed = postProcessingTasks.includes('create_communities');

const { isGdsActive } = useCredentials();

return (
<CustomMenu
closeHandler={closeHandler}
Expand All @@ -30,7 +31,7 @@ export default function ChatModeToggle({
anchorPortal={anchorPortal}
disableBackdrop={disableBackdrop}
items={useMemo(() => {
if (isCommunityAllowed) {
if (isGdsActive && isCommunityAllowed) {
return chatModes?.map((m) => {
return {
title: m.includes('+') ? capitalizeWithPlus(m) : capitalize(m),
Expand All @@ -49,29 +50,28 @@ export default function ChatModeToggle({
),
};
});
}
return chatModes
?.filter((s) => !s.includes('community'))
?.map((m) => {
return {
title: m.includes('+') ? capitalizeWithPlus(m) : capitalize(m),
onClick: () => {
setchatMode(m);
},
disabledCondition: false,
description: (
<span>
{chatMode === m && (
<>
<StatusIndicator type={`${chatMode === m ? 'success' : 'unknown'}`} /> Selected
</>
)}
</span>
),
};
});

}, [chatMode, chatModes,isCommunityAllowed])}
></CustomMenu>
}
return chatModes
?.filter((s) => !s.includes('community'))
?.map((m) => {
return {
title: m.includes('+') ? capitalizeWithPlus(m) : capitalize(m),
onClick: () => {
setchatMode(m);
},
disabledCondition: false,
description: (
<span>
{chatMode === m && (
<>
<StatusIndicator type={`${chatMode === m ? 'success' : 'unknown'}`} /> Selected
</>
)}
</span>
),
};
});
}, [chatMode, chatModes, isCommunityAllowed, isGdsActive])}
/>
);
}
10 changes: 5 additions & 5 deletions frontend/src/components/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import DeletePopUp from './Popups/DeletePopUp/DeletePopUp';
import GraphEnhancementDialog from './Popups/GraphEnhancementDialog';
import { tokens } from '@neo4j-ndl/base';
import axios from 'axios';
import DatabaseStatusIcon from './UI/DatabaseIcon';
import DatabaseStatusIcon from './UI/DatabaseStatusIcon';

const ConnectionModal = lazy(() => import('./Popups/ConnectionModal/ConnectionModal'));
const ConfirmationDialog = lazy(() => import('./Popups/LargeFilePopUp/ConfirmationDialog'));
Expand All @@ -59,7 +59,7 @@ const Content: React.FC<ContentProps> = ({
const [openGraphView, setOpenGraphView] = useState<boolean>(false);
const [inspectedName, setInspectedName] = useState<string>('');
const [connectionStatus, setConnectionStatus] = useState<boolean>(false);
const { setUserCredentials, userCredentials, isGdsActive } = useCredentials();
const { setUserCredentials, userCredentials, isGdsActive, setGdsActive } = useCredentials();
const [showConfirmationModal, setshowConfirmationModal] = useState<boolean>(false);
const [extractLoading, setextractLoading] = useState<boolean>(false);

Expand Down Expand Up @@ -87,7 +87,6 @@ const Content: React.FC<ContentProps> = ({
alertType: 'error',
alertMessage: '',
});
const isGdsActive = true;
const { updateStatusForLargeFiles } = useServerSideEvent(
(inMinutes, time, fileName) => {
setalertDetails({
Expand Down Expand Up @@ -128,6 +127,9 @@ const Content: React.FC<ContentProps> = ({
database: neo4jConnection.database,
port: neo4jConnection.uri.split(':')[2],
});
if (neo4jConnection.isgdsActive !== undefined) {
setGdsActive(neo4jConnection.isgdsActive);
}
} else {
setOpenConnection((prev) => ({ ...prev, openPopUp: true }));
}
Expand Down Expand Up @@ -653,8 +655,6 @@ const Content: React.FC<ContentProps> = ({
}
};

console.log('isGds', isGdsActive);

return (
<>
{alertDetails.showAlert && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function ConnectionModal({
const [username, setUsername] = useState<string>(initialusername ?? 'neo4j');
const [password, setPassword] = useState<string>('');
const [connectionMessage, setMessage] = useState<Message | null>({ type: 'unknown', content: '' });
const { setUserCredentials, userCredentials } = useCredentials();
const { setUserCredentials, userCredentials, setGdsActive } = useCredentials();
const [isLoading, setIsLoading] = useState<boolean>(false);
const [searchParams, setSearchParams] = useSearchParams();
const [userDbVectorIndex, setUserDbVectorIndex] = useState<number | undefined>(initialuserdbvectorindex ?? undefined);
Expand Down Expand Up @@ -201,6 +201,8 @@ export default function ConnectionModal({
if (response?.data?.status !== 'Success') {
throw new Error(response.data.error);
} else {
const isgdsActive = response.data.data.gds_status;
setGdsActive(isgdsActive);
localStorage.setItem(
'neo4j.connection',
JSON.stringify({
Expand All @@ -209,6 +211,7 @@ export default function ConnectionModal({
password: password,
database: database,
userDbVectorIndex,
isgdsActive,
})
);
setUserDbVectorIndex(response.data.data.db_vector_dimension);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ export default function DeduplicationTab() {
const onRemove = (nodeid: string, similarNodeId: string) => {
setDuplicateNodes((prev) => {
return prev.map((d) =>
(d.e.elementId === nodeid
d.e.elementId === nodeid
? {
...d,
similar: d.similar.filter((n) => n.elementId != similarNodeId),
}
: d)
: d
);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ export default function PostProcessingCheckList() {
.join(' ')}
</Typography>
}
checked={postProcessingTasks.includes(job.title)}
checked={
isCreateCommunities
? isGdsActive && postProcessingTasks.includes(job.title)
: postProcessingTasks.includes(job.title)
}
onChange={(e) => {
if (e.target.checked) {
setPostProcessingTasks((prev) => [...prev, job.title]);
} else {
setPostProcessingTasks((prev) => prev.filter((s) => s !== job.title));
}
}}
disabled={isCreateCommunities && !isGdsActive} // Disable if GDS is not active
disabled={isCreateCommunities && !isGdsActive}
/>
<Typography variant={tablet ? 'body-small' : 'body-medium'}>{job.description}</Typography>
</Flex>
Expand Down
26 changes: 26 additions & 0 deletions frontend/src/components/UI/DatabaseStatusIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { CircleStackIconOutline } from '@neo4j-ndl/react/icons';
import { IconWithToolTip } from './IconButtonToolTip';
import { DatabaseStatusProps } from '../../types';
import { connectionLabels } from '../../utils/Constants';
import ScienceMoleculeIcon from '../UI/ScienceMolecule';

const DatabaseStatusIcon: React.FC<DatabaseStatusProps> = ({ isConnected, isGdsActive, uri }) => {
const strokeColour = isConnected ? connectionLabels.greenStroke : connectionLabels.redStroke;
const text = isGdsActive ? connectionLabels.graphDataScience : connectionLabels.graphDatabase;
return (
<div style={{ display: 'flex', alignItems: 'center' }}>
<IconWithToolTip label={text} text={text} placement='top'>
<span>
{isGdsActive ? (
<ScienceMoleculeIcon currentColour={strokeColour} />
) : (
<CircleStackIconOutline className='n-size-token-6' style={{ stroke: strokeColour }} />
)}
</span>
</IconWithToolTip>
<span className='n-body-small ml-1'>{isConnected ? uri : connectionLabels.notConnected}</span>
</div>
);
};

export default DatabaseStatusIcon;
40 changes: 40 additions & 0 deletions frontend/src/components/UI/ScienceMolecule.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';

interface ScienceMoleculeIconProps {
currentColour: string;
}

const ScienceMoleculeIcon: React.FC<ScienceMoleculeIconProps> = ({ currentColour }) => (
<svg
width='1em'
height='1em'
viewBox='0 0 24 24'
fill='none'
xmlns='http://www.w3.org/2000/svg'
className='n-size-token-6'
>
<path
d='M12.0068 13.6942C12.9387 13.6942 13.6943 12.9387 13.6943 12.0067C13.6943 11.0748 12.9387 10.3192 12.0068 10.3192C11.0748 10.3192 10.3193 11.0748 10.3193 12.0067C10.3193 12.9387 11.0748 13.6942 12.0068 13.6942Z'
stroke={currentColour}
strokeWidth='1.5'
strokeLinecap='round'
strokeLinejoin='round'
/>
<path
d='M14.7912 14.791C19.1846 10.3976 21.4996 5.58948 19.9619 4.05179C18.4242 2.5141 13.6161 4.82911 9.22275 9.22251C4.82935 13.6159 2.51434 18.424 4.05203 19.9617C5.58972 21.4994 10.3978 19.1844 14.7912 14.791Z'
stroke={currentColour}
strokeWidth='1.5'
strokeLinecap='round'
strokeLinejoin='round'
/>
<path
d='M19.9619 19.9617C21.4996 18.424 19.1846 13.6159 14.7912 9.22251C10.3978 4.82911 5.58972 2.5141 4.05203 4.05179C2.51434 5.58948 4.82935 10.3976 9.22275 14.791C13.6162 19.1844 18.4242 21.4994 19.9619 19.9617Z'
stroke={currentColour}
strokeWidth='1.5'
strokeLinecap='round'
strokeLinejoin='round'
/>
</svg>
);

export default ScienceMoleculeIcon;
6 changes: 3 additions & 3 deletions frontend/src/context/UserCredentials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ type Props = {
export const UserConnection = createContext<ContextProps>({
userCredentials: null,
setUserCredentials: () => null,
isGdsActive: null,
setGdsActive: () => null,
isGdsActive: false,
setGdsActive: () => false,
});
export const useCredentials = () => {
const userCredentials = useContext(UserConnection);
return userCredentials;
};
const UserCredentialsWrapper: FunctionComponent<Props> = (props) => {
const [userCredentials, setUserCredentials] = useState<UserCredentials | null>(null);
const [isGdsActive, setGdsActive] = useReducer((s) => !s, false);
const [isGdsActive, setGdsActive] = useState<boolean>(false);
const value = {
userCredentials,
setUserCredentials,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ export interface DrawerChatbotProps {
export interface ContextProps {
userCredentials: UserCredentials | null;
setUserCredentials: (UserCredentials: UserCredentials) => void;
isGdsActive: boolean | null;
setGdsActive: () => void;
isGdsActive: boolean;
setGdsActive: Dispatch<SetStateAction<boolean>>;
}
export interface MessageContextType {
messages: Messages[] | [];
Expand Down