Skip to content

feat(site): allow selecting an organization when creating a template #14061

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

Merged
merged 65 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
d640312
feat: initial changes for multi org template creation
jaaydenh Jul 12, 2024
1c973ae
feat: styling and add template creation options
jaaydenh Jul 18, 2024
6b5e7ec
chore: remove unused imports
jaaydenh Jul 18, 2024
fbd6ca3
fix: use theme on cardTitle
jaaydenh Jul 18, 2024
013522b
fix: remove unused import
jaaydenh Jul 18, 2024
f547bfc
fix: pass key directly to JSX without using spread
jaaydenh Jul 19, 2024
6b6c635
fix: use correct path
jaaydenh Jul 19, 2024
b4e3c67
fix: fix test
jaaydenh Jul 19, 2024
2636753
chore: handle merge changes
jaaydenh Jul 19, 2024
c113979
fix: remove CreateTemplateButton
jaaydenh Jul 19, 2024
cb53396
fix: update template examples for multi-org
jaaydenh Jul 23, 2024
789699a
feat: pass along organizationId when creating templates
jaaydenh Jul 23, 2024
8b03b11
fix: improve organization autocomplete
jaaydenh Jul 24, 2024
b3aa04f
Feat: move org dropdown and add orgId search param
jaaydenh Jul 24, 2024
03768c4
chore: show org autocomplete if experiment is enabled
jaaydenh Jul 24, 2024
7baba1e
fix: remove unnecessary query param
jaaydenh Jul 24, 2024
f513633
fix: cleanup
jaaydenh Jul 24, 2024
b350b95
fix: fix tests
jaaydenh Jul 24, 2024
2810cd3
fix: fix create template form stories
jaaydenh Jul 24, 2024
6499543
fix
jaaydenh Jul 24, 2024
c52c3dc
fix: merge issues
jaaydenh Jul 25, 2024
6205129
chore: use default org for example templates
jaaydenh Jul 26, 2024
b721a43
feat: add organizationId to the templates route
jaaydenh Jul 26, 2024
41a414e
fix: add missing useMemo dependency
jaaydenh Jul 26, 2024
e23475b
fix: add organizationId dependency
jaaydenh Jul 26, 2024
53d4a3e
feat: update tests for organization in templates route
jaaydenh Jul 26, 2024
7d92893
feat: gate org dropdown to multiple_organizations feature
jaaydenh Jul 26, 2024
73ae86b
chore: set default for organization route param
jaaydenh Jul 26, 2024
9bb1139
feat: update template routes for organizations
jaaydenh Jul 26, 2024
1375b30
feat: add templates route
jaaydenh Jul 26, 2024
aa452fe
feat: use templates_route
jaaydenh Jul 26, 2024
0830dcc
Merge branch 'main' into multi-org-create-template
aslilac Jul 26, 2024
b637620
the whirly durly
aslilac Jul 26, 2024
fc9c6b4
oh boy
aslilac Jul 29, 2024
85a6834
fix `pageTitle`
aslilac Jul 29, 2024
2cf6662
:^)
aslilac Jul 29, 2024
833c51c
Merge branch 'main' into kayla/multi-org-create-template
aslilac Jul 30, 2024
bb996df
builds again
aslilac Jul 30, 2024
b939177
Merge branch 'main' into kayla/multi-org-create-template
aslilac Jul 30, 2024
f209a69
Merge branch 'main' into kayla/multi-org-create-template
aslilac Jul 30, 2024
0316028
fix some pages
aslilac Jul 30, 2024
36b6937
🧹
aslilac Jul 30, 2024
1a88c60
:|
aslilac Jul 30, 2024
2cf9e25
patch tests
aslilac Jul 30, 2024
b358578
you dun
aslilac Jul 30, 2024
9e9ae3f
these tests pass I swear
aslilac Jul 30, 2024
833bb75
required
aslilac Jul 30, 2024
c469959
🧹
aslilac Jul 30, 2024
60b6a13
🧹
aslilac Jul 31, 2024
ccbb35d
Merge branch 'main' into kayla/multi-org-create-template
aslilac Jul 31, 2024
7c34bd9
fix some more links
aslilac Jul 31, 2024
a60a9f6
don't use dashboard hooks in the form
aslilac Jul 31, 2024
b61860e
dude bro man come on
aslilac Jul 31, 2024
088d27c
yaaaay navigation code yay
aslilac Aug 1, 2024
f9048a3
what
aslilac Aug 1, 2024
3f4a430
🧹
aslilac Aug 1, 2024
c034bdc
fix some tests
aslilac Aug 1, 2024
d1db06a
nonsense
aslilac Aug 1, 2024
e9031f8
fix a bunch of nav stuff
aslilac Aug 1, 2024
f45fc20
fix even more tests forever
aslilac Aug 1, 2024
fdff07f
and here
aslilac Aug 1, 2024
f3e77a5
fmt
aslilac Aug 1, 2024
af6413c
aaaand storybook
aslilac Aug 1, 2024
958bea4
dense
aslilac Aug 1, 2024
861a5c4
PLS I'M SO TIRED
aslilac Aug 1, 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
7 changes: 6 additions & 1 deletion site/e2e/expectUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export const expectUrl = expect.extend({
pass,
actual,
expected,
message: () => "The page does not have the expected URL pathname.",
message: () =>
"The page does not have the expected URL pathname.\n" +
`Expected: ${this.isNot ? "not" : ""}${this.utils.printExpected(
expected,
)}\n` +
`Actual: ${this.utils.printReceived(actual)}`,
};
},
});
126 changes: 90 additions & 36 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,73 +516,97 @@ class ApiMethods {
return response.data;
};

/**
* @param organization Can be the organization's ID or name
*/
updateOrganization = async (
organizationId: string,
organization: string,
params: TypesGen.UpdateOrganizationRequest,
) => {
const response = await this.axios.patch<TypesGen.Organization>(
`/api/v2/organizations/${organizationId}`,
`/api/v2/organizations/${organization}`,
params,
);
return response.data;
};

deleteOrganization = async (organizationId: string) => {
/**
* @param organization Can be the organization's ID or name
*/
deleteOrganization = async (organization: string) => {
await this.axios.delete<TypesGen.Organization>(
`/api/v2/organizations/${organizationId}`,
`/api/v2/organizations/${organization}`,
);
};

/**
* @param organization Can be the organization's ID or name
*/
getOrganization = async (
organizationId: string,
organization: string,
): Promise<TypesGen.Organization> => {
const response = await this.axios.get<TypesGen.Organization>(
`/api/v2/organizations/${organizationId}`,
`/api/v2/organizations/${organization}`,
);

return response.data;
};

getOrganizationMembers = async (organizationId: string) => {
/**
* @param organization Can be the organization's ID or name
*/
getOrganizationMembers = async (organization: string) => {
const response = await this.axios.get<
TypesGen.OrganizationMemberWithUserData[]
>(`/api/v2/organizations/${organizationId}/members`);
>(`/api/v2/organizations/${organization}/members`);

return response.data;
};

getOrganizationRoles = async (organizationId: string) => {
/**
* @param organization Can be the organization's ID or name
*/
getOrganizationRoles = async (organization: string) => {
const response = await this.axios.get<TypesGen.AssignableRoles[]>(
`/api/v2/organizations/${organizationId}/members/roles`,
`/api/v2/organizations/${organization}/members/roles`,
);

return response.data;
};

/**
* @param organization Can be the organization's ID or name
*/
updateOrganizationMemberRoles = async (
organizationId: string,
organization: string,
userId: string,
roles: TypesGen.SlimRole["name"][],
): Promise<TypesGen.User> => {
const response = await this.axios.put<TypesGen.User>(
`/api/v2/organizations/${organizationId}/members/${userId}/roles`,
`/api/v2/organizations/${organization}/members/${userId}/roles`,
{ roles },
);

return response.data;
};

addOrganizationMember = async (organizationId: string, userId: string) => {
/**
* @param organization Can be the organization's ID or name
*/
addOrganizationMember = async (organization: string, userId: string) => {
const response = await this.axios.post<TypesGen.OrganizationMember>(
`/api/v2/organizations/${organizationId}/members/${userId}`,
`/api/v2/organizations/${organization}/members/${userId}`,
);

return response.data;
};

removeOrganizationMember = async (organizationId: string, userId: string) => {
/**
* @param organization Can be the organization's ID or name
*/
removeOrganizationMember = async (organization: string, userId: string) => {
await this.axios.delete(
`/api/v2/organizations/${organizationId}/members/${userId}`,
`/api/v2/organizations/${organization}/members/${userId}`,
);
};

Expand All @@ -601,8 +625,11 @@ class ApiMethods {
return response.data;
};

/**
* @param organization Can be the organization's ID or name
*/
getTemplates = async (
organizationId: string,
organization: string,
options?: TemplateOptions,
): Promise<TypesGen.Template[]> => {
const params: Record<string, string> = {};
Expand All @@ -614,19 +641,22 @@ class ApiMethods {
}

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

return response.data;
};

/**
* @param organization Can be the organization's ID or name
*/
getTemplateByName = async (
organizationId: string,
organization: string,
name: string,
): Promise<TypesGen.Template> => {
const response = await this.axios.get<TypesGen.Template>(
`/api/v2/organizations/${organizationId}/templates/${name}`,
`/api/v2/organizations/${organization}/templates/${name}`,
);

return response.data;
Expand Down Expand Up @@ -675,26 +705,32 @@ class ApiMethods {
return response.data;
};

/**
* @param organization Can be the organization's ID or name
*/
getTemplateVersionByName = async (
organizationId: string,
organization: string,
templateName: string,
versionName: string,
): Promise<TypesGen.TemplateVersion> => {
const response = await this.axios.get<TypesGen.TemplateVersion>(
`/api/v2/organizations/${organizationId}/templates/${templateName}/versions/${versionName}`,
`/api/v2/organizations/${organization}/templates/${templateName}/versions/${versionName}`,
);

return response.data;
};

/**
* @param organization Can be the organization's ID or name
*/
getPreviousTemplateVersionByName = async (
organizationId: string,
organization: string,
templateName: string,
versionName: string,
) => {
try {
const response = await this.axios.get<TypesGen.TemplateVersion>(
`/api/v2/organizations/${organizationId}/templates/${templateName}/versions/${versionName}/previous`,
`/api/v2/organizations/${organization}/templates/${templateName}/versions/${versionName}/previous`,
);

return response.data;
Expand All @@ -713,12 +749,15 @@ class ApiMethods {
}
};

/**
* @param organization Can be the organization's ID or name
*/
createTemplateVersion = async (
organizationId: string,
organization: string,
data: TypesGen.CreateTemplateVersionRequest,
): Promise<TypesGen.TemplateVersion> => {
const response = await this.axios.post<TypesGen.TemplateVersion>(
`/api/v2/organizations/${organizationId}/templateversions`,
`/api/v2/organizations/${organization}/templateversions`,
data,
);

Expand All @@ -744,12 +783,15 @@ class ApiMethods {
return response.data;
};

/**
* @param organization Can be the organization's ID or name
*/
createTemplate = async (
organizationId: string,
organization: string,
data: TypesGen.CreateTemplateRequest,
): Promise<TypesGen.Template> => {
const response = await this.axios.post(
`/api/v2/organizations/${organizationId}/templates`,
`/api/v2/organizations/${organization}/templates`,
data,
);

Expand Down Expand Up @@ -1480,31 +1522,40 @@ class ApiMethods {
return response.data;
};

getGroups = async (organizationId: string): Promise<TypesGen.Group[]> => {
/**
* @param organization Can be the organization's ID or name
*/
getGroups = async (organization: string): Promise<TypesGen.Group[]> => {
const response = await this.axios.get(
`/api/v2/organizations/${organizationId}/groups`,
`/api/v2/organizations/${organization}/groups`,
);

return response.data;
};

/**
* @param organization Can be the organization's ID or name
*/
createGroup = async (
organizationId: string,
organization: string,
data: TypesGen.CreateGroupRequest,
): Promise<TypesGen.Group> => {
const response = await this.axios.post(
`/api/v2/organizations/${organizationId}/groups`,
`/api/v2/organizations/${organization}/groups`,
data,
);
return response.data;
};

/**
* @param organization Can be the organization's ID or name
*/
getGroup = async (
organizationId: string,
organization: string,
groupName: string,
): Promise<TypesGen.Group> => {
const response = await this.axios.get(
`/api/v2/organizations/${organizationId}/groups/${groupName}`,
`/api/v2/organizations/${organization}/groups/${groupName}`,
);
return response.data;
};
Expand Down Expand Up @@ -1673,11 +1724,14 @@ class ApiMethods {
return response.data;
};

/**
* @param organization Can be the organization's ID or name
*/
getTemplateExamples = async (
organizationId: string,
organization: string,
): Promise<TypesGen.TemplateExample[]> => {
const response = await this.axios.get(
`/api/v2/organizations/${organizationId}/templates/examples`,
`/api/v2/organizations/${organization}/templates/examples`,
);

return response.data;
Expand Down
Loading
Loading