Skip to content

Commit

Permalink
Merge pull request #727 from opencollective/feature/app-management
Browse files Browse the repository at this point in the history
App Management
  • Loading branch information
znarf authored Oct 5, 2018
2 parents b70d16f + 76e32de commit 622999d
Show file tree
Hide file tree
Showing 9 changed files with 805 additions and 11 deletions.
43 changes: 37 additions & 6 deletions src/components/TopBarProfileMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class TopBarProfileMenu extends React.Component {
id: 'menu.transactions',
defaultMessage: 'transactions',
},
'menu.applications': {
id: 'menu.applications',
defaultMessage: 'applications',
},
});
}

Expand Down Expand Up @@ -196,7 +200,7 @@ class TopBarProfileMenu extends React.Component {
/>
</P>
<Container height="0.1rem" bg="#E6E6E6" width={1} minWidth={50} />
<Link route="/create">
<Link route="/create" passHref>
<StyledLink
border="1px solid #D5DAE0"
borderRadius="20px"
Expand All @@ -221,7 +225,7 @@ class TopBarProfileMenu extends React.Component {
'collective.slug',
)}`}
>
<Link route={`/${get(membership, 'collective.slug')}`}>
<Link route={`/${get(membership, 'collective.slug')}`} passHref>
<StyledLink
title={this.tooltip(membership)}
color="#494D52"
Expand Down Expand Up @@ -270,7 +274,7 @@ class TopBarProfileMenu extends React.Component {
/>
</P>
<Container height="0.1rem" bg="#E6E6E6" width={1} minWidth={50} />
<Link route="/organizations/new">
<Link route="/organizations/new" passHref>
<StyledLink
border="1px solid #D5DAE0"
borderRadius="20px"
Expand All @@ -295,7 +299,7 @@ class TopBarProfileMenu extends React.Component {
'collective.slug',
)}`}
>
<Link route={`/${get(membership, 'collective.slug')}`}>
<Link route={`/${get(membership, 'collective.slug')}`} passHref>
<StyledLink
title={this.tooltip(membership)}
color="#494D52"
Expand Down Expand Up @@ -348,7 +352,11 @@ class TopBarProfileMenu extends React.Component {
</P>
<Box is="ul" p={0} my={2}>
<ListItem py={1}>
<Link route="collective" params={{ slug: LoggedInUser.username }}>
<Link
route="collective"
params={{ slug: LoggedInUser.username }}
passHref
>
<StyledLink
color="#494D52"
fontSize="1.2rem"
Expand All @@ -365,6 +373,7 @@ class TopBarProfileMenu extends React.Component {
<Link
route="subscriptions"
params={{ collectiveSlug: LoggedInUser.username }}
passHref
>
<StyledLink
color="#494D52"
Expand All @@ -382,6 +391,7 @@ class TopBarProfileMenu extends React.Component {
<Link
route="transactions"
params={{ collectiveSlug: LoggedInUser.username }}
passHref
>
<StyledLink
color="#494D52"
Expand All @@ -394,6 +404,23 @@ class TopBarProfileMenu extends React.Component {
</StyledLink>
</Link>
</ListItem>
<ListItem py={1}>
<Link
route="applications"
params={{ collectiveSlug: LoggedInUser.username }}
passHref
>
<StyledLink
color="#494D52"
fontSize="1.2rem"
fontFamily="montserratlight, arial"
>
{capitalize(
intl.formatMessage(this.messages['menu.applications']),
)}
</StyledLink>
</Link>
</ListItem>
<ListItem py={1}>
<StyledLink
color="#494D52"
Expand Down Expand Up @@ -498,7 +525,11 @@ class TopBarProfileMenu extends React.Component {
)}

{status === 'loggedout' && (
<Link route="signin" params={{ next: this.redirectAfterSignin }}>
<Link
route="signin"
params={{ next: this.redirectAfterSignin }}
passHref
>
<StyledLink
border="1px solid #D5DAE0"
borderRadius="20px"
Expand Down
32 changes: 32 additions & 0 deletions src/graphql/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,38 @@ const deleteCollectiveQuery = gql`
}
`;

export const createApplicationMutation = gql`
mutation createApplication($application: ApplicationInput!) {
createApplication(application: $application) {
id
name
description
callbackUrl
clientId
clientSecret
}
}
`;

export const updateApplicationMutation = gql`
mutation updateApplication($id: String!, $application: ApplicationInput!) {
updateApplication(id: $id, application: $application) {
id
name
description
callbackUrl
}
}
`;

export const deleteApplicationMutation = gql`
mutation deleteApplication($id: String!) {
deleteApplication(id: $id) {
id
}
}
`;

export const addCreateOrderMutation = graphql(createOrderQuery, {
props: ({ mutate }) => ({
createOrder: order => mutate({ variables: { order } }),
Expand Down
20 changes: 20 additions & 0 deletions src/graphql/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,26 @@ export const searchCollectivesQuery = gql`
}
`;

export const getCollectiveApplicationsQuery = gql`
query Collective($slug: String) {
Collective(slug: $slug) {
id
... on User {
applications {
id
type
name
description
callbackUrl
apiKey
clientId
clientSecret
}
}
}
}
`;

export const addCollectiveData = graphql(getCollectiveQuery);
export const addCollectiveCoverData = graphql(getCollectiveCoverQuery);
export const addCollectiveToEditData = graphql(getCollectiveToEditQuery);
Expand Down
41 changes: 36 additions & 5 deletions src/graphql/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
# source: http://localhost:3000/api/graphql
# timestamp: Thu Sep 20 2018 12:38:04 GMT+0200 (Central European Summer Time)
# source: http://localhost:3000/api/graphql/v1
# timestamp: Mon Oct 01 2018 15:10:59 GMT+0200 (Central European Summer Time)

"""Application model"""
type Application {
id: Int
type: ApplicationType
name: String
description: String
apiKey: String
clientId: String
clientSecret: String
callbackUrl: String
}

"""Input type for Application"""
input ApplicationInput {
type: ApplicationType!
name: String
description: String
callbackUrl: String
}

"""All application types"""
enum ApplicationType {
API_KEY
OAUTH
}

"""Breakdown of backers per type (ANY/USER/ORGANIZATION/COLLECTIVE)"""
type BackersStatsType {
id: Int
Expand Down Expand Up @@ -733,9 +742,30 @@ type Mutation {
refundTransaction(id: Int!): Transaction
addFundsToOrg(totalAmount: Int!, CollectiveId: Int!, HostCollectiveId: Int!, description: String): PaymentMethodType
createApplication(application: ApplicationInput!): Application
updateApplication(id: Int!, application: ApplicationInput!): Application
deleteApplication(id: Int!): Application
createPaymentMethod(type: String!, amount: Int!, currency: String!, CollectiveId: Int!, PaymentMethodId: Int, description: String, expiryDate: String): PaymentMethodType
updateApplication(id: String!, application: ApplicationInput!): Application
deleteApplication(id: String!): Application
createPaymentMethod(
type: String!
amount: Int!
currency: String!

"""
Limit this payment method to make donations to collectives having those tags
"""
limitedToTags: [String]

"""Limit this payment method to make donations to those collectives"""
limitedToCollectiveIds: [Int]

"""
Limit this payment method to make donations to the collectives hosted by those hosts
"""
limitedToHostCollectiveIds: [Int]
CollectiveId: Int!
PaymentMethodId: Int
description: String
expiryDate: String
): PaymentMethodType
claimPaymentMethod(code: String!, user: UserInputType): PaymentMethodType
claimCollective(id: Int!): CollectiveInterface
}
Expand Down Expand Up @@ -1071,6 +1101,7 @@ type PaymentMethodType {
collective: CollectiveInterface
limitedToTags: JSON
limitedToCollectiveIds: [Int]
limitedToHostCollectiveIds: [Int]
orders(
"""Only returns orders that have an active subscription (monthly/yearly)"""
hasActiveSubscription: Boolean
Expand Down
1 change: 1 addition & 0 deletions src/pages/__tests__/__snapshots__/search.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3490,6 +3490,7 @@ exports[`Search Page renders error message 1`] = `
color="#3385FF"
display="inline-block"
fontSize="1.4rem"
href="/signin?next=%2F"
onClick={[Function]}
>
<span>
Expand Down
Loading

0 comments on commit 622999d

Please sign in to comment.