-
Notifications
You must be signed in to change notification settings - Fork 0
Add admin block/unblock listing controls to view listing page #317
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
Open
Copilot
wants to merge
85
commits into
main
Choose a base branch
from
copilot/add-block-unblock-listing-buttons-again
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
85 commits
Select commit
Hold shift + click to select a range
0c47ac3
Initial plan
Copilot da4abab
Add backend block listing mutation and tests
Copilot b2d6bfd
Add frontend block/unblock listing UI with modals and mutations
Copilot f181fbd
Add access control for blocked listings and modal stories
Copilot d7c4c6a
Fix lint errors in modal components
Copilot a851a46
Address code review feedback - simplify modal and remove unused param…
Copilot e2a86e2
Fix sonar issues
e720f96
Update twilio
0d83de8
Update pnpm-lock.yaml
964647c
Update test cases
e7c0675
Update jws and jsonwebtoken
5e55f08
Update node.json
6d7fba8
Fixed import problem
e043285
Merge branch 'main' of https://github.com/simnova/sharethrift into co…
0c9a8a9
Update twilio
dd6f86e
Update import
bfc4680
Update import route
eda9272
Added test cases of ViewListingContainer
e973d56
Merge branch 'main' into copilot/add-block-unblock-listing-buttons-again
rohit-r-kumar 02665e3
Potential fix for pull request finding 'Unused variable, import, func…
rohit-r-kumar d467702
Update test cases for coverage
9763e66
Update test coverage
0032423
Update test cases
099a02b
Update test cases for coverge
18e62b1
Update story book
1e4d765
Update requested changes
c712407
Resolved sourcery-ai comments
78abd26
Update
ca745a6
Merge branch 'main' of https://github.com/simnova/sharethrift into co…
2b8198d
Resolved sonar issues
8aad95e
Update tsconfig-base.json
d669c74
resolve sonar isssue
821267c
Resolve knip issue
1ab993e
Resolve sourcery-ai comment
acd1ffb
Resolved sourcery-ai comment
e44aacc
Resolved sourcery-ai comment
c6fa0d4
Resolve sourcery-comments
0802434
Update test cases and resolved sonar issues
3276844
Fix test cases
f639ed3
update test cases
936f3a9
Revert "update test cases"
ed9242e
Revert "Fix test cases"
e370b77
Revert "Update test cases and resolved sonar issues"
304416f
Rev "
6dff80d
Update test cases
d77cf25
Add test of item-listing
a6d46ff
Update test cases
0e66a1e
Update button
cdb96ad
Update block
0f093f8
Add sharer name to pop up of Unblock Listing
9c456ec
Resolve kip issues
647a5c0
Merge branch 'main' of https://github.com/simnova/sharethrift into co…
d8d5131
Update test cases
456fc6e
Solve vulnerable storybook version
86fcab2
Merge branch 'main' of https://github.com/simnova/sharethrift into co…
cca3fae
Update Comments
75e8067
Resolve comments
0018aec
Update storybook
ef267c9
Resolve BlockListingButton
bd93b20
Update event handler
98319d3
Update yaml
520f36d
Merge branch 'main' of https://github.com/simnova/sharethrift into co…
efd094c
Update yaml
f98ae57
Update express verison
fb43e4c
Update qs version
176bfab
qs package update
f384437
Update qs in mock
68143a6
Update qs
aca871d
Revert "qs package update"
0a9e08b
Revert "Update qs"
13ca6d2
Revert "Update qs version"
622f9a2
RESOLVE SYNK ISSUE
a5f101d
Update yaml
5e8e0d5
Merge branch 'main' of https://github.com/simnova/sharethrift into co…
403f083
Merge branch 'main' of https://github.com/simnova/sharethrift into co…
e0f9de4
Suggested changes done
98c1423
Resolce conflicts
90a40ed
Update yaml
fa1cce0
Fix Vulnerability
130e543
ReSolve vunerability
e9ec51f
Revert "ReSolve vunerability"
f0a9f01
Revert "Fix Vulnerability"
51c803f
fixed vulnerabilities (react-router-dom)
efdbf52
Resolve conflicts
8aae971
Fix pnpm-lock.yaml
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...hrift/src/components/layouts/home/components/view-listing/block-listing-modal.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
| import { BlockListingModal } from './block-listing-modal'; | ||
|
|
||
| const meta: Meta<typeof BlockListingModal> = { | ||
| title: 'Layouts/Home/View Listing/Block Listing Modal', | ||
| component: BlockListingModal, | ||
| parameters: { | ||
| layout: 'centered', | ||
| }, | ||
| tags: ['autodocs'], | ||
| argTypes: { | ||
| visible: { control: 'boolean' }, | ||
| loading: { control: 'boolean' }, | ||
| onConfirm: { action: 'confirmed' }, | ||
| onCancel: { action: 'cancelled' }, | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Default: Story = { | ||
| args: { | ||
| visible: true, | ||
| listingTitle: 'City Bike', | ||
| loading: false, | ||
| }, | ||
| }; | ||
|
|
||
| export const Loading: Story = { | ||
| args: { | ||
| visible: true, | ||
| listingTitle: 'City Bike', | ||
| loading: true, | ||
| }, | ||
| }; | ||
|
|
||
| export const Closed: Story = { | ||
| args: { | ||
| visible: false, | ||
| listingTitle: 'City Bike', | ||
| loading: false, | ||
| }, | ||
| }; |
55 changes: 55 additions & 0 deletions
55
...i-sharethrift/src/components/layouts/home/components/view-listing/block-listing-modal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { Button, Modal } from 'antd'; | ||
|
|
||
| interface BlockListingModalProps { | ||
| visible: boolean; | ||
| listingTitle: string; | ||
| onConfirm: () => void; | ||
| onCancel: () => void; | ||
| loading?: boolean; | ||
| } | ||
|
|
||
| export const BlockListingModal: React.FC<BlockListingModalProps> = ({ | ||
| visible, | ||
| listingTitle, | ||
| onConfirm, | ||
| onCancel, | ||
| loading = false, | ||
| }) => { | ||
| const handleOk = () => { | ||
| onConfirm(); | ||
| }; | ||
|
|
||
| const handleCancel = () => { | ||
| onCancel(); | ||
| }; | ||
|
|
||
| return ( | ||
| <Modal | ||
| title="Block Listing" | ||
| open={visible} | ||
| onCancel={handleCancel} | ||
| footer={[ | ||
| <Button key="cancel" onClick={handleCancel}> | ||
| Cancel | ||
| </Button>, | ||
| <Button | ||
| key="block" | ||
| type="primary" | ||
| danger | ||
| onClick={handleOk} | ||
| loading={loading} | ||
| > | ||
| Block | ||
| </Button>, | ||
| ]} | ||
| > | ||
| <p style={{ marginBottom: 16 }}> | ||
| You are about to block the listing: <strong>{listingTitle}</strong> | ||
| </p> | ||
| <p> | ||
| Are you sure you want to block this listing? This will make it | ||
| unavailable to all users except administrators. | ||
| </p> | ||
| </Modal> | ||
| ); | ||
| }; |
25 changes: 25 additions & 0 deletions
25
...hrift/src/components/layouts/home/components/view-listing/block-listing.container.graphql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| mutation BlockListingContainerBlockListing($id: ObjectID!) { | ||
| blockListing(id: $id) { | ||
| status { | ||
| success | ||
| errorMessage | ||
| } | ||
| listing { | ||
| id | ||
| state | ||
| } | ||
| } | ||
| } | ||
|
|
||
| mutation BlockListingContainerUnblockListing($id: ObjectID!) { | ||
| unblockListing(id: $id) { | ||
| status { | ||
| success | ||
| errorMessage | ||
| } | ||
| listing { | ||
| id | ||
| state | ||
| } | ||
| } | ||
| } |
144 changes: 144 additions & 0 deletions
144
...t/src/components/layouts/home/components/view-listing/block-listing.container.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
| import { | ||
| BlockListingContainerBlockListingDocument, | ||
| BlockListingContainerUnblockListingDocument, | ||
| ViewListingDocument, | ||
| } from '../../../../../generated.tsx'; | ||
| import { withMockApolloClient } from '../../../../../test-utils/storybook-decorators.tsx'; | ||
| import { BlockListingButton } from './block-listing.container.tsx'; | ||
|
|
||
| const meta: Meta<typeof BlockListingButton> = { | ||
| title: 'Containers/BlockListingButton', | ||
| component: BlockListingButton, | ||
| parameters: { | ||
| layout: 'centered', | ||
| apolloClient: { | ||
| mocks: [ | ||
| { | ||
| request: { | ||
| query: BlockListingContainerBlockListingDocument, | ||
| variables: { id: 'listing-1' }, | ||
| }, | ||
| result: { | ||
| data: { | ||
| blockListing: { | ||
| __typename: 'ItemListing', | ||
| id: 'listing-1', | ||
| isBlocked: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| request: { | ||
| query: BlockListingContainerUnblockListingDocument, | ||
| variables: { id: 'listing-1' }, | ||
| }, | ||
| result: { | ||
| data: { | ||
| unblockListing: { | ||
| __typename: 'ItemListing', | ||
| id: 'listing-1', | ||
| isBlocked: false, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| request: { | ||
| query: ViewListingDocument, | ||
| variables: { id: 'listing-1' }, | ||
| }, | ||
| result: { | ||
| data: { | ||
| itemListing: { | ||
| __typename: 'ItemListing', | ||
| id: 'listing-1', | ||
| title: 'City Bike', | ||
| description: 'A great city bike', | ||
| category: 'Sports & Outdoors', | ||
| location: 'Toronto, ON', | ||
| state: 'Published', | ||
| images: [], | ||
| sharingPeriodStart: '2025-01-01', | ||
| sharingPeriodEnd: '2025-12-31', | ||
| createdAt: '2025-01-01T00:00:00Z', | ||
| updatedAt: '2025-01-01T00:00:00Z', | ||
| isBlocked: false, | ||
| sharer: { | ||
| __typename: 'PersonalUser', | ||
| id: 'user-1', | ||
| profile: { | ||
| firstName: 'John', | ||
| lastName: 'Doe', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| decorators: [withMockApolloClient], | ||
| tags: ['autodocs'], | ||
| argTypes: { | ||
| listingId: { control: 'text' }, | ||
| listingTitle: { control: 'text' }, | ||
| isBlocked: { control: 'boolean' }, | ||
| sharerName: { control: 'text' }, | ||
| renderModals: { control: 'boolean' }, | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const BlockButton: Story = { | ||
| args: { | ||
| listingId: 'listing-1', | ||
| listingTitle: 'City Bike', | ||
| isBlocked: false, | ||
| sharerName: 'user-1', | ||
| renderModals: true, | ||
| }, | ||
| }; | ||
|
|
||
| export const UnblockButton: Story = { | ||
| args: { | ||
| listingId: 'listing-1', | ||
| listingTitle: 'City Bike', | ||
| isBlocked: true, | ||
| sharerName: 'user-1', | ||
| renderModals: true, | ||
| }, | ||
| }; | ||
|
|
||
| export const BlockButtonWithoutModals: Story = { | ||
| args: { | ||
| listingId: 'listing-1', | ||
| listingTitle: 'City Bike', | ||
| isBlocked: false, | ||
| sharerName: 'user-1', | ||
| renderModals: false, | ||
| }, | ||
| }; | ||
|
|
||
| export const UnblockButtonWithoutModals: Story = { | ||
| args: { | ||
| listingId: 'listing-1', | ||
| listingTitle: 'City Bike', | ||
| isBlocked: true, | ||
| sharerName: 'user-1', | ||
| renderModals: false, | ||
| }, | ||
| }; | ||
|
|
||
| export const WithDefaultSharer: Story = { | ||
| args: { | ||
| listingId: 'listing-1', | ||
| listingTitle: 'Professional Camera', | ||
| isBlocked: false, | ||
| renderModals: true, | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.