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

ENH More Actions button is hidden if Campaign is published #288

Merged

Conversation

sabina-talipova
Copy link
Contributor

Description

  • API endpoints to remove items from campaign return 400 errors when called on a published campaign.
  • UI doesn't offer actions to remove items if the campaign has been published.

Parent issue

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

Tested locally, works good, some minor code changes

Comment on lines 388 to 405
return State === 'open'
? (
<PreviewComponent
itemLinks={itemLinks}
itemId={itemId}
onBack={this.handleCloseItem}
moreActions={this.getMoreActions()}
className={previewClasses}
/>
)
: (
<PreviewComponent
itemLinks={itemLinks}
itemId={itemId}
onBack={this.handleCloseItem}
className={previewClasses}
/>
);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return State === 'open'
? (
<PreviewComponent
itemLinks={itemLinks}
itemId={itemId}
onBack={this.handleCloseItem}
moreActions={this.getMoreActions()}
className={previewClasses}
/>
)
: (
<PreviewComponent
itemLinks={itemLinks}
itemId={itemId}
onBack={this.handleCloseItem}
className={previewClasses}
/>
);
const props = {
itemLinks,
itemID,
onBack: this.handleCloseItem,
className: previewClasses,
};
if (State) {
props.moreActions = this.getMoreActions();
}
return <PreviewComponent {...props}/>;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@@ -159,4 +161,38 @@ public function testReadCampaign(
$response = $this->get("/admin/campaigns/set/$changeSetID/show", null, ['Accept' => 'application/json']);
$this->assertEquals($expectedResponseCode, $response->getStatusCode());
}

public function removeCampaignDataProvider()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function removeCampaignDataProvider()
public function provideRemoveCampaignItem(): array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 174 to 181
/**
* @dataProvider removeCampaignDataProvider
*/
public function testRemoveCampaignItem(
bool $isPublished,
bool $isWrongID,
int $expectedResponseCode,
) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/**
* @dataProvider removeCampaignDataProvider
*/
public function testRemoveCampaignItem(
bool $isPublished,
bool $isWrongID,
int $expectedResponseCode,
) {
/**
* @dataProvider provideRemoveCampaignItem
*/
public function testRemoveCampaignItem(
bool $isPublished,
bool $isWrongID,
int $expectedResponseCode,
): void {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@sabina-talipova sabina-talipova force-pushed the pulls/2/more-action-btn-hidden branch from 28532dd to b088e1a Compare November 7, 2023 22:21
@sabina-talipova sabina-talipova force-pushed the pulls/2/more-action-btn-hidden branch from b088e1a to bdd34d7 Compare November 7, 2023 22:29
Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

Looks good

@emteknetnz emteknetnz merged commit 1c20dbf into silverstripe:2 Nov 7, 2023
12 checks passed
@emteknetnz emteknetnz deleted the pulls/2/more-action-btn-hidden branch November 7, 2023 23:00
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.

2 participants