Skip to content

Commit 7125b37

Browse files
authored
feat(site): allow selecting an organization when creating a template (#14061)
1 parent a27ac30 commit 7125b37

File tree

72 files changed

+1058
-578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1058
-578
lines changed

site/e2e/expectUrl.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ export const expectUrl = expect.extend({
2323
pass,
2424
actual,
2525
expected,
26-
message: () => "The page does not have the expected URL pathname.",
26+
message: () =>
27+
"The page does not have the expected URL pathname.\n" +
28+
`Expected: ${this.isNot ? "not" : ""}${this.utils.printExpected(
29+
expected,
30+
)}\n` +
31+
`Actual: ${this.utils.printReceived(actual)}`,
2732
};
2833
},
2934
});

site/src/api/api.ts

Lines changed: 90 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -516,73 +516,97 @@ class ApiMethods {
516516
return response.data;
517517
};
518518

519+
/**
520+
* @param organization Can be the organization's ID or name
521+
*/
519522
updateOrganization = async (
520-
organizationId: string,
523+
organization: string,
521524
params: TypesGen.UpdateOrganizationRequest,
522525
) => {
523526
const response = await this.axios.patch<TypesGen.Organization>(
524-
`/api/v2/organizations/${organizationId}`,
527+
`/api/v2/organizations/${organization}`,
525528
params,
526529
);
527530
return response.data;
528531
};
529532

530-
deleteOrganization = async (organizationId: string) => {
533+
/**
534+
* @param organization Can be the organization's ID or name
535+
*/
536+
deleteOrganization = async (organization: string) => {
531537
await this.axios.delete<TypesGen.Organization>(
532-
`/api/v2/organizations/${organizationId}`,
538+
`/api/v2/organizations/${organization}`,
533539
);
534540
};
535541

542+
/**
543+
* @param organization Can be the organization's ID or name
544+
*/
536545
getOrganization = async (
537-
organizationId: string,
546+
organization: string,
538547
): Promise<TypesGen.Organization> => {
539548
const response = await this.axios.get<TypesGen.Organization>(
540-
`/api/v2/organizations/${organizationId}`,
549+
`/api/v2/organizations/${organization}`,
541550
);
542551

543552
return response.data;
544553
};
545554

546-
getOrganizationMembers = async (organizationId: string) => {
555+
/**
556+
* @param organization Can be the organization's ID or name
557+
*/
558+
getOrganizationMembers = async (organization: string) => {
547559
const response = await this.axios.get<
548560
TypesGen.OrganizationMemberWithUserData[]
549-
>(`/api/v2/organizations/${organizationId}/members`);
561+
>(`/api/v2/organizations/${organization}/members`);
550562

551563
return response.data;
552564
};
553565

554-
getOrganizationRoles = async (organizationId: string) => {
566+
/**
567+
* @param organization Can be the organization's ID or name
568+
*/
569+
getOrganizationRoles = async (organization: string) => {
555570
const response = await this.axios.get<TypesGen.AssignableRoles[]>(
556-
`/api/v2/organizations/${organizationId}/members/roles`,
571+
`/api/v2/organizations/${organization}/members/roles`,
557572
);
558573

559574
return response.data;
560575
};
561576

577+
/**
578+
* @param organization Can be the organization's ID or name
579+
*/
562580
updateOrganizationMemberRoles = async (
563-
organizationId: string,
581+
organization: string,
564582
userId: string,
565583
roles: TypesGen.SlimRole["name"][],
566584
): Promise<TypesGen.User> => {
567585
const response = await this.axios.put<TypesGen.User>(
568-
`/api/v2/organizations/${organizationId}/members/${userId}/roles`,
586+
`/api/v2/organizations/${organization}/members/${userId}/roles`,
569587
{ roles },
570588
);
571589

572590
return response.data;
573591
};
574592

575-
addOrganizationMember = async (organizationId: string, userId: string) => {
593+
/**
594+
* @param organization Can be the organization's ID or name
595+
*/
596+
addOrganizationMember = async (organization: string, userId: string) => {
576597
const response = await this.axios.post<TypesGen.OrganizationMember>(
577-
`/api/v2/organizations/${organizationId}/members/${userId}`,
598+
`/api/v2/organizations/${organization}/members/${userId}`,
578599
);
579600

580601
return response.data;
581602
};
582603

583-
removeOrganizationMember = async (organizationId: string, userId: string) => {
604+
/**
605+
* @param organization Can be the organization's ID or name
606+
*/
607+
removeOrganizationMember = async (organization: string, userId: string) => {
584608
await this.axios.delete(
585-
`/api/v2/organizations/${organizationId}/members/${userId}`,
609+
`/api/v2/organizations/${organization}/members/${userId}`,
586610
);
587611
};
588612

@@ -601,8 +625,11 @@ class ApiMethods {
601625
return response.data;
602626
};
603627

628+
/**
629+
* @param organization Can be the organization's ID or name
630+
*/
604631
getTemplates = async (
605-
organizationId: string,
632+
organization: string,
606633
options?: TemplateOptions,
607634
): Promise<TypesGen.Template[]> => {
608635
const params: Record<string, string> = {};
@@ -614,19 +641,22 @@ class ApiMethods {
614641
}
615642

616643
const response = await this.axios.get<TypesGen.Template[]>(
617-
`/api/v2/organizations/${organizationId}/templates`,
644+
`/api/v2/organizations/${organization}/templates`,
618645
{ params },
619646
);
620647

621648
return response.data;
622649
};
623650

651+
/**
652+
* @param organization Can be the organization's ID or name
653+
*/
624654
getTemplateByName = async (
625-
organizationId: string,
655+
organization: string,
626656
name: string,
627657
): Promise<TypesGen.Template> => {
628658
const response = await this.axios.get<TypesGen.Template>(
629-
`/api/v2/organizations/${organizationId}/templates/${name}`,
659+
`/api/v2/organizations/${organization}/templates/${name}`,
630660
);
631661

632662
return response.data;
@@ -675,26 +705,32 @@ class ApiMethods {
675705
return response.data;
676706
};
677707

708+
/**
709+
* @param organization Can be the organization's ID or name
710+
*/
678711
getTemplateVersionByName = async (
679-
organizationId: string,
712+
organization: string,
680713
templateName: string,
681714
versionName: string,
682715
): Promise<TypesGen.TemplateVersion> => {
683716
const response = await this.axios.get<TypesGen.TemplateVersion>(
684-
`/api/v2/organizations/${organizationId}/templates/${templateName}/versions/${versionName}`,
717+
`/api/v2/organizations/${organization}/templates/${templateName}/versions/${versionName}`,
685718
);
686719

687720
return response.data;
688721
};
689722

723+
/**
724+
* @param organization Can be the organization's ID or name
725+
*/
690726
getPreviousTemplateVersionByName = async (
691-
organizationId: string,
727+
organization: string,
692728
templateName: string,
693729
versionName: string,
694730
) => {
695731
try {
696732
const response = await this.axios.get<TypesGen.TemplateVersion>(
697-
`/api/v2/organizations/${organizationId}/templates/${templateName}/versions/${versionName}/previous`,
733+
`/api/v2/organizations/${organization}/templates/${templateName}/versions/${versionName}/previous`,
698734
);
699735

700736
return response.data;
@@ -713,12 +749,15 @@ class ApiMethods {
713749
}
714750
};
715751

752+
/**
753+
* @param organization Can be the organization's ID or name
754+
*/
716755
createTemplateVersion = async (
717-
organizationId: string,
756+
organization: string,
718757
data: TypesGen.CreateTemplateVersionRequest,
719758
): Promise<TypesGen.TemplateVersion> => {
720759
const response = await this.axios.post<TypesGen.TemplateVersion>(
721-
`/api/v2/organizations/${organizationId}/templateversions`,
760+
`/api/v2/organizations/${organization}/templateversions`,
722761
data,
723762
);
724763

@@ -744,12 +783,15 @@ class ApiMethods {
744783
return response.data;
745784
};
746785

786+
/**
787+
* @param organization Can be the organization's ID or name
788+
*/
747789
createTemplate = async (
748-
organizationId: string,
790+
organization: string,
749791
data: TypesGen.CreateTemplateRequest,
750792
): Promise<TypesGen.Template> => {
751793
const response = await this.axios.post(
752-
`/api/v2/organizations/${organizationId}/templates`,
794+
`/api/v2/organizations/${organization}/templates`,
753795
data,
754796
);
755797

@@ -1480,31 +1522,40 @@ class ApiMethods {
14801522
return response.data;
14811523
};
14821524

1483-
getGroups = async (organizationId: string): Promise<TypesGen.Group[]> => {
1525+
/**
1526+
* @param organization Can be the organization's ID or name
1527+
*/
1528+
getGroups = async (organization: string): Promise<TypesGen.Group[]> => {
14841529
const response = await this.axios.get(
1485-
`/api/v2/organizations/${organizationId}/groups`,
1530+
`/api/v2/organizations/${organization}/groups`,
14861531
);
14871532

14881533
return response.data;
14891534
};
14901535

1536+
/**
1537+
* @param organization Can be the organization's ID or name
1538+
*/
14911539
createGroup = async (
1492-
organizationId: string,
1540+
organization: string,
14931541
data: TypesGen.CreateGroupRequest,
14941542
): Promise<TypesGen.Group> => {
14951543
const response = await this.axios.post(
1496-
`/api/v2/organizations/${organizationId}/groups`,
1544+
`/api/v2/organizations/${organization}/groups`,
14971545
data,
14981546
);
14991547
return response.data;
15001548
};
15011549

1550+
/**
1551+
* @param organization Can be the organization's ID or name
1552+
*/
15021553
getGroup = async (
1503-
organizationId: string,
1554+
organization: string,
15041555
groupName: string,
15051556
): Promise<TypesGen.Group> => {
15061557
const response = await this.axios.get(
1507-
`/api/v2/organizations/${organizationId}/groups/${groupName}`,
1558+
`/api/v2/organizations/${organization}/groups/${groupName}`,
15081559
);
15091560
return response.data;
15101561
};
@@ -1673,11 +1724,14 @@ class ApiMethods {
16731724
return response.data;
16741725
};
16751726

1727+
/**
1728+
* @param organization Can be the organization's ID or name
1729+
*/
16761730
getTemplateExamples = async (
1677-
organizationId: string,
1731+
organization: string,
16781732
): Promise<TypesGen.TemplateExample[]> => {
16791733
const response = await this.axios.get(
1680-
`/api/v2/organizations/${organizationId}/templates/examples`,
1734+
`/api/v2/organizations/${organization}/templates/examples`,
16811735
);
16821736

16831737
return response.data;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy