mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
Revert "Fixed actions crashing on post history"
Revert "Improved null handling on Admin X" and Revert "Fixed actions crashing on post history" no issue
This commit is contained in:
parent
1f2f0a7322
commit
6d0da713f0
1 changed files with 16 additions and 29 deletions
|
@ -110,19 +110,8 @@ export const getActorLinkTarget = (action: Action): InternalLink | ExternalLink
|
|||
};
|
||||
|
||||
export const getLinkTarget = (action: Action): InternalLink | ExternalLink | undefined => {
|
||||
if (!action.resource_type || !action.event || !action.resource) {
|
||||
return;
|
||||
}
|
||||
let resourceType = action.resource_type;
|
||||
|
||||
const contextExists = action.context !== null;
|
||||
|
||||
if (resourceType === 'post' && contextExists) {
|
||||
if (action.context?.type) {
|
||||
resourceType = action.context?.type as string;
|
||||
}
|
||||
}
|
||||
|
||||
if (action.event !== 'deleted') {
|
||||
switch (action.resource_type) {
|
||||
case 'page':
|
||||
|
@ -183,9 +172,6 @@ export const getLinkTarget = (action: Action): InternalLink | ExternalLink | und
|
|||
};
|
||||
|
||||
export const getActionTitle = (action: Action) => {
|
||||
if (!action.resource_type || !action.event) {
|
||||
return '';
|
||||
}
|
||||
let resourceType = action.resource_type;
|
||||
|
||||
if (resourceType === 'api_key') {
|
||||
|
@ -196,23 +182,23 @@ export const getActionTitle = (action: Action) => {
|
|||
resourceType = 'tier';
|
||||
}
|
||||
|
||||
const contextExists = action.context !== null;
|
||||
|
||||
if (resourceType === 'post' && contextExists) {
|
||||
// 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;
|
||||
resourceType = action.context?.type as string;
|
||||
}
|
||||
}
|
||||
|
||||
let actionName = action.event;
|
||||
|
||||
if (action.event === 'edited' && contextExists) {
|
||||
if (action.context?.action_name) {
|
||||
if (action.event === 'edited') {
|
||||
if (action.context.action_name) {
|
||||
actionName = action.context.action_name as string;
|
||||
}
|
||||
}
|
||||
|
||||
if (contextExists && action.context?.count && (action.context.count as number) > 1) {
|
||||
if (action.context.count && (action.context.count as number) > 1) {
|
||||
return `${action.context.count} ${resourceType}s ${actionName}`;
|
||||
}
|
||||
|
||||
|
@ -220,13 +206,14 @@ export const getActionTitle = (action: Action) => {
|
|||
};
|
||||
|
||||
export const getContextResource = (action: Action) => {
|
||||
if (action.resource_type === 'setting' && action.context && action.context?.group && action.context?.key) {
|
||||
return {
|
||||
group: action.context.group as string,
|
||||
key: action.context.key as string
|
||||
};
|
||||
if (action.resource_type === 'setting') {
|
||||
if (action.context?.group && action.context?.key) {
|
||||
return {
|
||||
group: action.context.group as string,
|
||||
key: action.context.key as string
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
export const isBulkAction = (action: Action) => {
|
||||
return action.context !== null && typeof action.context?.count === 'number' && action.context.count > 1;
|
||||
};
|
||||
|
||||
export const isBulkAction = (action: Action) => typeof action.context.count === 'number' && action.context.count > 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue