Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: implement multi-org template gallery#13784

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jaaydenh merged 25 commits intomainfrommulti-org-template-gallery
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
25 commits
Select commitHold shift + click to select a range
0a5c431
feat: initial changes for multi-org templates page
jaaydenhJul 1, 2024
6f96fee
feat: add TemplateCard component
jaaydenhJul 2, 2024
51ebb67
feat: add component stories
jaaydenhJul 3, 2024
a0effc6
chore: update template query naming
jaaydenhJul 3, 2024
be37085
fix: fix formatting
jaaydenhJul 3, 2024
5649166
feat: template card interaction and navigation
jaaydenhJul 8, 2024
3ea3aa2
fix: copy updates
jaaydenhJul 8, 2024
f17a0c3
chore: update TemplateFilter type to include FilterQuery
jaaydenhJul 9, 2024
0077db0
chore: update typesGenerated.ts
jaaydenhJul 9, 2024
461202e
feat: update template filter api logic
jaaydenhJul 9, 2024
66e02fb
fix: fix format
jaaydenhJul 11, 2024
369c59f
fix: get activeOrg
jaaydenhJul 11, 2024
c41cdc4
fix: add format annotation
jaaydenhJul 11, 2024
7f5d35e
chore: use organization display name
jaaydenhJul 11, 2024
6e2a6d8
feat: client side org filtering
jaaydenhJul 15, 2024
978c047
fix: use org display name
jaaydenhJul 15, 2024
aaed038
fix: add ExactName
jaaydenhJul 15, 2024
8d84ad9
feat: show orgs filter only if more than 1 org
jaaydenhJul 15, 2024
a1c6169
chore: updates for PR review
jaaydenhJul 16, 2024
15542c0
fix: fix format
jaaydenhJul 16, 2024
8f4c56f
chore: add story for multi org
jaaydenhJul 16, 2024
a282bac
fix: aggregate templates by organization id
jaaydenhJul 17, 2024
b092644
fix: fix format
jaaydenhJul 17, 2024
32376e6
fix: check org count
jaaydenhJul 17, 2024
801138a
fix: update ExactName type
jaaydenhJul 17, 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
PrevPrevious commit
NextNext commit
chore: update template query naming
  • Loading branch information
@jaaydenh
jaaydenh committedJul 17, 2024
commita0effc6dc9a8dcdfc26cf15c0c5ddb5303ebe115
21 changes: 20 additions & 1 deletionsite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -578,7 +578,7 @@ class ApiMethods {
return response.data;
};

getTemplates = async (
getTemplatesByOrganizationId = async (
organizationId: string,
options?: TemplateOptions,
): Promise<TypesGen.Template[]> => {
Expand All@@ -598,6 +598,25 @@ class ApiMethods {
return response.data;
};

getTemplates = async (
options?: TemplateOptions,
): Promise<TypesGen.Template[]> => {
const params: Record<string, string> = {};
if (options?.deprecated !== undefined) {
// Just want to check if it isn't undefined. If it has
// a boolean value, convert it to a string and include
// it as a param.
params["deprecated"] = String(options.deprecated);
}

const response = await this.axios.get<TypesGen.Template[]>(
`/api/v2/templates`,
{ params },
);

return response.data;
};

getTemplateByName = async (
organizationId: string,
name: string,
Expand Down
22 changes: 17 additions & 5 deletionssite/src/api/queries/templates.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,16 +30,28 @@ export const templateByName = (
};
};

constgetTemplatesQueryKey = (organizationId: string, deprecated?: boolean) => [
constgetTemplatesByOrganizationIdQueryKey = (organizationId: string, deprecated?: boolean) => [
organizationId,
"templates",
deprecated,
];

export consttemplates = (organizationId: string, deprecated?: boolean) => {
export consttemplatesByOrganizationId = (organizationId: string, deprecated?: boolean) => {
return {
queryKey: getTemplatesQueryKey(organizationId, deprecated),
queryFn: () => API.getTemplates(organizationId, { deprecated }),
queryKey: getTemplatesByOrganizationIdQueryKey(organizationId, deprecated),
queryFn: () => API.getTemplatesByOrganizationId(organizationId, { deprecated }),
};
};

const getTemplatesQueryKey = (deprecated?: boolean) => [
"templates",
deprecated,
];

export const templates = (deprecated?: boolean) => {
return {
queryKey: getTemplatesQueryKey(deprecated),
queryFn: () => API.getTemplates({ deprecated }),
};
};

Expand DownExpand Up@@ -92,7 +104,7 @@ export const setGroupRole = (

export const templateExamples = (organizationId: string) => {
return {
queryKey: [...getTemplatesQueryKey(organizationId), "examples"],
queryKey: [...getTemplatesByOrganizationIdQueryKey(organizationId), "examples"],
queryFn: () => API.getTemplateExamples(organizationId),
};
};
Expand Down
18 changes: 8 additions & 10 deletionssite/src/pages/TemplatesPage/TemplatesPage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
import type { FC } from "react";
import { Helmet } from "react-helmet-async";
import { useQuery } from "react-query";
import { templateExamples, templates } from "api/queries/templates";
import { myOrganizations } from "api/queries/users";
import { templateExamples, templatesByOrganizationId, templates, } from "api/queries/templates";
import { useAuthenticated } from "contexts/auth/RequireAuth";
import { useDashboard } from "modules/dashboard/useDashboard";
import { pageTitle } from "utils/page";
import { TemplatesPageView } from "./TemplatesPageView";
import {TemplatesPageViewV2 } from "./TemplatesPageViewV2";
import { TemplatesPageViewas MultiOrgTemplatesPageView} from "./MultiOrgTemplatePage/TemplatesPageView";
import {TemplatesPageView } from "./TemplatePage/TemplatesPageView";

export const TemplatesPage: FC = () => {
const { permissions } = useAuthenticated();
const { organizationId, experiments } = useDashboard();

constorganizationsQuery = useQuery(myOrganizations());
const templatesQuery = useQuery(templates(organizationId));
consttemplatesByOrganizationIdQuery = useQuery(templatesByOrganizationId(organizationId));
const templatesQuery = useQuery(templates());
const examplesQuery = useQuery({
...templateExamples(organizationId),
enabled: permissions.createTemplates,
});
const error =templatesQuery.error || examplesQuery.error ||organizationsQuery.error;
const error =templatesByOrganizationIdQuery.error || examplesQuery.error ||templatesQuery.error;
const multiOrgExperimentEnabled = experiments.includes("multi-organization");

return (
Expand All@@ -28,19 +27,18 @@ export const TemplatesPage: FC = () => {
<title>{pageTitle("Templates")}</title>
</Helmet>
{multiOrgExperimentEnabled ? (
<TemplatesPageViewV2
<MultiOrgTemplatesPageView
error={error}
canCreateTemplates={permissions.createTemplates}
examples={examplesQuery.data}
templates={templatesQuery.data}
organizations={organizationsQuery.data}
/>
) : (
<TemplatesPageView
error={error}
canCreateTemplates={permissions.createTemplates}
examples={examplesQuery.data}
templates={templatesQuery.data}
templates={templatesByOrganizationIdQuery.data}
/>
)}
</>
Expand Down
97 changes: 0 additions & 97 deletionssite/src/pages/TemplatesPage/TemplatesPageView.stories.tsx
View file
Open in desktop

This file was deleted.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp