1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 18:29:23 +00:00

deleted files notice (#5426)

* batch delete files notice

* frontend page
This commit is contained in:
WJH
2023-07-19 10:44:30 +08:00
committed by GitHub
parent 80022abf0e
commit f81072c8a7
3 changed files with 38 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ const MSG_TYPE_DRAFT_COMMENT = 'draft_comment';
const MSG_TYPE_DRAFT_REVIEWER = 'draft_reviewer';
const MSG_TYPE_GUEST_INVITATION_ACCEPTED = 'guest_invitation_accepted';
const MSG_TYPE_REPO_MONITOR = 'repo_monitor';
const MSG_TYPE_DELETED_FILES = 'deleted_files';
class NoticeItem extends React.Component {
@@ -307,6 +308,21 @@ class NoticeItem extends React.Component {
return { avatar_url, notice };
}
if (noticeType === MSG_TYPE_DELETED_FILES) {
const {
repo_id,
repo_name,
} = detail;
const repoURL = `${siteRoot}library/${repo_id}/${encodeURIComponent(repo_name)}/`;
const repoLink = `<a href=${repoURL} target="_blank">${Utils.HTMLescape(repo_name)}</a>`;
let notice = gettext('Your library {libraryName} has recently deleted a large number of files.');
notice = notice.replace('{libraryName}', repoLink);
return { avatar_url : null, notice };
}
// if (noticeType === MSG_TYPE_GUEST_INVITATION_ACCEPTED) {
// }

View File

@@ -75,6 +75,7 @@ MSG_TYPE_DRAFT_REVIEWER = 'draft_reviewer'
MSG_TYPE_GUEST_INVITATION_ACCEPTED = 'guest_invitation_accepted'
MSG_TYPE_REPO_TRANSFER = 'repo_transfer'
MSG_TYPE_REPO_MINOTOR = 'repo_monitor'
MSG_TYPE_DELETED_FILES = 'deleted_files'
USER_NOTIFICATION_COUNT_CACHE_PREFIX = 'USER_NOTIFICATION_COUNT_'
@@ -407,6 +408,9 @@ class UserNotification(models.Model):
def is_repo_monitor_msg(self):
return self.msg_type == MSG_TYPE_REPO_MINOTOR
def is_deleted_files_msg(self):
return self.msg_type == MSG_TYPE_DELETED_FILES
def user_message_detail_to_dict(self):
"""Parse user message detail, returns dict contains ``message`` and
``msg_from``.

View File

@@ -247,4 +247,22 @@ def update_notice_detail(request, notices):
except Exception as e:
logger.error(e)
elif notice.is_deleted_files_msg():
try:
d = json.loads(notice.detail)
repo_id = d['repo_id']
if repo_id in repo_dict:
repo = repo_dict[repo_id]
else:
repo = seafile_api.get_repo(repo_id)
repo_dict[repo_id] = repo
if repo:
d['repo_name'] = repo.name
notice.detail = d
else:
notice.detail = None
except Exception as e:
logger.error(e)
return notices