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 top bar to display org name#14596

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 17 commits intomainfrommes/filter-work-1
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
17 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
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
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
17a9e8c
Merge branch 'main' into mes/filter-work-1
ParkreinerSep 12, 2024
775486f
fix: ensure that mock query cache key and component key are properly …
ParkreinerSep 13, 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
4 changes: 3 additions & 1 deletionsite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1684,11 +1684,13 @@ class ApiMethods {
};

getWorkspaceQuota = async (
organizationName: string,
username: string,
): Promise<TypesGen.WorkspaceQuota> => {
const response = await this.axios.get(
`/api/v2/workspace-quota/${encodeURIComponent(username)}`,
`/api/v2/organizations/${encodeURIComponent(organizationName)}/members/${encodeURIComponent(username)}/workspace-quota`,
);

return response.data;
};

Expand Down
16 changes: 9 additions & 7 deletionssite/src/api/queries/workspaceQuota.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
import { API } from "api/api";

export const getWorkspaceQuotaQueryKey = (username: string) => [
username,
"workspaceQuota",
];
export const getWorkspaceQuotaQueryKey = (
organizationName: string,
username: string,
) => {
return ["workspaceQuota", organizationName, username];
};

export const workspaceQuota = (username: string) => {
export const workspaceQuota = (organizationName: string,username: string) => {
return {
queryKey: getWorkspaceQuotaQueryKey(username),
queryFn: () => API.getWorkspaceQuota(username),
queryKey: getWorkspaceQuotaQueryKey(organizationName,username),
queryFn: () => API.getWorkspaceQuota(organizationName,username),
};
};

Expand Down
2 changes: 1 addition & 1 deletionsite/src/modules/dashboard/DashboardProvider.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,7 +19,7 @@ export interface DashboardValue {
entitlements: Entitlements;
experiments: Experiments;
appearance: AppearanceConfig;
organizations: Organization[];
organizations:readonlyOrganization[];
showOrganizations: boolean;
}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,5 +99,8 @@ export const GroupsPage: FC = () => {

export default GroupsPage;

export const getOrganizationNameByDefault = (organizations: Organization[]) =>
organizations.find((org) => org.is_default)?.name;
export const getOrganizationNameByDefault = (
organizations: readonly Organization[],
) => {
return organizations.find((org) => org.is_default)?.name;
};
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,9 +12,9 @@ import { Outlet } from "react-router-dom";
import { DeploySettingsContext } from "../DeploySettingsPage/DeploySettingsLayout";
import { Sidebar } from "./Sidebar";

type OrganizationSettingsValue = {
organizations: Organization[];
};
type OrganizationSettingsValue =Readonly<{
organizations:readonlyOrganization[];
}>;

export const useOrganizationSettings = (): OrganizationSettingsValue => {
const { organizations } = useDashboard();
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,5 +59,9 @@ const OrganizationProvisionersPage: FC = () => {

export default OrganizationProvisionersPage;

const getOrganizationByName = (organizations: Organization[], name: string) =>
organizations.find((org) => org.name === name);
const getOrganizationByName = (
organizations: readonly Organization[],
name: string,
) => {
return organizations.find((org) => org.name === name);
};
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ const OrganizationSettingsPage: FC = () => {
// Redirect /organizations => /organizations/default-org, or if they cannot edit
// the default org, then the first org they can edit, if any.
if (!organizationName) {
const editableOrg = organizations
const editableOrg =[...organizations]
.sort((a, b) => {
// Prefer default org (it may not be first).
// JavaScript will happily subtract booleans, but use numbers to keep
Expand DownExpand Up@@ -112,5 +112,9 @@ const OrganizationSettingsPage: FC = () => {

export default OrganizationSettingsPage;

const getOrganizationByName = (organizations: Organization[], name: string) =>
organizations.find((org) => org.name === name);
const getOrganizationByName = (
organizations: readonly Organization[],
name: string,
) => {
return organizations.find((org) => org.name === name);
};
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,8 +45,11 @@ export const TemplateRedirectController: FC = () => {
return <Outlet />;
};

const getOrganizationNameByDefault = (organizations: Organization[]) =>
organizations.find((org) => org.is_default)?.name;
const getOrganizationNameByDefault = (
organizations: readonly Organization[],
) => {
return organizations.find((org) => org.is_default)?.name;
};

// I really hate doing it this way, but React Router does not provide a better way.
const removePrefix = (self: string, prefix: string) =>
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -220,6 +220,12 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = ({
(n) => n.severity === "warning",
);

// We have to avoid rendering out a div at all if there is no content so
// that we don't introduce additional gaps via the parent flex container
if (infoNotifications.length === 0 && warningNotifications.length === 0) {
return null;
}

return (
<div css={styles.notificationsGroup}>
{infoNotifications.length > 0 && (
Expand Down
11 changes: 7 additions & 4 deletionssite/src/pages/WorkspacePage/WorkspaceScheduleControls.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,14 +30,15 @@ import {
} from "utils/schedule";
import { isWorkspaceOn } from "utils/workspace";

exportinterface WorkspaceScheduleContainerProps {
interface WorkspaceScheduleContainerProps {
children?: ReactNode;
onClickIcon?: () => void;
}

export const WorkspaceScheduleContainer: FC<
WorkspaceScheduleContainerProps
> = ({ children, onClickIcon }) => {
const WorkspaceScheduleContainer: FC<WorkspaceScheduleContainerProps> = ({
children,
onClickIcon,
}) => {
const icon = (
<TopbarIcon>
<ScheduleOutlined aria-label="Schedule" />
Expand All@@ -49,6 +50,7 @@ export const WorkspaceScheduleContainer: FC<
<Tooltip title="Schedule">
{onClickIcon ? (
<button
type="button"
data-testid="schedule-icon-button"
onClick={onClickIcon}
css={styles.scheduleIconButton}
Expand DownExpand Up@@ -294,6 +296,7 @@ const styles = {
padding: 0,
fontSize: "inherit",
lineHeight: "inherit",
cursor: "pointer",
},

scheduleValue: {
Expand Down
37 changes: 32 additions & 5 deletionssite/src/pages/WorkspacePage/WorkspaceTopbar.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
import type { Meta, StoryObj } from "@storybook/react";
import { expect, screen, userEvent, waitFor, within } from "@storybook/test";
import { getWorkspaceQuotaQueryKey } from "api/queries/workspaceQuota";
import type { Workspace, WorkspaceQuota } from "api/typesGenerated";
import { addHours, addMinutes } from "date-fns";
import {
MockOrganization,
MockTemplate,
MockTemplateVersion,
MockUser,
Expand All@@ -11,9 +13,12 @@ import {
import { withDashboardProvider } from "testHelpers/storybook";
import { WorkspaceTopbar } from "./WorkspaceTopbar";

// We want a workspace without a deadline to not pollute the screenshot
const baseWorkspace = {
// We want a workspace without a deadline to not pollute the screenshot. Also
// want to make sure that the workspace is synced to our other mock values
const baseWorkspace: Workspace = {
...MockWorkspace,
organization_name: MockOrganization.name,
organization_id: MockOrganization.id,
latest_build: {
...MockWorkspace.latest_build,
deadline: undefined,
Expand DownExpand Up@@ -262,15 +267,37 @@ export const WithFarAwayDeadlineRequiredByTemplate: Story = {
},
};

export constWithQuota: Story = {
export constWithQuotaNoOrgs: Story = {
parameters: {
showOrganizations: false,
queries: [
{
key: getWorkspaceQuotaQueryKey(MockUser.username),
key: getWorkspaceQuotaQueryKey(
MockOrganization.name,
MockUser.username,
),
data: {
credits_consumed: 2,
budget: 40,
},
} satisfies WorkspaceQuota,
},
],
},
};

export const WithQuotaWithOrgs: Story = {
parameters: {
showOrganizations: true,
queries: [
{
key: getWorkspaceQuotaQueryKey(
MockOrganization.name,
MockUser.username,
),
data: {
credits_consumed: 2,
budget: 40,
} satisfies WorkspaceQuota,
},
],
},
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp