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: add an ability to mark contributors as hidden gf-346 #400

Merged
merged 36 commits into from
Sep 25, 2024

Conversation

kolibri753
Copy link
Collaborator

@kolibri753 kolibri753 commented Sep 19, 2024

Changes:

  • added new icons: check, circle-question;
  • added is_hidden column to contributors table by migration;
  • added isHidden to types, model, entity, repository;
  • adjusted contributors table;
  • excluded hidden contributors from project contributors page;
  • excluded hidden contributors from analytics page.

Screenshots:

image

image

image

image

id="isHidden"
name="isHidden"
/>
<span>Is hidden</span>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that you didn't choose this name, but am I the only one who thinks "Is Hidden" sounds more like developer language than something suited for a user interface?
"Do Not Track", or perhaps just "Hidden"

Copy link
Collaborator

Choose a reason for hiding this comment

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

good suggestion, I like do not track option (on the backend side let's keep it as it is now)

@kolibri753 kolibri753 marked this pull request as ready for review September 20, 2024 16:53
Comment on lines 185 to 187
contributorId: contributorId ?? "",
contributorIsHidden: contributor ? contributor.isHidden : false,
contributorName: contributorName ?? "",
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we can return contributor as an object and id, isHidden, and name as properties, or is there an issue? cc @sandrvvu

Comment on lines 71 to 73
const visibleActivityLogs = activityLogs.filter(
(log) => !log.contributorIsHidden,
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be filtered inside backend query

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it mandatory to modify query like this builder.select("id", "name").where("isHidden", false); or can it be just check in service if (!contributor.isHidden), not sure it is needed to add isHidden to contributor on GitEmailModel.

(I'll push it with just a check for a better look)

Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't need isHidden in GitEmailModel for now, it's better to use query builder

id="isHidden"
name="isHidden"
/>
<span>Is hidden</span>
Copy link
Collaborator

Choose a reason for hiding this comment

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

good suggestion, I like do not track option (on the backend side let's keep it as it is now)


const IsHiddenHeader = (): JSX.Element => (
<div className={styles["header-with-icon"]}>
Is Hidden <Icon height={15} name="circleQuestion" width={15} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the design, this icon is meant to be with a tooltip, but if we rename the column on UI to Do Not Track, then I think we can remove this icon at all, especially taking into consideration that it's described inside edit modal

@@ -166,6 +166,10 @@ const Project = (): JSX.Element => {
userPermissions,
);

const visibleProjectContributors = projectContributors.filter(
Copy link
Collaborator

Choose a reason for hiding this comment

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

same, should be returned this way from the backend

Copy link
Contributor

@what1s1ove what1s1ove left a comment

Choose a reason for hiding this comment

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

lgtm after Lisa's changes

return {
commitsNumber: commitsArray,
contributorId: contributorId ?? "",
contributorIsHidden: contributor ? contributor.isHidden : false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
contributorIsHidden: contributor ? contributor.isHidden : false,
contributorIsHidden: contributor?.isHidden ?? false,

@@ -1,5 +1,6 @@
type ActivityLogQueryParameters = {
endDate: string;
hasHidden?: boolean;
Copy link
Collaborator

@liza-veis liza-veis Sep 24, 2024

Choose a reason for hiding this comment

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

I meant to only pass this parameter as false on activity log service level, similarly, we did for hasDeleted parameter, where we needed to find with deleted users in one place and without them in another place. And don't we need to pass this parameter to findAllByProjectId?

const TABLE_NAME = "contributors";

const ColumnName = {
IS_HIDDEN: "is_hidden",
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's rename this column to hidden_at and record datetime

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so I'm changing it everywhere, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes

Comment on lines 60 to 61
void handleSubmit((formData: { isHidden: boolean; name: string }) => {
const hiddenAtValue = isHiddenValue ? new Date().toISOString() : null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why don't you use isHidden instead of isHiddenValue and useFormWatch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

isHidden (formData.isHidden) resulted in undefined, will investigate it more

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we need to pass a default value? there is no need for setValue here, usual checkbox should be handled as inputs using useForm default flow

.modifyGraph("gitEmail.contributor", (builder) => {
builder.select("id", "name");
builder.select("id", "name", "HiddenAt");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
builder.select("id", "name", "HiddenAt");
builder.select("id", "name", "hiddenAt");

Comment on lines 113 to 115
public async findAllWithoutPagination(
hasHidden?: boolean,
): Promise<ContributorGetAllResponseDto> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's may be not clear what boolean parameter is used for outside of this service

Suggested change
public async findAllWithoutPagination(
hasHidden?: boolean,
): Promise<ContributorGetAllResponseDto> {
public async findAllWithoutPagination({
hasHidden,
}: { hasHidden?: boolean }): Promise<ContributorGetAllResponseDto> {

For example, you call this.contributorService.findAllWithoutPagination(false)); -- when we look at this call it is hard to guess what false may be used for.

Same for findAllByProjectId

const handleFormSubmit = useCallback(
(event_: React.BaseSyntheticEvent): void => {
void handleSubmit((formData: { name: string }) => {
const payload: ContributorPatchRequestDto = { name: formData.name };
void handleSubmit((formData: { isHidden: boolean; name: string }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why don't we just destucture it

Suggested change
void handleSubmit((formData: { isHidden: boolean; name: string }) => {
void handleSubmit(({ isHidden: boolean; name: string }) => {

BTW, no matter you annotate formData with { isHidden: boolean; name: string } type, it still contains gitEmails, name and projects

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep, but if I'm not mistaken void handleSubmit(({ isHidden, name }) => {

Copy link
Collaborator

Choose a reason for hiding this comment

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

agree with this option, void handleSubmit(({ isHidden, name }) => {, from the code it looks like formData should already have an appropriate type, so we don't need to define it again

cell: ({ row: { original: contributor } }) =>
contributor.hiddenAt ? (
<Icon height={18} name="check" width={18} />
) : null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

To render nothing we are using this approach

Suggested change
) : null,
) : <></>,

@@ -8,6 +8,7 @@ import { type ContributorPatchRequestDto } from "../types/types.js";

const contributorPatch: z.ZodType<ContributorPatchRequestDto> = z
.object({
hiddenAt: z.union([z.string().nullable(), z.null()]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we do it like this?

Suggested change
hiddenAt: z.union([z.string().nullable(), z.null()]),
hiddenAt: z.string().nullable(),

Copy link
Collaborator

Choose a reason for hiding this comment

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

or at least

Suggested change
hiddenAt: z.union([z.string().nullable(), z.null()]),
hiddenAt: z.union([z.string(), z.null()]),

@GvoFor
Copy link
Collaborator

GvoFor commented Sep 24, 2024

Don't forget to update readme.md

@@ -86,9 +93,10 @@ class ContributorRepository implements Repository {
}

public async findAllByProjectId(
hasHidden: 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.

let's pass it as a second parameter, it would be more logical to me

Comment on lines 60 to 61
void handleSubmit((formData: { isHidden: boolean; name: string }) => {
const hiddenAtValue = isHiddenValue ? new Date().toISOString() : null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we need to pass a default value? there is no need for setValue here, usual checkbox should be handled as inputs using useForm default flow

@@ -1,4 +1,5 @@
type ContributorPatchRequestDto = {
hiddenAt: null | string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

for request it's better to pass isHidden, and set the timestamp on the backend side

Suggested change
hiddenAt: null | string;
isHidden: boolean;

@@ -1,5 +1,6 @@
type ContributorPatchResponseDto = {
id: number;
isHidden?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't we return hiddenAt in response?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, sorry, 🤦

@liza-veis liza-veis merged commit 6143e4c into main Sep 25, 2024
6 checks passed
This was referenced Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

7 participants