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

chore: update workspaces page filter to include organization controls#14597

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
Parkreiner merged 34 commits intomainfrommes/filter-work-2
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
34 commits
Select commitHold shift + click to select a range
f90f088
chore: move schedule controls to the right side of the screen
ParkreinerSep 4, 2024
4956ebb
chore: add org display to workspace topbar
ParkreinerSep 4, 2024
43ce786
fix: force organizations to be readonly array
ParkreinerSep 4, 2024
6570b51
Merge branch 'main' into mes/filter-work-1
ParkreinerSep 5, 2024
b2512a7
fix update type mismatch for organizations again
ParkreinerSep 5, 2024
3211805
refactor: tuck main loading skeleton for filter into base definition
ParkreinerSep 5, 2024
cdcc907
refactor: give filter files different names to reduce confusion
ParkreinerSep 5, 2024
99a3792
refactor: remove separate base filter skeleton
ParkreinerSep 5, 2024
66a55a6
fix: update responsive logic for audit table filter
ParkreinerSep 5, 2024
d7c9571
chore: add organizations option group to workspaces table
ParkreinerSep 6, 2024
74d5ff8
refactor: make prop contracts more explicit
ParkreinerSep 6, 2024
8acc33b
refactor: centralize the organizations dropdown logic
ParkreinerSep 6, 2024
5a0c523
fix: update imports and formatting
ParkreinerSep 6, 2024
6829017
fix: update quota querying logic to use new endpoint
ParkreinerSep 6, 2024
dcfb84f
fix: add logic for handling long workspace or org names
ParkreinerSep 6, 2024
836a2d4
chore: add links for workspaces by org
ParkreinerSep 6, 2024
6696c0a
chore: expand tooltip styling for org
ParkreinerSep 6, 2024
de554d6
chore: expand tooltip styling for owner
ParkreinerSep 6, 2024
3b410f7
refactor: split off breadcrumbs for readability
ParkreinerSep 6, 2024
c8f9226
fix: display correct template version name in dropdown
ParkreinerSep 6, 2024
83788e7
Merge branch 'mes/filter-work-1' into mes/filter-work-2
ParkreinerSep 6, 2024
36eba47
fix: update overflow styling for breadcrumb segments
ParkreinerSep 9, 2024
5e0689d
fix: favor org display name
ParkreinerSep 9, 2024
7c1e859
fix: centralize org display name logic
ParkreinerSep 9, 2024
552b93d
Merge branch 'mes/filter-work-1' into mes/filter-work-2
ParkreinerSep 9, 2024
ba8515d
fix: make sure skeletons stay synced with org feature toggles
ParkreinerSep 12, 2024
17a9e8c
Merge branch 'main' into mes/filter-work-1
ParkreinerSep 12, 2024
7c7a9fb
Merge branch 'mes/filter-work-1' into mes/filter-work-2
ParkreinerSep 12, 2024
775486f
fix: ensure that mock query cache key and component key are properly …
ParkreinerSep 13, 2024
f7f8c3e
Merge branch 'mes/filter-work-1' into mes/filter-work-2
ParkreinerSep 13, 2024
d40167f
docs: clean up wording on SearchField comment
ParkreinerSep 13, 2024
3806867
Merge branch 'main' into mes/filter-work-2
ParkreinerSep 16, 2024
5db1400
fix: shrink mix width threshold for search field
ParkreinerSep 16, 2024
6dbfe06
chore: add navigation test for workspace details page (#14629)
ParkreinerSep 16, 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
2 changes: 1 addition & 1 deletionsite/src/api/queries/audits.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import{API}from"api/api";
importtype{AuditLogResponse}from"api/typesGenerated";
import{useFilterParamsKey}from"components/Filter/filter";
import{useFilterParamsKey}from"components/Filter/Filter";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

MY HERO

importtype{UsePaginatedQueryOptions}from"hooks/usePaginatedQuery";

exportfunctionpaginatedAudits(
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,38 +125,40 @@ const BaseSkeleton: FC<SkeletonProps> = ({ children, ...skeletonProps }) => {
);
};

export const SearchFieldSkeleton: FC = () => {
return <BaseSkeleton width="100%" />;
};

export const MenuSkeleton: FC = () => {
return <BaseSkeleton css={{ minWidth: 200, flexShrink: 0 }} />;
};

type FilterProps = {
filter: ReturnType<typeof useFilter>;
skeleton: ReactNode;
optionsSkeleton: ReactNode;
isLoading: boolean;
learnMoreLink?: string;
learnMoreLabel2?: string;
learnMoreLink2?: string;
error?: unknown;
options?: ReactNode;
presets: PresetFilter[];
breakpoint?: Breakpoint;

/**
* The CSS media query breakpoint that defines when the UI will try
* displaying all options on one row, regardless of the number of options
* present
*/
singleRowBreakpoint?: Breakpoint;
};

export const Filter: FC<FilterProps> = ({
filter,
isLoading,
error,
skeleton,
optionsSkeleton,
options,
learnMoreLink,
learnMoreLabel2,
learnMoreLink2,
presets,
breakpoint = "md",
singleRowBreakpoint = "lg",
}) => {
const theme = useTheme();
// Storing local copy of the filter query so that it can be updated more
Expand DownExpand Up@@ -187,15 +189,18 @@ export const Filter: FC<FilterProps> = ({
display: "flex",
gap: 8,
marginBottom: 16,
flexWrap: "nowrap",
flexWrap: "wrap",

[theme.breakpoints.down(breakpoint)]: {
flexWrap: "wrap",
[theme.breakpoints.up(singleRowBreakpoint)]: {
flexWrap: "nowrap",
},
}}
>
{isLoading ? (
skeleton
<>
<BaseSkeleton width="100%" />
{optionsSkeleton}
</>
Comment on lines +200 to +203
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Inlined the base skeleton because:

  1. I don't think there will ever be a situation where we don't want a skeleton for the main search box itself
  2. It felt weird that the component was never in control ofany of its skeletons

) : (
<>
<InputGroup css={{ width: "100%" }}>
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/Filter/SelectFilter.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ export const SelectFilter: FC<SelectFilterProps> = ({
<SelectMenuTrigger>
<SelectMenuButton
startIcon={selectedOption?.startIcon}
css={{ width, flexGrow: 1 }}
css={{flexBasis:width, flexGrow: 1 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

flexBasis!!!!! you're literally so good at your job

aria-label={label}
>
{selectedOption?.label ?? placeholder}
Expand Down
6 changes: 3 additions & 3 deletionssite/src/components/Filter/UserFilter.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,8 +19,8 @@ export const useUserFilterMenu = ({
>) => {
const { user: me } = useAuthenticated();

const addMeAsFirstOption = (options: SelectFilterOption[]) => {
options= options.filter((option) =>option.value !== me.username);
const addMeAsFirstOption = (options:readonlySelectFilterOption[]) => {
const filtered= options.filter((o) =>o.value !== me.username);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

the only way this line would make me happier is if you did the thing I like where the closure names the parameterit

return [
{
label: me.username,
Expand All@@ -33,7 +33,7 @@ export const useUserFilterMenu = ({
/>
),
},
...options,
...filtered,
];
};

Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/Filter/storyHelpers.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { action } from "@storybook/addon-actions";
import type { UseFilterResult } from "./filter";
import type { UseFilterResult } from "./Filter";
import type { UseFilterMenuResult } from "./menu";

export const MockMenu: UseFilterMenuResult = {
Expand Down
3 changes: 3 additions & 0 deletionssite/src/components/SearchField/SearchField.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,9 @@ export const SearchField: FC<SearchFieldProps> = ({
const theme = useTheme();
return (
<TextField
// Specifying `minWidth` so that the text box can't shrink so much
// that it becomes un-clickable as we add more filter controls
css={{ minWidth: "280px" }}
size="small"
value={value}
onChange={(e) => onChange(e.target.value)}
Expand Down
22 changes: 19 additions & 3 deletionssite/src/contexts/auth/RequireAuth.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
import { API } from "api/api";
import { isApiError } from "api/errors";
import { Loader } from "components/Loader/Loader";
import { ProxyProvider } from "contexts/ProxyContext";
import { DashboardProvider } from "modules/dashboard/DashboardProvider";
import { ProxyProvideras ProductionProxyProvider} from "contexts/ProxyContext";
import { DashboardProvideras ProductionDashboardProvider} from "modules/dashboard/DashboardProvider";
import { type FC, useEffect } from "react";
import { Navigate, Outlet, useLocation } from "react-router-dom";
import { embedRedirect } from "utils/redirect";
import { type AuthContextValue, useAuthContext } from "./AuthProvider";

export const RequireAuth: FC = () => {
type RequireAuthProps = Readonly<{
ProxyProvider?: typeof ProductionProxyProvider;
DashboardProvider?: typeof ProductionDashboardProvider;
}>;

/**
* Wraps any component and ensures that the user has been authenticated before
* they can access the component's contents.
*
* In production, it is assumed that this component will not be called with any
* props at all. But to make testing easier, you can call this component with
* specific providers to mock them out.
*/
export const RequireAuth: FC<RequireAuthProps> = ({
DashboardProvider = ProductionDashboardProvider,
ProxyProvider = ProductionProxyProvider,
}) => {
const location = useLocation();
const { signOut, isSigningOut, isSignedOut, isSignedIn, isLoading } =
useAuthContext();
Expand Down
121 changes: 121 additions & 0 deletionssite/src/modules/tableFiltering/options.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
/**
* @file Defines a centralized place for filter dropdown groups that are
* relevant across multiple pages within the Coder UI.
*
* @todo 2024-09-06 - Figure out how to move the user dropdown group into this
* file (or whether there are enough subtle differences that it's not worth
* centralizing the logic). We currently have two separate implementations for
* the workspaces and audits page that have a risk of getting out of sync.
*/
import { API } from "api/api";
import {
SelectFilter,
type SelectFilterOption,
SelectFilterSearch,
} from "components/Filter/SelectFilter";
import {
type UseFilterMenuOptions,
useFilterMenu,
} from "components/Filter/menu";
import { UserAvatar } from "components/UserAvatar/UserAvatar";
import type { FC } from "react";

// Organization helpers ////////////////////////////////////////////////////////

export const useOrganizationsFilterMenu = ({
value,
onChange,
}: Pick<UseFilterMenuOptions<SelectFilterOption>, "value" | "onChange">) => {
return useFilterMenu({
onChange,
value,
id: "organizations",
getSelectedOption: async () => {
if (value) {
const organizations = await API.getOrganizations();
const organization = organizations.find((o) => o.name === value);
if (organization) {
return {
label: organization.display_name || organization.name,
value: organization.name,
startIcon: (
<UserAvatar
key={organization.id}
size="xs"
username={organization.display_name || organization.name}
avatarURL={organization.icon}
/>
),
};
}
}
return null;
},
getOptions: async () => {
// Only show the organizations for which you can view audit logs.
const organizations = await API.getOrganizations();
const permissions = await API.checkAuthorization({
checks: Object.fromEntries(
organizations.map((organization) => [
organization.id,
{
object: {
resource_type: "audit_log",
organization_id: organization.id,
},
action: "read",
},
]),
),
});
return organizations
.filter((organization) => permissions[organization.id])
.map<SelectFilterOption>((organization) => ({
label: organization.display_name || organization.name,
value: organization.name,
startIcon: (
<UserAvatar
key={organization.id}
size="xs"
username={organization.display_name || organization.name}
avatarURL={organization.icon}
/>
),
}));
},
});
};

export type OrganizationsFilterMenu = ReturnType<
typeof useOrganizationsFilterMenu
>;

interface OrganizationsMenuProps {
menu: OrganizationsFilterMenu;
width?: number;
}

export const OrganizationsMenu: FC<OrganizationsMenuProps> = ({
menu,
width,
}) => {
return (
<SelectFilter
label="Select an organization"
placeholder="All organizations"
emptyText="No organizations found"
options={menu.searchOptions}
onSelect={menu.selectOption}
selectedOption={menu.selectedOption ?? undefined}
selectFilterSearch={
<SelectFilterSearch
inputProps={{ "aria-label": "Search organization" }}
placeholder="Search organization..."
value={menu.query}
onChange={menu.setQuery}
/>
}
width={width}
/>
);
};
Loading

[8]ページ先頭

©2009-2025 Movatter.jp