Skip to content

Commit

Permalink
fill and show adminAddressHistory field in the projectsTab of adminJS
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 committed Aug 1, 2024
1 parent 22a6e3f commit 36b912f
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/server/adminJs/tabs/projectsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
After,
} from 'adminjs/src/backend/actions/action.interface';
import { RecordJSON } from 'adminjs/src/frontend/interfaces/record-json.interface';
import moment from 'moment/moment';
import {
Project,
ProjectUpdate,
Expand Down Expand Up @@ -716,6 +715,17 @@ export const projectsTab = {
},
position: 1,
},
adminAddressHistory: {
type: 'string[]',
isVisible: {
list: false,
filter: false,
show: true,
edit: false,
new: false,
},
position: 2,
},
contacts: {
isVisible: {
list: false,
Expand Down Expand Up @@ -1031,19 +1041,16 @@ export const projectsTab = {
const adminUser = await User.findOne({
where: { id: request?.record?.params?.newAdminId },
});
const changeLog =
'previous admin user address: ' +
project.adminUser.walletAddress;
const previousAdminAddress = project.adminUser.walletAddress;
if (previousAdminAddress) {
if (project.adminAddressHistory) {
project.adminAddressHistory.push(previousAdminAddress);
} else {
project.adminAddressHistory = [previousAdminAddress];
}
}
project.adminUser = adminUser!;
await project.save();
await ProjectUpdate.insert({
userId: currentAdmin.id,
projectId: project.id,
content: changeLog,
title: 'admin user changed',
createdAt: moment().toDate(),
isMain: false,
});
}
// Not required for now
// Project.notifySegment(project, SegmentEvents.PROJECT_EDITED);
Expand Down

0 comments on commit 36b912f

Please sign in to comment.