Skip to content

Commit 4eb67ad

Browse files
authored
Revert "feat: implement multi-org template gallery (coder#13784)" (coder#14013)
This reverts commit 554c4ab.
1 parent 615bb94 commit 4eb67ad

21 files changed

+64
-663
lines changed

codersdk/organizations.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,8 @@ func (c *Client) TemplatesByOrganization(ctx context.Context, organizationID uui
405405
}
406406

407407
type TemplateFilter struct {
408-
OrganizationID uuid.UUID `json:"organization_id,omitempty" format:"uuid" typescript:"-"`
409-
FilterQuery string `json:"q,omitempty"`
410-
ExactName string `json:"exact_name,omitempty" typescript:"-"`
408+
OrganizationID uuid.UUID
409+
ExactName string
411410
}
412411

413412
// asRequestOption returns a function that can be used in (*Client).Request.
@@ -425,11 +424,6 @@ func (f TemplateFilter) asRequestOption() RequestOption {
425424
params = append(params, fmt.Sprintf("exact_name:%q", f.ExactName))
426425
}
427426

428-
if f.FilterQuery != "" {
429-
// If custom stuff is added, just add it on here.
430-
params = append(params, f.FilterQuery)
431-
}
432-
433427
q := r.URL.Query()
434428
q.Set("q", strings.Join(params, " "))
435429
r.URL.RawQuery = q.Encode()

site/src/api/api.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ class ApiMethods {
599599
return response.data;
600600
};
601601

602-
getTemplatesByOrganizationId = async (
602+
getTemplates = async (
603603
organizationId: string,
604604
options?: TemplateOptions,
605605
): Promise<TypesGen.Template[]> => {
@@ -619,14 +619,6 @@ class ApiMethods {
619619
return response.data;
620620
};
621621

622-
getTemplates = async (
623-
options?: TypesGen.TemplateFilter,
624-
): Promise<TypesGen.Template[]> => {
625-
const url = getURLWithSearchParams("/api/v2/templates", options);
626-
const response = await this.axios.get<TypesGen.Template[]>(url);
627-
return response.data;
628-
};
629-
630622
getTemplateByName = async (
631623
organizationId: string,
632624
name: string,

site/src/api/queries/audits.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { API } from "api/api";
22
import type { AuditLogResponse } from "api/typesGenerated";
3+
import { useFilterParamsKey } from "components/Filter/filter";
34
import type { UsePaginatedQueryOptions } from "hooks/usePaginatedQuery";
4-
import { filterParamsKey } from "utils/filters";
55

66
export function paginatedAudits(
77
searchParams: URLSearchParams,
88
): UsePaginatedQueryOptions<AuditLogResponse, string> {
99
return {
1010
searchParams,
11-
queryPayload: () => searchParams.get(filterParamsKey) ?? "",
11+
queryPayload: () => searchParams.get(useFilterParamsKey) ?? "",
1212
queryKey: ({ payload, pageNumber }) => {
1313
return ["auditLogs", payload, pageNumber] as const;
1414
},

site/src/api/queries/templates.ts

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { MutationOptions, QueryClient, QueryOptions } from "react-query";
22
import { API } from "api/api";
33
import type {
4-
TemplateFilter,
54
CreateTemplateRequest,
65
CreateTemplateVersionRequest,
76
ProvisionerJob,
@@ -31,26 +30,16 @@ export const templateByName = (
3130
};
3231
};
3332

34-
const getTemplatesByOrganizationIdQueryKey = (
35-
organizationId: string,
36-
deprecated?: boolean,
37-
) => [organizationId, "templates", deprecated];
38-
39-
export const templatesByOrganizationId = (
40-
organizationId: string,
41-
deprecated?: boolean,
42-
) => {
43-
return {
44-
queryKey: getTemplatesByOrganizationIdQueryKey(organizationId, deprecated),
45-
queryFn: () =>
46-
API.getTemplatesByOrganizationId(organizationId, { deprecated }),
47-
};
48-
};
33+
const getTemplatesQueryKey = (organizationId: string, deprecated?: boolean) => [
34+
organizationId,
35+
"templates",
36+
deprecated,
37+
];
4938

50-
export const templates = (filter?: TemplateFilter) => {
39+
export const templates = (organizationId: string, deprecated?: boolean) => {
5140
return {
52-
queryKey: ["templates", filter],
53-
queryFn: () => API.getTemplates(filter),
41+
queryKey: getTemplatesQueryKey(organizationId, deprecated),
42+
queryFn: () => API.getTemplates(organizationId, { deprecated }),
5443
};
5544
};
5645

@@ -103,10 +92,7 @@ export const setGroupRole = (
10392

10493
export const templateExamples = (organizationId: string) => {
10594
return {
106-
queryKey: [
107-
...getTemplatesByOrganizationIdQueryKey(organizationId),
108-
"examples",
109-
],
95+
queryKey: [...getTemplatesQueryKey(organizationId), "examples"],
11096
queryFn: () => API.getTemplateExamples(organizationId),
11197
};
11298
};

site/src/api/typesGenerated.ts

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/components/Filter/filter.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
import { InputGroup } from "components/InputGroup/InputGroup";
1717
import { SearchField } from "components/SearchField/SearchField";
1818
import { useDebouncedFunction } from "hooks/debounce";
19-
import { filterParamsKey } from "utils/filters";
2019

2120
export type PresetFilter = {
2221
name: string;
@@ -36,19 +35,21 @@ type UseFilterConfig = {
3635
onUpdate?: (newValue: string) => void;
3736
};
3837

38+
export const useFilterParamsKey = "filter";
39+
3940
export const useFilter = ({
4041
fallbackFilter = "",
4142
searchParamsResult,
4243
onUpdate,
4344
}: UseFilterConfig) => {
4445
const [searchParams, setSearchParams] = searchParamsResult;
45-
const query = searchParams.get(filterParamsKey) ?? fallbackFilter;
46+
const query = searchParams.get(useFilterParamsKey) ?? fallbackFilter;
4647

4748
const update = (newValues: string | FilterValues) => {
4849
const serialized =
4950
typeof newValues === "string" ? newValues : stringifyFilter(newValues);
5051

51-
searchParams.set(filterParamsKey, serialized);
52+
searchParams.set(useFilterParamsKey, serialized);
5253
setSearchParams(searchParams);
5354

5455
if (onUpdate !== undefined) {

site/src/modules/templates/TemplateCard/TemplateCard.stories.tsx

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

site/src/modules/templates/TemplateCard/TemplateCard.tsx

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

site/src/pages/StarterTemplatesPage/StarterTemplatesPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { templateExamples } from "api/queries/templates";
55
import type { TemplateExample } from "api/typesGenerated";
66
import { useDashboard } from "modules/dashboard/useDashboard";
77
import { pageTitle } from "utils/page";
8-
import { getTemplatesByTag } from "utils/templateAggregators";
8+
import { getTemplatesByTag } from "utils/starterTemplates";
99
import { StarterTemplatesPageView } from "./StarterTemplatesPageView";
1010

1111
const StarterTemplatesPage: FC = () => {

site/src/pages/StarterTemplatesPage/StarterTemplatesPageView.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
MockTemplateExample,
66
MockTemplateExample2,
77
} from "testHelpers/entities";
8-
import { getTemplatesByTag } from "utils/templateAggregators";
8+
import { getTemplatesByTag } from "utils/starterTemplates";
99
import { StarterTemplatesPageView } from "./StarterTemplatesPageView";
1010

1111
const meta: Meta<typeof StarterTemplatesPageView> = {

site/src/pages/StarterTemplatesPage/StarterTemplatesPageView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from "components/PageHeader/PageHeader";
1212
import { Stack } from "components/Stack/Stack";
1313
import { TemplateExampleCard } from "modules/templates/TemplateExampleCard/TemplateExampleCard";
14-
import type { StarterTemplatesByTag } from "utils/templateAggregators";
14+
import type { StarterTemplatesByTag } from "utils/starterTemplates";
1515

1616
const getTagLabel = (tag: string) => {
1717
const labelByTag: Record<string, string> = {

0 commit comments

Comments
 (0)