-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
[TASK-882] [TASK-1186] Project activity details modal #5210
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7b51284
add modal to formActivity
magicznyleszek d086626
wip change mock data to follow BE response architecture
magicznyleszek dabf23d
further update data (WIP)
magicznyleszek a4b354c
Merge branch 'main' into task-882-details-modal
magicznyleszek 413241c
create ActivityMessage component, add all possible messages,
magicznyleszek 631c710
linter cleanup
magicznyleszek 39a422d
improve mock data
magicznyleszek a8be6f5
add comments
magicznyleszek d5a59f1
code cleanupo
magicznyleszek 878e5cd
Merge branch 'main' into task-882-details-modal
magicznyleszek 1383e68
Merge branch 'main' into task-882-details-modal
magicznyleszek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
/** | ||
* All possible log item actions. | ||
* @see `AuditAction` class from {@link kobo/apps/audit_log/models.py} (BE code) | ||
*/ | ||
export enum AuditActions { | ||
'update-name' = 'update-name', | ||
'update-settings' = 'update-settings', | ||
'deploy' = 'deploy', | ||
'redeploy' = 'redeploy', | ||
'archive' = 'archive', | ||
'unarchive' = 'unarchive', | ||
'replace-form' = 'replace-form', | ||
'update-form' = 'update-form', | ||
'export' = 'export', | ||
'update-qa' = 'update-qa', | ||
'add-media' = 'add-media', | ||
'delete-media' = 'delete-media', | ||
'connect-project' = 'connect-project', | ||
'disconnect-project' = 'disconnect-project', | ||
'modify-imported-fields' = 'modify-imported-fields', | ||
'modify-sharing' = 'modify-sharing', | ||
'enable-sharing' = 'enable-sharing', | ||
'disable-sharing' = 'disable-sharing', | ||
'register-service' = 'register-service', | ||
'modify-service' = 'modify-service', | ||
'delete-service' = 'delete-service', | ||
'add-user' = 'add-user', | ||
'remove-user' = 'remove-user', | ||
'update-permission' = 'update-permission', | ||
'make-public' = 'make-public', | ||
'share-public' = 'share-public', | ||
'transfer' = 'transfer', | ||
} | ||
|
||
type AuditActionTypes = { | ||
[P in AuditActions]: { | ||
name: AuditActions; | ||
message: string; | ||
}; | ||
}; | ||
|
||
export const AUDIT_ACTION_TYPES: AuditActionTypes = { | ||
'update-name': { | ||
name: AuditActions['update-name'], | ||
message: t('##username## changed project name'), | ||
}, | ||
'update-settings': { | ||
name: AuditActions['update-settings'], | ||
message: t('##username## updated project settings'), | ||
}, | ||
'deploy': { | ||
name: AuditActions['deploy'], | ||
message: t('##username## deployed project'), | ||
}, | ||
'redeploy': { | ||
name: AuditActions['redeploy'], | ||
message: t('##username## redeployed project'), | ||
}, | ||
'archive': { | ||
name: AuditActions['archive'], | ||
message: t('##username## archived project'), | ||
}, | ||
'unarchive': { | ||
name: AuditActions['unarchive'], | ||
message: t('##username## unarchived project'), | ||
}, | ||
'replace-form': { | ||
name: AuditActions['replace-form'], | ||
message: t('##username## uploaded a new form'), | ||
}, | ||
'update-form': { | ||
name: AuditActions['update-form'], | ||
message: t('##username## edited the form in the formbuilder'), | ||
}, | ||
'export': { | ||
name: AuditActions['export'], | ||
message: t('##username## exported data'), | ||
}, | ||
'update-qa': { | ||
name: AuditActions['update-qa'], | ||
message: t('##username## modified qualitative analysis questions'), | ||
}, | ||
'add-media': { | ||
name: AuditActions['add-media'], | ||
message: t('##username## added a media attachment'), | ||
}, | ||
'delete-media': { | ||
name: AuditActions['delete-media'], | ||
message: t('##username## removed a media attachment'), | ||
}, | ||
'connect-project': { | ||
name: AuditActions['connect-project'], | ||
message: t('##username## connected project data with another project'), | ||
}, | ||
'disconnect-project': { | ||
name: AuditActions['disconnect-project'], | ||
message: t('##username## disconnected project from another project'), | ||
}, | ||
'modify-imported-fields': { | ||
name: AuditActions['modify-imported-fields'], | ||
message: t('##username## changed imported fields from another project'), | ||
}, | ||
'modify-sharing': { | ||
name: AuditActions['modify-sharing'], | ||
message: t('##username## modified data sharing'), | ||
}, | ||
'enable-sharing': { | ||
name: AuditActions['enable-sharing'], | ||
message: t('##username## enabled data sharing'), | ||
}, | ||
'disable-sharing': { | ||
name: AuditActions['disable-sharing'], | ||
message: t('##username## disabled data sharing'), | ||
}, | ||
'register-service': { | ||
name: AuditActions['register-service'], | ||
message: t('##username## registered a new REST service'), | ||
}, | ||
'modify-service': { | ||
name: AuditActions['modify-service'], | ||
message: t('##username## modified a REST service'), | ||
}, | ||
'delete-service': { | ||
name: AuditActions['delete-service'], | ||
message: t('##username## deleted a REST service'), | ||
}, | ||
'add-user': { | ||
name: AuditActions['add-user'], | ||
message: t('##username## added ##username2## to project'), | ||
}, | ||
'remove-user': { | ||
name: AuditActions['remove-user'], | ||
message: t('##username## removed ##username2## from project'), | ||
}, | ||
'update-permission': { | ||
name: AuditActions['update-permission'], | ||
message: t('##username## updated permissions of ##username2##'), | ||
}, | ||
'make-public': { | ||
name: AuditActions['make-public'], | ||
message: t('##username## made the project publicly accessible'), | ||
}, | ||
'share-public': { | ||
name: AuditActions['share-public'], | ||
message: t('##username## shared data publicly'), | ||
}, | ||
'transfer': { | ||
name: AuditActions['transfer'], | ||
message: t('##username## transferred project ownership to ##username2##'), | ||
}, | ||
}; | ||
|
||
export const FALLBACK_MESSAGE = '##username## did action ##action##'; | ||
|
||
/** | ||
* All possible log item types. | ||
* @see `AuditType` class from {@link kobo/apps/audit_log/models.py} (BE code) | ||
*/ | ||
export enum AuditTypes { | ||
access = 'access', | ||
'project-history' = 'project-history', | ||
'data-editing' = 'data-editing', | ||
'user-management' = 'user-management', | ||
'asset-management' = 'asset-management', | ||
'submission-management' = 'submission-management', | ||
} | ||
|
||
export enum AuditSubTypes { | ||
project = 'project', | ||
permission = 'permission', | ||
} | ||
|
||
export interface ActivityLogsItem { | ||
/** User url. E.g. "https://kf.beta.kbtdev.org/api/v2/users/<username>/" */ | ||
user: string; | ||
user_uid: string; | ||
username: string; | ||
/** Date string in ISO 8601. E.g. "2024-10-04T14:04:18Z" */ | ||
date_created: string; | ||
action: AuditActions; | ||
log_type: AuditTypes; | ||
metadata: { | ||
/** E.g. "Firefox (Ubuntu)" */ | ||
source: string; | ||
asset_uid: string; | ||
/** E.g. "71.235.120.86" */ | ||
ip_address: string; | ||
log_subtype: AuditSubTypes; | ||
old_name?: string; | ||
new_name?: string; | ||
latest_deployed_version_id?: string; | ||
latest_version_id?: string; | ||
version_uid?: string; | ||
second_user?: string; | ||
// a lot of more optional metadata props… | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
jsapp/js/components/activity/activityMessage.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Avatar from '../common/avatar'; | ||
import {type ActivityLogsItem, AUDIT_ACTION_TYPES, FALLBACK_MESSAGE} from './activity.constants'; | ||
import styles from './activityMessage.module.scss'; | ||
|
||
/** | ||
* An inline message that starts with avatar and username, and then is followed | ||
* by short text describing what username did. | ||
*/ | ||
export function ActivityMessage(props: {data: ActivityLogsItem}) { | ||
magicznyleszek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let message = AUDIT_ACTION_TYPES[props.data.action]?.message || FALLBACK_MESSAGE; | ||
|
||
// Here we reaplace all possible placeholders with appropriate data. This way | ||
// we don't really need to know which message (out of around 30) are we | ||
// dealing with - if it has given placeholder, it would be replaced, if it | ||
// doesn't nothing will happen. | ||
message = message | ||
.replace('##username##', `<strong>${props.data.username}</strong>`) | ||
.replace('##action##', props.data.action); | ||
// We only replace it if metadata is provided. | ||
if (props.data.metadata.second_user) { | ||
message = message.replace('##username2##', `<strong>${props.data.metadata.second_user}</strong>`); | ||
} | ||
|
||
return ( | ||
<div className={styles.activityMessage}> | ||
<Avatar size='s' username={props.data.username} /> | ||
<span dangerouslySetInnerHTML={{__html: message}} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.activityMessage { | ||
display: inline-flex; | ||
align-items: center; | ||
gap: 4px; | ||
font-size: 14px; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice extends to the mock! 👍🏻