mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 10:42:45 +03:00
Fixed actions crashing on post history - Admin X (#18344)
refs https://ghost.slack.com/archives/C0568LN2CGJ/p1695642553045059 - this attempts to fix an undefined error on AdminX when accessing history log. - At the moment I only have it reproducible on staging, so if this doesn't fix it, it will potentially be reverted. --- <!-- Leave the line below if you'd like GitHub Copilot to generate a summary from your commit --> <!-- copilot:summary --> ### <samp>🤖 Generated by Copilot at 818fa49</samp> Improve context handling for action events in `actions.ts`. Use a variable to simplify and customize the action name and title based on the context.
This commit is contained in:
parent
41576d2dc3
commit
677c829c4b
@ -182,23 +182,23 @@ export const getActionTitle = (action: Action) => {
|
||||
resourceType = 'tier';
|
||||
}
|
||||
|
||||
// Because a `page` and `post` both use the same model, we store the
|
||||
// actual type in the context, so let's check if that exists
|
||||
if (resourceType === 'post') {
|
||||
if (action.context?.type) {
|
||||
resourceType = action.context?.type as string;
|
||||
const contextExists = action.context !== null;
|
||||
|
||||
if (resourceType === 'post' && contextExists) {
|
||||
if (action.context.type) {
|
||||
resourceType = action.context.type as string;
|
||||
}
|
||||
}
|
||||
|
||||
let actionName = action.event;
|
||||
|
||||
if (action.event === 'edited') {
|
||||
if (action.event === 'edited' && contextExists) {
|
||||
if (action.context.action_name) {
|
||||
actionName = action.context.action_name as string;
|
||||
}
|
||||
}
|
||||
|
||||
if (action.context.count && (action.context.count as number) > 1) {
|
||||
if (contextExists && action.context.count && (action.context.count as number) > 1) {
|
||||
return `${action.context.count} ${resourceType}s ${actionName}`;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user