Skip to content

Conversation

@ppratikcr7
Copy link
Contributor

@ppratikcr7 ppratikcr7 commented Mar 29, 2025

This PR resolves #2245

I have added all the necessary code for add, edit and duplicate segment modal. Currently this PR needs the segmenr table list component for a listener to close the modal after add/edit/duplicate segment. Also, tags and listType are not getting stored in the backend as of now, that also needs to be handled in a separate PR. We will need to test this PR once all these missing parts are in the dev branch. Rest all seems to work fine as expected.

EDIT DAN:

  1. This has separate actions and effects from the 'legacy' segments logic so it can be changed later if we want to update the endpoint (like to add tags), but is currently able to work fine using the old endpoint in basically the same way.
  2. This adds Duplicate segment ability, but I left it disabled because I'm not sure it's what we want, I wanted to talk about that to figure out what the expected behavior of that is supposed to be.

@ppratikcr7 ppratikcr7 self-assigned this Mar 29, 2025
@ppratikcr7 ppratikcr7 requested a review from bcb37 March 29, 2025 18:15
@danoswaltCL danoswaltCL marked this pull request as ready for review April 1, 2025 21:52
@danoswaltCL danoswaltCL changed the title [WIP] add-edit-duplicate segment modal functionality add-edit-duplicate segment modal functionality Apr 1, 2025
@ppratikcr7 ppratikcr7 removed the request for review from danoswaltCL April 2, 2025 06:21
@zackcl
Copy link
Collaborator

zackcl commented Apr 2, 2025

I'm able to create two segments with the same name under the same app context. I think we should not allow this.

Screenshot 2025-04-02 at 10 09 00 PM

@zackcl
Copy link
Collaborator

zackcl commented Apr 2, 2025

I don't see the "Duplicate Segment" option from the menu currently.

Screenshot 2025-04-02 at 10 12 52 PM

Here's the design in Figma for reference:

Duplicate Segment

@danoswaltCL
Copy link
Collaborator

@zackcl yes, i disabled it on purpose because I think we need to talk about what the expected behavior is, I edited my comment above to be more clear

@danoswaltCL
Copy link
Collaborator

I'm able to create two segments with the same name under the same app context. I think we should not allow this.

Screenshot 2025-04-02 at 10 09 00 PM

Ok, I see the old modal disallows this to prevent the issue, I can do that but the backend should really not allow it to happen either.

@danoswaltCL danoswaltCL marked this pull request as draft April 4, 2025 00:36
@danoswaltCL
Copy link
Collaborator

@zackcl I added in a backend change to do a duplicate name check on submit and error if yes. Also shows error in the form that makes the form invalid until changed. The error will persist and keep getting checked while the name or context changes, removing the error if changed, putting it back if the name and context again match.

I put this in WIP still, I haven't added in the duplicate modal changes requested.

@danoswaltCL danoswaltCL marked this pull request as ready for review April 4, 2025 19:44
@danoswaltCL danoswaltCL requested a review from kawcl April 4, 2025 19:44
@danoswaltCL
Copy link
Collaborator

Ok, this now adds full duplicate modal functionality also, which does include just copying the lists directly from the source segment, it works just like add since it's upsert, so as far as I can tell this is creating faithful duplications, with the understanding that currently this must keep same context as target.

@bcb37 @zackcl

@zackcl
Copy link
Collaborator

zackcl commented Apr 7, 2025

@danoswaltCL Shouldn't we disable the "App Context" dropdown on the"Duplicate Segment" modal? I thought that was our decision. Currently, I'm able to change the "App Context" on your branch.

message: `Segment name ${name} already exists in context ${context}`,
});

// const error = new ErrorWithType();
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can probably remove these comments

Copy link
Collaborator

@bcb37 bcb37 left a comment

Choose a reason for hiding this comment

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

One small thing

@danoswaltCL
Copy link
Collaborator

@danoswaltCL Shouldn't we disable the "App Context" dropdown on the"Duplicate Segment" modal? I thought that was our decision. Currently, I'm able to change the "App Context" on your branch.

oops, yes

@danoswaltCL
Copy link
Collaborator

@zackcl @bcb37 updated but #2349 should go first, then I can use the changes there to update this to close the modal without using interceptor.

@danoswaltCL danoswaltCL requested a review from bcb37 April 8, 2025 11:40

public upsertSegment(segment: SegmentInputValidator, logger: UpgradeLogger): Promise<Segment> {
public async upsertSegment(segment: SegmentInputValidator, logger: UpgradeLogger): Promise<Segment> {
await this.checkIsDuplicateSegmentName(segment.name, segment.context, logger);
Copy link
Collaborator

@bcb37 bcb37 Apr 8, 2025

Choose a reason for hiding this comment

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

This method is also used when editing - so now editing always fails unless you're changing the name.
Maybe only perform the check if there isn't an id on 'segment'.

bcb37
bcb37 previously requested changes Apr 8, 2025
Copy link
Collaborator

@bcb37 bcb37 left a comment

Choose a reason for hiding this comment

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

I found one more thing.

Also, when you edit a new-style segment, it deletes all the lists (see code comment below)

context: appContext,
userIds: [],
groups: [],
subSegmentIds: [],
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need subSegmentIds from the segment here (same as with duplicate)

@danoswaltCL danoswaltCL dismissed bcb37’s stale review April 8, 2025 21:32

made the change

@danoswaltCL
Copy link
Collaborator

@bcb37 updated, ready for re-re-review

@bcb37
Copy link
Collaborator

bcb37 commented Apr 8, 2025

@bcb37 updated, ready for re-re-review

This works now. Duplicating still adds the same lists, rather than cloning them - but I just put up a pr (#2350) to fix that.

@danoswaltCL danoswaltCL merged commit f1ba973 into dev Apr 8, 2025
14 of 15 checks passed
@danoswaltCL danoswaltCL deleted the feature/add-segment-modal branch April 8, 2025 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Segment Modal

5 participants