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

Commitb29246d

Browse files
committed
chore: update template query naming
1 parentb831390 commitb29246d

File tree

8 files changed

+49
-578
lines changed

8 files changed

+49
-578
lines changed

‎site/src/api/api.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ class ApiMethods {
556556
returnresponse.data;
557557
};
558558

559-
getTemplates=async(
559+
getTemplatesByOrganizationId=async(
560560
organizationId:string,
561561
options?:TemplateOptions,
562562
):Promise<TypesGen.Template[]>=>{
@@ -576,6 +576,25 @@ class ApiMethods {
576576
returnresponse.data;
577577
};
578578

579+
getTemplates=async(
580+
options?:TemplateOptions,
581+
):Promise<TypesGen.Template[]>=>{
582+
constparams:Record<string,string>={};
583+
if(options?.deprecated!==undefined){
584+
// Just want to check if it isn't undefined. If it has
585+
// a boolean value, convert it to a string and include
586+
// it as a param.
587+
params["deprecated"]=String(options.deprecated);
588+
}
589+
590+
constresponse=awaitthis.axios.get<TypesGen.Template[]>(
591+
`/api/v2/templates`,
592+
{ params},
593+
);
594+
595+
returnresponse.data;
596+
};
597+
579598
getTemplateByName=async(
580599
organizationId:string,
581600
name:string,

‎site/src/api/queries/templates.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,28 @@ export const templateByName = (
3030
};
3131
};
3232

33-
constgetTemplatesQueryKey=(organizationId:string,deprecated?:boolean)=>[
33+
constgetTemplatesByOrganizationIdQueryKey=(organizationId:string,deprecated?:boolean)=>[
3434
organizationId,
3535
"templates",
3636
deprecated,
3737
];
3838

39-
exportconsttemplates=(organizationId:string,deprecated?:boolean)=>{
39+
exportconsttemplatesByOrganizationId=(organizationId:string,deprecated?:boolean)=>{
4040
return{
41-
queryKey:getTemplatesQueryKey(organizationId,deprecated),
42-
queryFn:()=>API.getTemplates(organizationId,{ deprecated}),
41+
queryKey:getTemplatesByOrganizationIdQueryKey(organizationId,deprecated),
42+
queryFn:()=>API.getTemplatesByOrganizationId(organizationId,{ deprecated}),
43+
};
44+
};
45+
46+
constgetTemplatesQueryKey=(deprecated?:boolean)=>[
47+
"templates",
48+
deprecated,
49+
];
50+
51+
exportconsttemplates=(deprecated?:boolean)=>{
52+
return{
53+
queryKey:getTemplatesQueryKey(deprecated),
54+
queryFn:()=>API.getTemplates({ deprecated}),
4355
};
4456
};
4557

@@ -92,7 +104,7 @@ export const setGroupRole = (
92104

93105
exportconsttemplateExamples=(organizationId:string)=>{
94106
return{
95-
queryKey:[...getTemplatesQueryKey(organizationId),"examples"],
107+
queryKey:[...getTemplatesByOrganizationIdQueryKey(organizationId),"examples"],
96108
queryFn:()=>API.getTemplateExamples(organizationId),
97109
};
98110
};

‎site/src/pages/TemplatesPage/TemplatesPage.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
importtype{FC}from"react";
22
import{Helmet}from"react-helmet-async";
33
import{useQuery}from"react-query";
4-
import{templateExamples,templates}from"api/queries/templates";
5-
import{myOrganizations}from"api/queries/users";
4+
import{templateExamples,templatesByOrganizationId,templates,}from"api/queries/templates";
65
import{useAuthenticated}from"contexts/auth/RequireAuth";
76
import{useDashboard}from"modules/dashboard/useDashboard";
87
import{pageTitle}from"utils/page";
9-
import{TemplatesPageView}from"./TemplatesPageView";
10-
import{TemplatesPageViewV2}from"./TemplatesPageViewV2";
8+
import{TemplatesPageViewasMultiOrgTemplatesPageView}from"./MultiOrgTemplatePage/TemplatesPageView";
9+
import{TemplatesPageView}from"./TemplatePage/TemplatesPageView";
1110

1211
exportconstTemplatesPage:FC=()=>{
1312
const{ permissions}=useAuthenticated();
1413
const{ organizationId, experiments}=useDashboard();
1514

16-
constorganizationsQuery=useQuery(myOrganizations());
17-
consttemplatesQuery=useQuery(templates(organizationId));
15+
consttemplatesByOrganizationIdQuery=useQuery(templatesByOrganizationId(organizationId));
16+
consttemplatesQuery=useQuery(templates());
1817
constexamplesQuery=useQuery({
1918
...templateExamples(organizationId),
2019
enabled:permissions.createTemplates,
2120
});
22-
consterror=templatesQuery.error||examplesQuery.error||organizationsQuery.error;
21+
consterror=templatesByOrganizationIdQuery.error||examplesQuery.error||templatesQuery.error;
2322
constmultiOrgExperimentEnabled=experiments.includes("multi-organization");
2423

2524
return(
@@ -28,19 +27,18 @@ export const TemplatesPage: FC = () => {
2827
<title>{pageTitle("Templates")}</title>
2928
</Helmet>
3029
{multiOrgExperimentEnabled ?(
31-
<TemplatesPageViewV2
30+
<MultiOrgTemplatesPageView
3231
error={error}
3332
canCreateTemplates={permissions.createTemplates}
3433
examples={examplesQuery.data}
3534
templates={templatesQuery.data}
36-
organizations={organizationsQuery.data}
3735
/>
3836
) :(
3937
<TemplatesPageView
4038
error={error}
4139
canCreateTemplates={permissions.createTemplates}
4240
examples={examplesQuery.data}
43-
templates={templatesQuery.data}
41+
templates={templatesByOrganizationIdQuery.data}
4442
/>
4543
)}
4644
</>

‎site/src/pages/TemplatesPage/TemplatesPageView.stories.tsx

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp