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: Browser Back button not functioning after redirecting to the Analytics page from the Project details page gf-540 #542

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
10 changes: 8 additions & 2 deletions apps/frontend/src/libs/components/chart/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import styles from "./styles.module.css";

type Properties = {
data: ChartData;
isCursorPointer: boolean;
};

const Chart = ({ data }: Properties): JSX.Element => {
const Chart = ({ data, isCursorPointer }: Properties): JSX.Element => {
return (
<LineChart data={data} height={40} width={120}>
<LineChart
data={data}
height={40}
style={{ cursor: isCursorPointer ? "pointer" : "default" }}
width={120}
>
<Line className={styles["line"] as string} dataKey="y" dot={false} />
</LineChart>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ const useSearchFilters = ({
: "";
const [search, setSearch] = useState<string>(searchParameter);

const [isInitialLoad, setIsInitialLoad] = useState<boolean>(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this works as expected? I was thinking maybe the problem in place where we call navigate? like there different methods for navigation, push, replace etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works only for the redirection from click on contributor item to analytics page. But for example when user is on contributors page and then clicks on sidebar to get to access management page and tries to click back it doesn't go back. It appears to be related to query parameters. I'm unsure if this qualifies as a bug, as the QA team only mentioned that specific redirection in the ticket, so they may consider the current behavior acceptable for these pages.


useEffect(() => {
if (isInitialLoad) {
setIsInitialLoad(false);

return;
}

if (isSavedToUrl) {
const updatedSearchParameters = new URLSearchParams(searchParameters);
updatedSearchParameters.set(queryParameterName, search);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const ContributorCard = ({
}: Properties): JSX.Element => {
const analyticsRoute = configureQueryString(AppRoute.ANALYTICS, [
[QueryParameterName.PROJECT_ID, projectId],
[QueryParameterName.SEARCH, contributor.name],
]);

const currentDate = getStartOfDay(new Date());
Expand Down Expand Up @@ -94,7 +95,11 @@ const ContributorCard = ({
{hasActivityIndicator && (
<ActivityIndicator label={lastUpdateLabel} status={colorStatus} />
)}
{hasActivityData && <Chart data={activityData} />}
{hasActivityData && (
<NavLink to={analyticsRoute}>
<Chart data={activityData} isCursorPointer />
</NavLink>
)}
<ContributorMenu
contributorId={contributor.id}
hasEditPermission={hasEditPermission}
Expand Down