|
@@ -41,6 +41,14 @@ type ActivityListItemProps = {
|
|
|
activity: ActivityHasTargetPage,
|
|
activity: ActivityHasTargetPage,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+type AllowPageDisplayPayload = {
|
|
|
|
|
+ grant: number | undefined,
|
|
|
|
|
+ status: string,
|
|
|
|
|
+ wip: boolean,
|
|
|
|
|
+ deletedAt?: Date,
|
|
|
|
|
+ path: string,
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const translateAction = (action: SupportedActivityActionType): string => {
|
|
const translateAction = (action: SupportedActivityActionType): string => {
|
|
|
return ActivityActionTranslationMap[action] || 'unknown_action';
|
|
return ActivityActionTranslationMap[action] || 'unknown_action';
|
|
|
};
|
|
};
|
|
@@ -58,6 +66,27 @@ const calculateTimePassed = (date: Date, locale: Locale): string => {
|
|
|
return timePassed;
|
|
return timePassed;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+const pageAllowedForDisplay = (allowDisplayPayload: AllowPageDisplayPayload): boolean => {
|
|
|
|
|
+ const {
|
|
|
|
|
+ grant, status, wip, deletedAt,
|
|
|
|
|
+ } = allowDisplayPayload;
|
|
|
|
|
+ if (grant !== 1) return false;
|
|
|
|
|
+
|
|
|
|
|
+ if (status !== 'published') return false;
|
|
|
|
|
+
|
|
|
|
|
+ if (wip) return false;
|
|
|
|
|
+
|
|
|
|
|
+ if (deletedAt) return false;
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const setPath = (path: string, allowed: boolean): string => {
|
|
|
|
|
+ if (allowed) return path;
|
|
|
|
|
+
|
|
|
|
|
+ return '';
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
|
|
|
export const ActivityListItem = ({ props }: { props: ActivityListItemProps }): JSX.Element => {
|
|
export const ActivityListItem = ({ props }: { props: ActivityListItemProps }): JSX.Element => {
|
|
|
const { t, i18n } = useTranslation();
|
|
const { t, i18n } = useTranslation();
|
|
@@ -65,7 +94,21 @@ export const ActivityListItem = ({ props }: { props: ActivityListItemProps }): J
|
|
|
const dateFnsLocale = getLocale(currentLangCode);
|
|
const dateFnsLocale = getLocale(currentLangCode);
|
|
|
|
|
|
|
|
const { activity } = props;
|
|
const { activity } = props;
|
|
|
- const targetPagePath = activity.target.path;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const {
|
|
|
|
|
+ path, grant, status, wip, deletedAt,
|
|
|
|
|
+ } = activity.target;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ const allowDisplayPayload: AllowPageDisplayPayload = {
|
|
|
|
|
+ grant,
|
|
|
|
|
+ status,
|
|
|
|
|
+ wip,
|
|
|
|
|
+ deletedAt,
|
|
|
|
|
+ path,
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const isPageAllowed = pageAllowedForDisplay(allowDisplayPayload);
|
|
|
|
|
|
|
|
const action = activity.action as SupportedActivityActionType;
|
|
const action = activity.action as SupportedActivityActionType;
|
|
|
const keyToTranslate = translateAction(action);
|
|
const keyToTranslate = translateAction(action);
|
|
@@ -81,11 +124,11 @@ export const ActivityListItem = ({ props }: { props: ActivityListItemProps }): J
|
|
|
<div className="flex-grow-1 ms-2">
|
|
<div className="flex-grow-1 ms-2">
|
|
|
<div className="activity-path-line mb-0">
|
|
<div className="activity-path-line mb-0">
|
|
|
<a
|
|
<a
|
|
|
- href={targetPagePath}
|
|
|
|
|
|
|
+ href={setPath(path, isPageAllowed)}
|
|
|
className="activity-target-link fw-bold text-wrap d-block"
|
|
className="activity-target-link fw-bold text-wrap d-block"
|
|
|
>
|
|
>
|
|
|
<span>
|
|
<span>
|
|
|
- {targetPagePath}
|
|
|
|
|
|
|
+ {setPath(path, isPageAllowed)}
|
|
|
</span>
|
|
</span>
|
|
|
</a>
|
|
</a>
|
|
|
</div>
|
|
</div>
|