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

feat: Revamp navigation bar #6031

Merged
merged 27 commits into from
Jul 16, 2024

Conversation

AdityaPimpalkar
Copy link
Contributor

@AdityaPimpalkar AdityaPimpalkar commented Jun 26, 2024

closes: #4428

Testing for fetchMoreRecords is pending, along with component tests

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

  • Introduced useRecordShowPagePagination hook for record show page pagination
  • Added viewBarId prop to RecordTable and RecordTableWithWrappers
  • Updated RecordTableContextProps to include viewBarId
  • Enhanced PageHeader with pagination buttons and updated styles
  • Modified useChipFieldDisplay to append view ID to linkToShowPage

7 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings

Comment on lines 141 to 149
const navigateToPreviousRecord = () => {
const prevRecord = objectRecords[currentRecordPosition - 1];
navigate(
`/object/${objectNameSingular}/${prevRecord.id}${
viewIdQueryParam ? `?view=${viewIdQueryParam}` : ''
}`,
);
setCurrentRecordPosition(currentRecordPosition - 1);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🧠 logic: Ensure currentRecordPosition - 1 is within bounds before accessing objectRecords.

Comment on lines 151 to 159
const navigateToNextRecord = () => {
const nextRecord = objectRecords[currentRecordPosition + 1];
navigate(
`/object/${objectNameSingular}/${nextRecord.id}${
viewIdQueryParam ? `?view=${viewIdQueryParam}` : ''
}`,
);
setCurrentRecordPosition(currentRecordPosition + 1);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🧠 logic: Ensure currentRecordPosition + 1 is within bounds before accessing objectRecords.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Enhanced pagination logic in useRecordShowPagePagination.ts
  • Added viewBarId property to context in RecordTableCell.perf.stories.tsx
  • Replaced back button with close button in PageHeader.tsx
  • Introduced pagination and close button in RecordShowPage.tsx

4 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Reordered imports in useRecordShowPagePagination.ts
  • Reformatted code for better readability
  • Ensured correct invocation of fetchMoreRecords
  • Adjusted logic for fetching more records for clarity

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Updated mock data for peopleMock
  • Added new GraphQL query handler for FindManyPeople
  • Improved accuracy of Storybook tests for RecordShowPage component

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Simplified useEffect dependency array in useRecordShowPagePagination.ts
  • Potential impact on pagination state management and updates

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@FelixMalfait
Copy link
Member

Pass view id to showpage on Kanban

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Added setRecordPosition function to ChipFieldDisplay.tsx for handling record positioning
  • Introduced setRecordPosition in useChipFieldDisplay.ts using Recoil for state management
  • Added recordPositionInternalState.ts to define state for tracking record positions
  • Updated useRecordShowPagePagination.ts to use Recoil for record position state management
  • Enhanced EntityChip.tsx with an optional onClick prop for custom click handlers

5 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

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

I made a lot of small comments but overall it is great! Thanks!!!

Copy link

github-actions bot commented Jul 15, 2024

Fails
🚫

node failed.

Log

�[31mError: �[39m RequestError [HttpError]: You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID 6CC7:13ED99:67554AF:BF90216:669669F4.
    at /home/runner/work/twenty/twenty/node_modules/�[4m@octokit�[24m/request/dist-node/index.js:86:21
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)�[39m {
  status: �[33m403�[39m,
  response: {
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3AAdityaPimpalkar%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    status: �[33m403�[39m,
    headers: {
      �[32m'access-control-allow-origin'�[39m: �[32m'*'�[39m,
      �[32m'access-control-expose-headers'�[39m: �[32m'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'�[39m,
      connection: �[32m'close'�[39m,
      �[32m'content-encoding'�[39m: �[32m'gzip'�[39m,
      �[32m'content-security-policy'�[39m: �[32m"default-src 'none'"�[39m,
      �[32m'content-type'�[39m: �[32m'application/json; charset=utf-8'�[39m,
      date: �[32m'Tue, 16 Jul 2024 12:39:16 GMT'�[39m,
      �[32m'referrer-policy'�[39m: �[32m'origin-when-cross-origin, strict-origin-when-cross-origin'�[39m,
      server: �[32m'github.com'�[39m,
      �[32m'strict-transport-security'�[39m: �[32m'max-age=31536000; includeSubdomains; preload'�[39m,
      �[32m'transfer-encoding'�[39m: �[32m'chunked'�[39m,
      vary: �[32m'Accept-Encoding, Accept, X-Requested-With'�[39m,
      �[32m'x-content-type-options'�[39m: �[32m'nosniff'�[39m,
      �[32m'x-frame-options'�[39m: �[32m'deny'�[39m,
      �[32m'x-github-api-version-selected'�[39m: �[32m'2022-11-28'�[39m,
      �[32m'x-github-media-type'�[39m: �[32m'github.v3; format=json'�[39m,
      �[32m'x-github-request-id'�[39m: �[32m'6CC7:13ED99:67554AF:BF90216:669669F4'�[39m,
      �[32m'x-ratelimit-limit'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-remaining'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-reset'�[39m: �[32m'1721133616'�[39m,
      �[32m'x-ratelimit-resource'�[39m: �[32m'search'�[39m,
      �[32m'x-ratelimit-used'�[39m: �[32m'1'�[39m,
      �[32m'x-xss-protection'�[39m: �[32m'0'�[39m
    },
    data: {
      documentation_url: �[32m'https://docs.github.com/free-pro-team@latest/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits'�[39m,
      message: �[32m'You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID 6CC7:13ED99:67554AF:BF90216:669669F4.'�[39m
    }
  },
  request: {
    method: �[32m'GET'�[39m,
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3AAdityaPimpalkar%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    headers: {
      accept: �[32m'application/vnd.github.v3+json'�[39m,
      �[32m'user-agent'�[39m: �[32m'octokit-rest.js/18.12.0 octokit-core.js/3.6.0 Node.js/18.20.4 (linux; x64)'�[39m,
      authorization: �[32m'token [REDACTED]'�[39m
    },
    request: { hook: �[36m[Function: bound bound register]�[39m }
  }
}
danger-results://tmp/danger-results-bd6f7ad9.json

Generated by 🚫 dangerJS against b03dbf2

@@ -37,7 +37,7 @@ export const useFetchAllRecordIds = <T>({
const firstQueryResult =
findManyRecordsDataResult?.data?.[objectMetadataItem.namePlural];

const totalCount = firstQueryResult?.totalCount ?? 1;
const totalCount = firstQueryResult?.totalCount ?? 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

)
.getValue();

// TODO: use URL builder
Copy link
Member

Choose a reason for hiding this comment

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

@@ -0,0 +1,30 @@
import { RecordGqlRefEdge } from '@/object-record/cache/types/RecordGqlRefEdge';
Copy link
Member

Choose a reason for hiding this comment

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

Strange file name?

(record) => record.id === lastShowPageRecordId,
);

const positionInPx = recordPosition * 32;
Copy link
Member

Choose a reason for hiding this comment

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

use row height?

@@ -0,0 +1,4 @@
import { isNull, isUndefined } from '@sniptt/guards';

export const isDefined = <T>(value: T | null | undefined): value is T =>
Copy link
Member

Choose a reason for hiding this comment

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

should we have it in both places? maybe just in twenty-ui then?

@@ -0,0 +1,20 @@
import { overlayScrollbarsState } from '@/ui/utilities/scroll/states/overlayScrollbarsState';
Copy link
Member

Choose a reason for hiding this comment

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

this looks very similar to useScrollRestoration? could we merge both?

@@ -169,7 +169,9 @@ export const CalendarEventRow = ({
? `${participant.firstName} ${participant.lastName}`
: participant.displayName
}
entityId={participant.workspaceMemberId ?? participant.personId}
placeholderColorSeed={
Copy link
Member

Choose a reason for hiding this comment

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

+1

@@ -17,7 +17,7 @@ export const getLabelIdentifierFieldValue = (
}

if (isDefined(labelIdentifierFieldMetadataItem?.name)) {
return record[labelIdentifierFieldMetadataItem.name] as string | number;
return String(record[labelIdentifierFieldMetadataItem.name]);
Copy link
Member

Choose a reason for hiding this comment

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

why is this needed?

avatarUrl={recordChipData.avatarUrl ?? ''}
linkToEntity={recordChipData.linkToShowPage}
return isLabelIdentifier ? (
<RecordIndexRecordChip
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about this naming RecordIndexRecordChip. should be RecordIdentifierChip?

import { isFieldNumber } from '@/object-record/record-field/types/guards/isFieldNumber';
import { isFieldText } from '@/object-record/record-field/types/guards/isFieldText';

export const isFieldChipDisplay = (
Copy link
Member

Choose a reason for hiding this comment

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

I would rename this to isFieldIdentifierDisplay

import { useApolloClient } from '@apollo/client';
import { createApolloStoreFieldName } from '~/utils/createApolloStoreFieldName';

export const useRecordIdsFromFindManyCacheRootQuery = ({
Copy link
Member

Choose a reason for hiding this comment

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

regarding the comment above, here it would be find if fieldVariables was also containing the cursor

}) => {
if (!viewId) {
return views.find(
(view: any) =>
Copy link
Member

Choose a reason for hiding this comment

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

any could be typed here

`/object/${objectNameSingular}/${recordBefore.id}${
viewIdQueryParam ? `?view=${viewIdQueryParam}` : ''
}`,
{
Copy link
Member

Choose a reason for hiding this comment

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

do we use it?

}
};

export const useRecordShowPagePagination = (
Copy link
Member

Choose a reason for hiding this comment

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

I feel this could be in a separate module "navigate-in-view" or something like this and could be re-used in other places later

@@ -33,7 +33,7 @@ export const RecordTableInternalEffect = ({
callback: () => {
leaveTableFocus();
},
mode: ClickOutsideMode.comparePixels,
mode: ClickOutsideMode.compareHTMLRef,
Copy link
Member

Choose a reason for hiding this comment

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

why this change? don't we have an issue with portals? (filter dropdown, field input) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I changed it in a recent PR but this introduced the bug of double click to open

@ijreilly ijreilly enabled auto-merge (squash) July 16, 2024 12:37
@ijreilly ijreilly merged commit 4a67cfa into twentyhq:main Jul 16, 2024
6 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revamp Navigation Bar in Shows for Enhanced Usability
5 participants