diff --git a/src/entities/project.ts b/src/entities/project.ts index 6dfa90cd9..8a1a386c0 100644 --- a/src/entities/project.ts +++ b/src/entities/project.ts @@ -286,7 +286,7 @@ export class Project extends BaseEntity { @Field(_type => [ProjectSocialMedia], { nullable: true }) @OneToMany(_type => ProjectSocialMedia, socialMedia => socialMedia.project, { - eager: false, + eager: true, }) socialMedia?: ProjectSocialMedia[]; diff --git a/src/server/adminJs/adminJs.ts b/src/server/adminJs/adminJs.ts index 56a21ce4f..224ced418 100644 --- a/src/server/adminJs/adminJs.ts +++ b/src/server/adminJs/adminJs.ts @@ -31,6 +31,7 @@ import { SybilTab } from './tabs/sybilTab'; import { ProjectFraudTab } from './tabs/projectFraudTab'; import { RecurringDonationTab } from './tabs/recurringDonationTab'; import { AnchorContractAddressTab } from './tabs/anchorContractAddressTab'; +import { projectSocialMediaTab } from './tabs/projectSocialMediaTab'; // use redis for session data instead of in-memory storage // eslint-disable-next-line @typescript-eslint/no-var-requires const RedisStore = require('connect-redis').default; @@ -151,6 +152,7 @@ const getResources = async (): Promise => { ProjectFraudTab, RecurringDonationTab, AnchorContractAddressTab, + projectSocialMediaTab, ]; const loggingHook = async (response, request, context) => { diff --git a/src/server/adminJs/tabs/projectSocialMediaTab.ts b/src/server/adminJs/tabs/projectSocialMediaTab.ts new file mode 100644 index 000000000..e4b9bfbc9 --- /dev/null +++ b/src/server/adminJs/tabs/projectSocialMediaTab.ts @@ -0,0 +1,64 @@ +import { ProjectSocialMedia } from '../../../entities/projectSocialMedia'; +import { + canAccessMainCategoryAction, + ResourceActions, +} from '../adminJsPermissions'; + +export const projectSocialMediaTab = { + resource: ProjectSocialMedia, + options: { + actions: { + list: { + isVisible: true, + isAccessible: ({ currentAdmin }) => + canAccessMainCategoryAction({ currentAdmin }, ResourceActions.LIST), + }, + show: { + isVisible: true, + isAccessible: ({ currentAdmin }) => + canAccessMainCategoryAction({ currentAdmin }, ResourceActions.SHOW), + }, + delete: { + isVisible: false, + isAccessible: ({ currentAdmin }) => + canAccessMainCategoryAction({ currentAdmin }, ResourceActions.DELETE), + }, + new: { + isVisible: false, + isAccessible: ({ currentAdmin }) => + canAccessMainCategoryAction({ currentAdmin }, ResourceActions.NEW), + }, + edit: { + isVisible: false, + isAccessible: ({ currentAdmin }) => + canAccessMainCategoryAction({ currentAdmin }, ResourceActions.EDIT), + }, + }, + properties: { + id: { + isVisible: { + list: true, + filter: true, + show: true, + edit: false, + new: false, + }, + }, + type: { + isVisible: true, + }, + link: { + isVisible: true, + }, + slug: { + isVisible: true, + }, + project: { + isVisible: true, + }, + user: { + isVisible: true, + }, + }, + }, +}; diff --git a/src/server/adminJs/tabs/projectsTab.ts b/src/server/adminJs/tabs/projectsTab.ts index 604c2d5ae..c16c8fc78 100644 --- a/src/server/adminJs/tabs/projectsTab.ts +++ b/src/server/adminJs/tabs/projectsTab.ts @@ -28,7 +28,6 @@ import { refreshProjectPowerView, } from '../../../repositories/projectPowerViewRepository'; import { logger } from '../../../utils/logger'; -import { findSocialProfilesByProjectId } from '../../../repositories/socialProfileRepository'; import { findProjectUpdatesByProjectId } from '../../../repositories/projectUpdateRepository'; import { AdminJsContextInterface, @@ -451,7 +450,6 @@ export const fillSocialProfileAndQfRounds: After< // both cases for projectVerificationForms and projects' ids const projectId = record.params.projectId || record.params.id; - const socials = await findSocialProfilesByProjectId({ projectId }); const projectUpdates = await findProjectUpdatesByProjectId(projectId); const project = await findProjectById(projectId); const adminJsBaseUrl = process.env.SERVER_URL; @@ -470,7 +468,6 @@ export const fillSocialProfileAndQfRounds: After< projectUrl: `${process.env.GIVETH_IO_DAPP_BASE_URL}/project/${ project!.slug }`, - socials, qfRounds: project?.qfRounds, projectUpdates, adminJsBaseUrl, @@ -674,19 +671,6 @@ export const projectsTab = { statusId: { isVisible: { list: true, filter: true, show: true, edit: true }, }, - socials: { - type: 'mixed', - isVisible: { - list: false, - filter: false, - show: true, - edit: false, - new: false, - }, - components: { - show: adminJs.bundle('./components/VerificationFormSocials'), - }, - }, adminUserId: { type: 'Number', isVisible: { @@ -814,6 +798,17 @@ export const projectsTab = { edit: false, }, }, + socialMedia: { + type: 'reference', + isArray: true, + reference: 'ProjectSocialMedia', + isVisible: { + list: false, + filter: false, + show: true, + edit: false, + } + }, categoryIds: { type: 'reference', isArray: true,