Skip to content
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

Fix finegrained roles #268

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -74,21 +74,34 @@ const createPostPages = (posts, createPage) => {
* @param {import("gatsby/index.d.ts").CreateSchemaCustomizationArgs}
*/
exports.createSchemaCustomization = ({ actions, schema }) => {
const { createTypes } = actions
const { createTypes } = actions;
const typeDefs = `
type MembersJson implements Node {
team: [TeamsJson] @link(by: "name")
teamRoles: [TeamRole]
posts: [MarkdownRemark] @link(by: "frontmatter.authors.pennkey", from: "pennkey")
}

type AlumniJson implements Node {
teamRoles: [TeamRole]
posts: [MarkdownRemark] @link(by: "frontmatter.authors.pennkey", from: "pennkey")
}

type TeamRole {
team: TeamsJson @link(by: "name", from: "team")
roles: [String]
}

type MarkdownRemark implements Node {
frontmatter: Frontmatter
}

type Frontmatter {
authors: [MembersJson] @link(by: "pennkey")
customExcerpt: String
publishedAt: Date @dateformat(formatString: "YYYY-MM-DD")
draft: Boolean
}`
}`;

const teamsJson = schema.buildObjectType({
name: 'TeamsJson',
interfaces: ['Node'],
@@ -98,22 +111,27 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
},
members: {
type: '[MembersJson]',
resolve: (source, args, context, info) => {
return context.nodeModel.runQuery({
resolve: async (source, args, context, info) => {
const members = await context.nodeModel.runQuery({
type: 'MembersJson',
query: {
filter: {
team: { elemMatch: { name: { eq: source.name } } },
teamRoles: { elemMatch: { team: { name: { eq: source.name } } } },
},
},
})
});
return members.map(member => ({
...member,
roles: member.teamRoles.filter(role => role.team === source.name)[0].roles,
}));
},
},
},
})
createTypes(typeDefs)
createTypes([teamsJson])
}
});

createTypes(typeDefs);
createTypes([teamsJson]);
};

exports.createPages = async ({ graphql, actions, reporter }) => {
const { createPage, createRedirect } = actions
19 changes: 7 additions & 12 deletions src/components/Team/TeamMemberPreview.tsx
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import {
} from '../../constants/measurements'
import { TEAM_MEMBER_ROUTE } from '../../constants/routes'
import { BLACK_ALPHA } from '../../constants/colors'
import { IMember } from '../../types'
import { ITeamMember } from '../../types'

const StyledLink = styled(Link) <{}>`
width: calc(100% + ${M2} + ${M2});
@@ -42,14 +42,8 @@ const Image = styled(BackgroundImage)`
border-radius: ${BORDER_RADIUS};
`

export const TeamMemberPreview = ({
name,
roles,
pennkey,
localImage,
semester_joined: semesterJoined,
alumnus,
}: IMember) => (
export const TeamMemberPreview = ({ name, roles, pennkey, localImage, semester_joined}: ITeamMember): React.ReactElement => {
return (
<Col margin={M2} sm={12} md={6} lg={3} key={pennkey}>
<StyledLink to={TEAM_MEMBER_ROUTE(pennkey)}>
{
@@ -61,11 +55,12 @@ export const TeamMemberPreview = ({
<div style={{ marginBottom: M3 }}>
<Tags tags={roles} />
</div>
{semesterJoined && (
{semester_joined && (
<P mb0 sm>
Member since {semesterToString(semesterJoined)}
Member since {semesterToString(semester_joined)}
</P>
)}
</StyledLink>
</Col>
)
)
}
8 changes: 4 additions & 4 deletions src/components/Team/Teams.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { ITeam, IMember } from '../../types'
import { ITeam, IMember, ITeamMember } from '../../types'
import { Fade, Section, H2, Row, Col, P } from '../../shared'
import { M2 } from '../../constants/measurements'
import { TeamMemberPreview } from './TeamMemberPreview'
@@ -10,7 +10,7 @@ interface ITeams {

const TEAM_LEAD = 'Team Lead'

const leadsFirst = (members: IMember[]): IMember[] => {
const leadsFirst = (members: ITeamMember[]): ITeamMember[] => {
if (!members) return []

return members.sort((m1, m2): number => {
@@ -30,7 +30,7 @@ export const Teams = ({ teams }: ITeams) => (
<>
{teams.map(({ name, description, members }: ITeam) => (
<Fade key={name} distance="1rem">
<Section>
<Section style={{width: '100%'}}>
<H2 mb2>{name}</H2>
<Row>
<Col sm={12} md={10} lg={8}>
@@ -39,7 +39,7 @@ export const Teams = ({ teams }: ITeams) => (
</Row>

<Row margin={M2}>
{leadsFirst(members).map((props: IMember) => (
{leadsFirst(members).map((props: ITeamMember) => (
<TeamMemberPreview key={props.pennkey} {...props} />
))}
</Row>
8 changes: 5 additions & 3 deletions src/json/alumni/aanten.json
Original file line number Diff line number Diff line change
@@ -5,9 +5,11 @@
"school": "College of Arts & Sciences",
"bio": "Hi! I'm a sophomore studying math & CS in the college and an avid proponent of Buffalo Wild Wings.",
"hometown": "Long Island, NY",
"team": "Penn Mobile",
"roles": [
"iOS Mobile Engineer"
"teamRoles": [
{
"team": "Penn Mobile",
"roles": ["iOS Mobile Engineer"]
}
],
"photo": "https://i.imgur.com/i271XGY.jpg",
"linkedin": "https://www.linkedin.com/in/andrew-antenberg/",
9 changes: 6 additions & 3 deletions src/json/alumni/anagwekar.json
Original file line number Diff line number Diff line change
@@ -5,8 +5,12 @@
"school": "Engineering",
"bio": "Hey! My name is Ansh Nagwekar, and I am a freshman studying NETS at Penn. Outside the lab, you can probably find me hiking up a mountain, playing spikeball, eating Airheads, or overanalyzing song lyrics!",
"hometown": "San Jose, California",
"team": "Penn Courses",
"roles": ["Backend Engineer"],
"teamRoles": [
{
"team": "Penn Courses",
"roles": ["Backend Engineer"]
}
],
"photo": "https://i.imgur.com/LITbDoC.jpg?1",
"linkedin": "https://www.linkedin.com/in/ansh-nagwekar/",
"website": "",
@@ -16,4 +20,3 @@
"graduation_year": 2025,
"job": null
}

10 changes: 6 additions & 4 deletions src/json/alumni/annajg.json
Original file line number Diff line number Diff line change
@@ -5,9 +5,11 @@
"school": "Engineering",
"bio": "My holy trinity consists of painting, pasta, and Percy Jackson. Also a VSCO HB2 enthusiast :)",
"hometown": "Edison, NJ",
"team": "Penn Mobile",
"roles": [
"Designer"
"teamRoles": [
{
"team": "Penn Mobile",
"roles": ["Designer"]
}
],
"photo": "https://i.imgur.com/acetToI.jpg",
"linkedin": "https://www.linkedin.com/in/annasjiang/",
@@ -17,4 +19,4 @@
"alumnus": true,
"graduation_year": 2023,
"job": null
}
}
10 changes: 6 additions & 4 deletions src/json/alumni/annawang.json
Original file line number Diff line number Diff line change
@@ -5,9 +5,11 @@
"school": "Engineering",
"bio": "former wii fit user",
"hometown": "Saratoga, CA",
"team": "Penn Mobile",
"roles": [
"Designer"
"teamRoles": [
{
"team": "Penn Mobile",
"roles": ["Designer"]
}
],
"photo": "https://i.imgur.com/QAXyuBW.jpg",
"linkedin": "https://www.linkedin.com/in/annalinwang/",
@@ -17,4 +19,4 @@
"alumnus": true,
"graduation_year": 2023,
"job": null
}
}
10 changes: 6 additions & 4 deletions src/json/alumni/annipan.json
Original file line number Diff line number Diff line change
@@ -5,9 +5,11 @@
"school": "Engineering",
"bio": "Hi there! I'm a sophomore at Penn studying CIS + MATH. In my free time I can be found playing with my cat, practicing guitar, reading or sleeping ;)",
"hometown": "Nanjing, China",
"team": "Penn Mobile",
"roles": [
"Backend Engineer"
"teamRoles": [
{
"team": "Penn Mobile",
"roles": ["Backend Engineer"]
}
],
"photo": "https://i.imgur.com/S1kfAT4.jpg",
"linkedin": "https://www.linkedin.com/in/anni-pan-17b95b179/",
@@ -17,4 +19,4 @@
"alumnus": true,
"graduation_year": 2023,
"job": null
}
}
8 changes: 6 additions & 2 deletions src/json/alumni/armaant.json
Original file line number Diff line number Diff line change
@@ -5,8 +5,12 @@
"pennkey": "armaant",
"bio": "Hi, I'm Armaan! I'm studying computer science and finance and am the Team Lead for [Platform](https://platform.pennlabs.org/). I'm super interested in Sysadmin and DevOps. If you want to know more about me or any of my recent projects, check out [my website](https://armaan.tobaccowalla.com/)!",
"hometown": "Upper Saddle River, NJ",
"team": "Platform",
"roles": ["Director Emeritus", "Team Lead", "Backend Engineer", "DevOps"],
"teamRoles": [
{
"team": "Platform",
"roles": ["Director Emeritus", "Team Lead", "Backend Engineer", "DevOps"]
}
],
"photo": "https://i.imgur.com/wDkP3rs.jpg",
"linkedin": "https://www.linkedin.com/in/tobaccowallaa/",
"website": "https://armaan.tobaccowalla.com",
10 changes: 6 additions & 4 deletions src/json/alumni/astrike.json
Original file line number Diff line number Diff line change
@@ -5,9 +5,11 @@
"school": "Engineering",
"bio": "Backend Dev on Penn mobile, CIS Major 2023 :)",
"hometown": "Johannesburg, South Africa",
"team": "Penn Mobile",
"roles": [
"Backend Engineer"
"teamRoles": [
{
"team": "Penn Mobile",
"roles": ["Backend Engineer"]
}
],
"photo": "https://i.imgur.com/lXMeM7y.jpg",
"linkedin": null,
@@ -17,4 +19,4 @@
"alumnus": true,
"graduation_year": 2023,
"job": null
}
}
10 changes: 6 additions & 4 deletions src/json/alumni/avnia.json
Original file line number Diff line number Diff line change
@@ -5,9 +5,11 @@
"school": "Engineering",
"bio": "I'm a sophomore studying Comp + Cog Sci and hopefully minoring in Creative Writing. I love movies, food, and playing obscure board games with my siblings :)",
"hometown": "New York City",
"team": "Penn Courses",
"roles": [
"Designer"
"teamRoles": [
{
"team": "Penn Courses",
"roles": ["Designer"]
}
],
"photo": "https://i.imgur.com/V4RclNb.png",
"linkedin": null,
@@ -17,4 +19,4 @@
"alumnus": true,
"graduation_year": 2022,
"job": null
}
}
9 changes: 6 additions & 3 deletions src/json/alumni/bqle.json
Original file line number Diff line number Diff line change
@@ -5,8 +5,12 @@
"school": "Engineering",
"bio": "Hi! I'm a freshman from Vietnam and I'm a backend engineer for OHQ. In my freetime, I like to watch movie summaries and take long walks",
"hometown": "Ho Chi Minh City, Vietnam",
"team": "Office Hours Queue",
"roles": ["Backend Engineer"],
"teamRoles": [
{
"team": "Office Hours Queue",
"roles": ["Backend Engineer"]
}
],
"photo": "https://i.imgur.com/RfPYyuL.jpg",
"linkedin": "https://www.linkedin.com/in/bqle/",
"website": "",
@@ -16,4 +20,3 @@
"graduation_year": 2025,
"job": null
}

8 changes: 6 additions & 2 deletions src/json/alumni/brandw.json
Original file line number Diff line number Diff line change
@@ -5,8 +5,12 @@
"school": "Engineering & Wharton",
"bio": "Hi y’all, I’m Brandon! I’m a freshman studying M&T, and I’m working on DevOps this year. I also love hiking, tennis, and playing Avalon and Catan with friends!",
"hometown": "Plano, TX",
"team": "Platform",
"roles": ["DevOps"],
"teamRoles": [
{
"team": "Platform",
"roles": ["DevOps"]
}
],
"photo": "https://i.imgur.com/x0Qowwv.jpg",
"linkedin": "https://www.linkedin.com/in/brandonzwang/",
"website": "https://www.brandonwang.com/",
11 changes: 6 additions & 5 deletions src/json/alumni/cbaile.json
Original file line number Diff line number Diff line change
@@ -5,10 +5,11 @@
"pennkey": "cbaile",
"bio": "Hi,I am Peter studying Computer Science.",
"hometown": "Hong Kong",
"team": "Office Hours Queue",
"roles": [
"Backend Engineer",
"Frontend Engineer"
"teamRoles": [
{
"team": "Office Hours Queue",
"roles": ["Backend Engineer", "Frontend Engineer"]
}
],
"photo": "https://i.imgur.com/LLPmYNK.jpg",
"linkedin": "https://www.linkedin.com/in/peter-chen-ba7847153/",
@@ -18,4 +19,4 @@
"alumnus": true,
"graduation_year": null,
"job": null
}
}
8 changes: 6 additions & 2 deletions src/json/alumni/ccabo.json
Original file line number Diff line number Diff line change
@@ -5,8 +5,12 @@
"pennkey": "ccabo",
"bio": "I'm a senior studying Computer Science and Management of Entrepreneurship and Innovation. I'm passionate for building products which people enjoy using and learn from. In my free time I like working out, learning new things, and exploring new places ?",
"hometown": "Wellesley, MA",
"team": "Penn Basics",
"roles": ["Team Lead", "Frontend Engineer", "Director Emeritus"],
"teamRoles": [
{
"team": "Penn Basics",
"roles": ["Team Lead", "Frontend Engineer", "Director Emeritus"]
}
],
"photo": "https://i.imgur.com/3yQizZb.jpg",
"linkedin": "https://www.linkedin.com/in/cameroncabo",
"website": "https://www.cameroncabo.com",
8 changes: 6 additions & 2 deletions src/json/alumni/ccunning.json
Original file line number Diff line number Diff line change
@@ -5,8 +5,12 @@
"pennkey": "ccunning",
"bio": "I'm a back-end developer with Penn Courses, working mainly on the Penn Course Alert refresh and Penn Course Plan. I'm studying Computer Science at SEAS and my other academic interests include mathematics, economics, game theory, physics, design thinking, and engineering. In my free time I love biking, sailing, and KSP.",
"hometown": "New York, NY",
"team": "Penn Courses",
"roles": ["Backend Engineer"],
"teamRoles": [
{
"team": "Penn Courses",
"roles": ["Backend Engineer"]
}
],
"photo": "https://i.imgur.com/qf46nbE.jpg",
"linkedin": "https://www.linkedin.com/in/charles-cunningham-049a81193/",
"website": "https://www.charleycunningham.com",
Loading