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

Charlesthebird/custom pages #99

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
bf08cb0
changelog
Charlesthebird Aug 27, 2024
b5d9274
changelog
Charlesthebird Aug 27, 2024
ac02085
added existing portal server teams and apps and admin features
Charlesthebird Sep 5, 2024
0b825ea
Delete projects/yarn.lock
Charlesthebird Sep 5, 2024
e378da5
updated changelog
Charlesthebird Sep 5, 2024
8f1d49d
api details page when logged out
Charlesthebird Sep 5, 2024
91016ae
empty page cleanup
Charlesthebird Sep 5, 2024
a9bc25c
small fix
Charlesthebird Sep 5, 2024
b0ad09a
Merge pull request #96 from solo-io/charlesthebird/existing-1-18-feat…
Worfle Sep 5, 2024
b707457
updated apps grid card styles to not include images.
Charlesthebird Sep 6, 2024
41a55f2
added simple empty state component. Updated landing page to not flick…
Charlesthebird Sep 9, 2024
3318f6e
wording
Charlesthebird Sep 9, 2024
77eb905
changelog
Charlesthebird Sep 9, 2024
f328599
empty state cleanup.
Charlesthebird Sep 9, 2024
8d78eb4
Merge pull request #97 from solo-io/charlesthebird/appsDocsLoadingFixes
Worfle Sep 9, 2024
7756c16
changelog
Charlesthebird Sep 10, 2024
e350dd6
Initial api keys section added. Still need post-creation modal.
Charlesthebird Sep 10, 2024
9c77118
updated empty state, added some instructions for empty states.
Charlesthebird Sep 11, 2024
6e3a336
empty data rename
Charlesthebird Sep 11, 2024
7ca428c
generate api key modal complete.
Charlesthebird Sep 11, 2024
ff7fa7a
Merge pull request #98 from solo-io/charlesthebird/appDetailsApiKeysS…
Charlesthebird Sep 11, 2024
4485944
changelog
Charlesthebird Sep 12, 2024
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
5 changes: 5 additions & 0 deletions changelog/v0.0.36/app-details-api-keys-section.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/solo-projects/issues/6881
description: >-
Adds an API keys section to the App Details page.
17 changes: 17 additions & 0 deletions changelog/v0.0.36/apps-docs-loading-fixes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/solo-projects/issues/6853
description: >-
Fixes flickering loading state on landing pages.
- type: FIX
issueLink: https://github.com/solo-io/solo-projects/issues/6852
description: >-
Adds docs setup information to API details page.
- type: FIX
issueLink: https://github.com/solo-io/solo-projects/issues/6851
description: >-
Removes placeholder images for apps.
- type: FIX
issueLink: https://github.com/solo-io/solo-projects/issues/6854
description: >-
Adds information when in a logged out empty state on private Portals.
5 changes: 5 additions & 0 deletions changelog/v0.0.36/custom-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/solo-projects/issues/6860
description: >-
Adds the ability for users to create custom pages that show up in the UI.
30 changes: 30 additions & 0 deletions changelog/v0.0.36/teams-page.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
changelog:
- type: NEW_FEATURE
issueLink: https://github.com/solo-io/solo-projects/issues/6808
description: >-
Adds the Teams page in to the GG version of the UI.
- type: NEW_FEATURE
issueLink: https://github.com/solo-io/solo-projects/issues/6809
description: >-
Adds the Team Details page in to the GG version of the UI.
- type: NEW_FEATURE
issueLink: https://github.com/solo-io/solo-projects/issues/6810
description: >-
Adds the Apps page in to the GG version of the UI.
- type: NEW_FEATURE
issueLink: https://github.com/solo-io/solo-projects/issues/6811
description: >-
Adds the App Details page in to the GG version of the UI.
- type: NEW_FEATURE
issueLink: https://github.com/solo-io/solo-projects/issues/6812
description: >-
Adds the Admin Subscriptions page in to the GG version of the UI.
- type: NEW_FEATURE
issueLink: https://github.com/solo-io/solo-projects/issues/6813
description: >-
Adds the Admin Teams page in to the GG version of the UI.
- type: NEW_FEATURE
issueLink: https://github.com/solo-io/solo-projects/issues/6814
description: >-
Adds in an edit button + modal to the Apps + Teams Details pages
(for both admins + non-admins) on the GG version of the UI.
10 changes: 10 additions & 0 deletions projects/ui/src/Apis/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ export type App = {
teamId: string;
};

export type ApiKey = {
id: string;
createdAt: string;
updatedAt: string;
deletedAt: string;
apiKey: string;
name: string;
metadata: Record<string, string>;
};

export type Team = {
createdAt: string;
description: string;
Expand Down
78 changes: 59 additions & 19 deletions projects/ui/src/Apis/gg_hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import useSWRMutation from "swr/mutation";
import { AuthContext } from "../Context/AuthContext";
import { omitErrorMessageResponse } from "../Utility/utility";
import {
ApiKey,
ApiProductDetails,
ApiProductSummary,
ApiVersion,
Expand All @@ -19,15 +20,15 @@ import {
import { fetchJSON, useMultiSwrWithAuth, useSwrWithAuth } from "./utility";

//
// Queries
// region Queries
//

// User
// region User
export function useGetCurrentUser() {
return useSwrWithAuth<User>("/me");
}

// Apps
// region Apps + API Keys
export function useListAppsForTeam(team: Team) {
return useSwrWithAuth<App[]>(`/teams/${team.id}/apps`);
}
Expand Down Expand Up @@ -55,8 +56,11 @@ export function useListFlatAppsForTeamsOmitErrors(teams: Team[]) {
export function useGetAppDetails(id?: string) {
return useSwrWithAuth<App>(`/apps/${id}`);
}
export function useListApiKeysForApp(appId: string) {
return useSwrWithAuth<ApiKey[]>(`/apps/${appId}/api-keys`);
}

// Teams
// region Teams
const TEAMS_SWR_KEY = "teams";
export function useListTeams() {
return useSwrWithAuth<Team[]>(`/teams`);
Expand All @@ -68,7 +72,7 @@ export function useGetTeamDetails(id?: string) {
return useSwrWithAuth<Team>(`/teams/${id}`);
}

// Api Products
// region API Products
export function useListApiProducts() {
return useSwrWithAuth<ApiProductSummary[]>("/api-products");
}
Expand All @@ -79,7 +83,7 @@ export function useGetApiProductVersions(id?: string) {
return useSwrWithAuth<ApiVersion[]>(`/api-products/${id}/versions`);
}

// Subscriptions
// region Subscriptions
// this is an admin endpoint
export function useListSubscriptionsForStatus(status: SubscriptionStatus) {
const swrResponse = useSwrWithAuth<Subscription[] | SubscriptionsListError>(
Expand Down Expand Up @@ -115,7 +119,7 @@ export function useListSubscriptionsForApps(apps: App[]) {
}

//
// Mutations
// region Mutations
//

const getLatestAuthHeaders = (latestAccessToken: string | undefined) => {
Expand All @@ -129,7 +133,7 @@ const getLatestAuthHeaders = (latestAccessToken: string | undefined) => {
type MutationWithArgs<T> = { arg: T };

// ------------------------ //
// Create Team
// region Create Team

type CreateTeamParams = MutationWithArgs<{ name: string; description: string }>;

Expand All @@ -149,7 +153,7 @@ export function useCreateTeamMutation() {
}

// ------------------------ //
// Create Team Member
// region Create Team Member

type AddTeamMemberParams = MutationWithArgs<{ email: string; teamId: string }>;

Expand All @@ -169,7 +173,7 @@ export function useAddTeamMemberMutation() {
}

// ------------------------ //
// Remove Team Member
// region Remove Team Member

type AdminRemoveTeamMemberParams = MutationWithArgs<{
teamId: string;
Expand All @@ -194,7 +198,7 @@ export function useRemoveTeamMemberMutation() {
}

// ------------------------ //
// Create App
// region Create App

type CreateAppParams = MutationWithArgs<{ name: string; description: string }>;

Expand All @@ -220,7 +224,7 @@ export function useCreateAppMutation(teamId: string | undefined) {
}

// ------------------------ //
// Update App
// region Update App

type UpdateAppParams = MutationWithArgs<{
appId: string;
Expand All @@ -247,7 +251,7 @@ export function useUpdateAppMutation() {
}

// ------------------------ //
// Update Team
// region Update Team

type UpdateTeamParams = MutationWithArgs<{
teamId: string;
Expand All @@ -272,7 +276,7 @@ export function useUpdateTeamMutation() {
}

// ------------------------ //
// Create App and Subscription
// region Create App and Subscription

type CreateAppAndSubscriptionParams = MutationWithArgs<{
appName: string;
Expand Down Expand Up @@ -315,7 +319,7 @@ export function useCreateAppAndSubscriptionMutation() {
}

// ------------------------ //
// Create Subscription
// region Create Subscription

type CreateSubscriptionParams = MutationWithArgs<{
apiProductId: string;
Expand Down Expand Up @@ -344,7 +348,7 @@ export function useCreateSubscriptionMutation(appId: string) {
}

// -------------------------------- //
// (Admin) Approve/Reject Subscription
// region (Admin) Approve/Reject Subscription

type UpdateSubscriptionParams = MutationWithArgs<{
subscription: Subscription;
Expand Down Expand Up @@ -387,7 +391,7 @@ export function useAdminRejectSubscriptionMutation() {
}

// -------------------------------- //
// Delete Subscription
// region Delete Subscription

export function useDeleteSubscriptionMutation() {
const { latestAccessToken } = useContext(AuthContext);
Expand All @@ -406,7 +410,7 @@ export function useDeleteSubscriptionMutation() {
}

// -------------------------------- //
// Delete Team
// region Delete Team

type DeleteTeamParams = MutationWithArgs<{ teamId: string }>;

Expand All @@ -424,7 +428,7 @@ export function useDeleteTeamMutation() {
}

// -------------------------------- //
// Delete App
// region Delete App

type DeleteAppParams = MutationWithArgs<{ appId: string }>;

Expand All @@ -440,3 +444,39 @@ export function useDeleteAppMutation() {
};
return useSWRMutation(`delete-team`, deleteApp);
}

// -------------------------------- //
// region Create API Key

type CreateApiKeyParams = MutationWithArgs<{ apiKeyName: string }>;

export function useCreateApiKeyMutation(appId: string) {
const { latestAccessToken } = useContext(AuthContext);
const createApiKey = async (_: string, { arg }: CreateApiKeyParams) => {
return await fetchJSON(`/apps/${appId}/api-keys`, {
method: "POST",
headers: getLatestAuthHeaders(latestAccessToken),
body: JSON.stringify(arg),
});
};
return useSWRMutation<ApiKey, any, string, CreateApiKeyParams["arg"]>(
`/apps/${appId}/api-keys`,
createApiKey
);
}

// -------------------------------- //
// region Delete API Key

type DeleteApiKeyParams = MutationWithArgs<{ apiKeyId: string }>;

export function useDeleteApiKeyMutation(appId: string) {
const { latestAccessToken } = useContext(AuthContext);
const deleteApiKey = async (_: string, { arg }: DeleteApiKeyParams) => {
await fetchJSON(`/api-keys/${arg.apiKeyId}`, {
method: "DELETE",
headers: getLatestAuthHeaders(latestAccessToken),
});
};
return useSWRMutation(`/apps/${appId}/api-keys`, deleteApiKey);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tabs } from "@mantine/core";
import { Code, Tabs } from "@mantine/core";
import { useEffect, useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import {
Expand All @@ -7,6 +7,7 @@ import {
ApiVersionSchema,
} from "../../../Apis/api-types";
import { ContentWidthDiv } from "../../../Styles/ContentWidthHelpers";
import { EmptyData } from "../../Common/EmptyData";
import DocsTabContent from "./DocsTab/DocsTabContent";
import SchemaTabContent from "./SchemaTab/SchemaTabContent";

Expand Down Expand Up @@ -62,27 +63,35 @@ export function ApiProductDetailsPageBody({
*/}
<Tabs.List>
<Tabs.Tab value={apiProductDetailsTabValues.SPEC}>Spec</Tabs.Tab>
{includesDocumentation && (
<Tabs.Tab value={apiProductDetailsTabValues.DOCS}>Docs</Tabs.Tab>
)}
<Tabs.Tab value={apiProductDetailsTabValues.DOCS}>Docs</Tabs.Tab>
</Tabs.List>
{/*

Tab Content
*/}
<Tabs.Panel value={apiProductDetailsTabValues.SPEC} pt={"xl"}>
<SchemaTabContent
apiProduct={apiProduct}
apiProductVersions={apiProductVersions}
apiVersionSpec={apiVersionSpec}
selectedApiVersion={selectedApiVersion}
/>
</Tabs.Panel>
{includesDocumentation && (
<Tabs.Panel value={apiProductDetailsTabValues.DOCS} pt={"xl"}>
<Tabs.Panel value={apiProductDetailsTabValues.DOCS} pt={"xl"}>
{includesDocumentation ? (
<DocsTabContent selectedApiVersion={selectedApiVersion} />
</Tabs.Panel>
)}
) : (
<EmptyData title="No documentation found.">
<small>
You may add documentation for this API in the{" "}
<Code>
spec.versions[your-version].openapiMetadata.description
</Code>{" "}
field of this <Code>ApiProduct</Code> resource. Markdown is
supported.
</small>
</EmptyData>
)}
</Tabs.Panel>
</Tabs>
</ContentWidthDiv>
);
Expand Down
Loading