Skip to content

Commit

Permalink
Fix redirect deletion (Fixes ethercreative#441)
Browse files Browse the repository at this point in the history
Remove HTML from fail toast (Fixes ethercreative#449)
  • Loading branch information
Tam committed Apr 19, 2023
1 parent ad87bdf commit e377939
Show file tree
Hide file tree
Showing 14 changed files with 4,528 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## 4.1.1 - 2023-04-19
### Fixed
- Fix redirect page 500 error (Fixes #448)
- Remove HTML from fail toast (Fixes #449)
- Fix redirect deletion (Fixes #441)

## 4.1.0 - 2023-04-12
### Fixed
Expand Down
4 changes: 2 additions & 2 deletions resources/js/_helpers/fail.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global Craft */
export default function fail (message) {
Craft.cp.displayError(`<strong>SEO:</strong> ${message}`);
Craft.cp.displayError(`SEO: ${message}`);
window.console && console.error.apply( // eslint-disable-line no-console
console,
[
Expand All @@ -9,4 +9,4 @@ export default function fail (message) {
'font-weight: normal;',
]
);
}
}
20 changes: 10 additions & 10 deletions resources/js/settings/Redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class Redirects {
));

Craft.cp.displayNotice(
"<strong>SEO:</strong> Redirect added successfully!"
"SEO: Redirect added successfully!"
);
spinner.classList.add("hidden");

Expand All @@ -115,7 +115,7 @@ export default class Redirects {
uri.focus();
this.initTables();
}, error => {
Craft.cp.displayError("<strong>SEO:</strong> " + error);
Craft.cp.displayError("SEO: " + error);
spinner.classList.add("hidden");
});
};
Expand Down Expand Up @@ -159,13 +159,13 @@ export default class Redirects {
));
});

Craft.cp.displayNotice('<strong>SEO:</strong> Redirects added successfully!');
Craft.cp.displayNotice('SEO: Redirects added successfully!');
spinner.classList.add("hidden");

redirects.value = '';
this.initTables();
}, error => {
Craft.cp.displayError('<strong>SEO:</strong> ' + error);
Craft.cp.displayError('SEO: ' + error);
spinner.classList.add("hidden");
});
};
Expand Down Expand Up @@ -209,7 +209,7 @@ export default class Redirects {

this.tables[siteId].removeChild(row);
}, error => {
Craft.cp.displayError('<strong>SEO:</strong> ' + error);
Craft.cp.displayError('SEO: ' + error);
spinner.classList.add("hidden");
});
};
Expand Down Expand Up @@ -257,10 +257,10 @@ export default class Redirects {
this.post("DELETE", {
id: row.dataset.id
}, () => {
Craft.cp.displayNotice('<strong>SEO:</strong> Redirect deleted');
Craft.cp.displayNotice('SEO: Redirect deleted');
this.tables[siteId].removeChild(row);
}, error => {
Craft.cp.displayNotice('<strong>SEO:</strong> ' + error);
Craft.cp.displayNotice('SEO: ' + error);
});
};

Expand All @@ -279,9 +279,9 @@ export default class Redirects {
action: 'seo/redirects/sort',
order: post,
}, () => {
Craft.cp.displayNotice('<strong>SEO:</strong> Redirect order saved');
Craft.cp.displayNotice('SEO: Redirect order saved');
}, error => {
Craft.cp.displayNotice('<strong>SEO:</strong> ' + error);
Craft.cp.displayNotice('SEO: ' + error);
});
};

Expand Down Expand Up @@ -482,4 +482,4 @@ export default class Redirects {
return true;
}

}
}
8 changes: 6 additions & 2 deletions src/services/RedirectsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,11 @@ public function sort ($order)
*/
public function delete ($id)
{
$redirect = RedirectRecord::findOne(compact('id'))->delete();
$redirect = false;

try {
$redirect = RedirectRecord::findOne(compact('id'))->delete();
} catch (\Exception $e) {}

if ($redirect === false)
return 'Unable find redirect with ID: ' . $id;
Expand Down Expand Up @@ -338,4 +342,4 @@ private function _isRedirectRegex ($uri)
return false;
}

}
}
2 changes: 1 addition & 1 deletion src/web/assets/css/seo.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/css/seo.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e377939

Please sign in to comment.