Skip to content
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

fix: relation name persisting on screen while hovering graph edges #1066 #1124

Merged
merged 5 commits into from
Oct 25, 2023
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
21 changes: 18 additions & 3 deletions dashboard/components/explorer/DependencyGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react-hooks/exhaustive-deps */
import React, { useState, memo, useEffect } from 'react';
import CytoscapeComponent from 'react-cytoscapejs';
import Cytoscape, { EventObject } from 'cytoscape';
import Cytoscape, { EdgeSingular, EventObject } from 'cytoscape';
import popper from 'cytoscape-popper';

import nodeHtmlLabel, {
Expand Down Expand Up @@ -91,6 +91,7 @@ const DependencyGraph = ({ data }: DependencyGraphProps) => {
const content = document.createElement('div');
content.classList.add('popper-div');
content.innerHTML = event.target.data('label');
content.style.pointerEvents = 'none';

document.body.appendChild(content);
return content;
Expand All @@ -108,6 +109,20 @@ const DependencyGraph = ({ data }: DependencyGraphProps) => {

// Hide labels when being zoomed out
cy.on('zoom', event => {
if (cy.zoom() <= zoomLevelBreakpoint) {
interface ExtendedEdgeSingular extends EdgeSingular {
popperRefObj?: any;
}

// Check if a tooltip is present and remove it
cy.edges().forEach((edge: ExtendedEdgeSingular) => {
if (edge.popperRefObj) {
edge.popperRefObj.state.elements.popper.remove();
edge.popperRefObj.destroy();
}
});
}

const opacity = cy.zoom() <= zoomLevelBreakpoint ? 0 : 1;

Array.from(
Expand All @@ -126,7 +141,7 @@ const DependencyGraph = ({ data }: DependencyGraphProps) => {

return (
<div className="relative h-full flex-1 bg-dependency-graph bg-[length:40px_40px]">
<CytoscapeComponent
{/* <CytoscapeComponent
className="h-full w-full"
elements={CytoscapeComponent.normalizeElements({
nodes: data.nodes,
Expand All @@ -150,7 +165,7 @@ const DependencyGraph = ({ data }: DependencyGraphProps) => {
}
]}
cy={(cy: Cytoscape.Core) => cyActionHandlers(cy)}
/>
/> */}
{dataIsEmpty ? (
<>
<div className="translate-y-[201px]">
Expand Down
3 changes: 2 additions & 1 deletion dashboard/components/feedback-widget/FeedbackWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Input from '@components/input/Input';
import settingsService from '@services/settingsService';
import Button from '@components/button/Button';
import { useToast } from '@components/toast/ToastProvider';
import Toast from '@components/toast/Toast';
import Upload from '@components/upload/Upload';

// We define the placeholder here for convenience
Expand Down Expand Up @@ -51,7 +52,7 @@ const useFeedbackWidget = (defaultState: boolean = false) => {
const [isTakingScreenCapture, setIsTakingScreenCapture] = useState(false);
const [fileAttachement, setFileAttachement] = useState<File | null>(null);
const [isSendingFeedback, setIsSendingFeedback] = useState(false);
const { showToast } = useToast();
const { toast, showToast, dismissToast } = useToast();

async function takeScreenshot() {
if (
Expand Down
19 changes: 15 additions & 4 deletions dashboard/components/upload/Upload.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,35 @@ function UploadWrapper({
onClose,
...otherProps
}: UploadProps) {
const [selectedFile, setSelectedFile] = useState<File | File[] | null>(null);
const [selectedFile, setSelectedFile] = useState<File | null>(null);
const [selectedFiles, setSelectedFiles] = useState<File[] | null>(null);

useEffect(() => {
setSelectedFile(null);
setSelectedFiles(null);
}, [multiple]);

const uploadFile = (file: File | File[] | null): void => {
if (file instanceof FileList) {
const filesArray = Array.from(file);
setSelectedFile(filesArray);
setSelectedFiles(filesArray);
} else if (file instanceof File) {
setSelectedFile(file);
} else {
setSelectedFile(null);
setSelectedFiles(null);
}
};

return (
return multiple ? (
<Upload
multiple={multiple}
fileOrFiles={selectedFiles}
handleChange={uploadFile}
onClose={() => setSelectedFiles(null)}
{...otherProps}
/>
) : (
<Upload
multiple={multiple}
fileOrFiles={selectedFile}
Expand All @@ -39,7 +50,7 @@ function UploadWrapper({
}

const meta: Meta<typeof Upload> = {
title: 'Komiser/FileUpload',
title: 'Komiser/Upload',
component: UploadWrapper,
decorators: [
Story => (
Expand Down