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

feat: batch workspace updates#11583

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
aslilac merged 14 commits intomainfrombatch-update
Jan 18, 2024
Merged
Changes from1 commit
Commits
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
PrevPrevious commit
NextNext commit
fix icons and small things
  • Loading branch information
@aslilac
aslilac committedJan 16, 2024
commit908a46c24e3224d2feb4e8c808f805f9604638de
67 changes: 30 additions & 37 deletionssite/src/pages/WorkspacesPage/BatchUpdateConfirmation.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
import PersonOutlinedIcon from "@mui/icons-material/PersonOutlined";
import ScheduleIcon from "@mui/icons-material/Schedule";
import InstallDesktopIcon from "@mui/icons-material/InstallDesktop";
import SettingsSuggestIcon from "@mui/icons-material/SettingsSuggest";
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import { type Interpolation, type Theme } from "@emotion/react";
Expand DownExpand Up@@ -55,8 +57,8 @@ export const BatchUpdateConfirmation: FC<BatchUpdateConfirmationProps> = ({
const workspacesToUpdate = [];

for (const it of outdatedWorkspaces) {
dormantWorkspaces.push(it);
if (it.dormant_at) {
dormantWorkspaces.push(it);
} else {
workspacesToUpdate.push(it);
}
Expand DownExpand Up@@ -173,9 +175,7 @@ export const BatchUpdateConfirmation: FC<BatchUpdateConfirmationProps> = ({
description={
<>
{stage === "consequences" && (
<Consequences
runningWorkspaceCount={runningWorkspacesToUpdate.length}
/>
<Consequences runningWorkspaces={runningWorkspacesToUpdate} />
)}
{stage === "dormantWorkspaces" && (
<DormantWorkspaces workspaces={dormantWorkspaces} />
Expand All@@ -194,19 +194,20 @@ export const BatchUpdateConfirmation: FC<BatchUpdateConfirmationProps> = ({
};

interface ConsequencesProps {
runningWorkspaceCount: number;
runningWorkspaces: Workspace[];
}

const Consequences: FC<ConsequencesProps> = ({ runningWorkspaceCount }) => {
const Consequences: FC<ConsequencesProps> = ({ runningWorkspaces }) => {
const workspaceCount = `${runningWorkspaces.length} ${
runningWorkspaces.length === 1 ? "running workspace" : "running workspaces"
}`;

const owners = new Set(runningWorkspaces.map((it) => it.owner_id)).size;
const ownerCount = `${owners} ${owners === 1 ? "owner" : "owners"}`;

return (
<>
<p>
You are about to update{" "}
{runningWorkspaceCount === 1
? "a running workspace"
: "multiple running workspaces"}
.
</p>
<p>You are about to update {workspaceCount}.</p>
<ul css={styles.consequences}>
<li>
Updating will stop all running processes and delete non-persistent
Expand All@@ -218,6 +219,17 @@ const Consequences: FC<ConsequencesProps> = ({ runningWorkspaceCount }) => {
</li>
<li>Any unsaved data will be lost.</li>
</ul>
<Stack
justifyContent="center"
direction="row"
wrap="wrap"
css={styles.summary}
>
<Stack direction="row" alignItems="center" spacing={1}>
<PersonIcon />
<span>{ownerCount}</span>
</Stack>
</Stack>
</>
);
};
Expand DownExpand Up@@ -309,27 +321,15 @@ interface UpdatesProps {
}

const Updates: FC<UpdatesProps> = ({ workspaces, updates, error }) => {
const mostRecent = workspaces.reduce(
(latestSoFar, against) => {
if (!latestSoFar) {
return against;
}

return new Date(against.last_used_at).getTime() >
new Date(latestSoFar.last_used_at).getTime()
? against
: latestSoFar;
},
undefined as Workspace | undefined,
);

const workspaceCount = `${workspaces.length} ${
workspaces.length === 1 ? "outdated workspace" : "outdated workspaces"
}`;

const updateCount =
updates &&
`${updates.length} ${updates.length === 1 ? "template" : "templates"}`;
`${updates.length} ${
updates.length === 1 ? "new version" : "new versions"
}`;

return (
<>
Expand All@@ -341,21 +341,15 @@ const Updates: FC<UpdatesProps> = ({ workspaces, updates, error }) => {
css={styles.summary}
>
<Stack direction="row" alignItems="center" spacing={1}>
<PersonIcon />
<InstallDesktopIcon css={styles.summaryIcon} />
<span>{workspaceCount}</span>
</Stack>
{updateCount && (
<Stack direction="row" alignItems="center" spacing={1}>
<PersonIcon />
<SettingsSuggestIcon css={styles.summaryIcon} />
<span>{updateCount}</span>
</Stack>
)}
{mostRecent && (
<Stack direction="row" alignItems="center" spacing={1}>
<ScheduleIcon css={styles.summaryIcon} />
<span>Last used {lastUsed(mostRecent.last_used_at)}</span>
</Stack>
)}
</Stack>
</>
);
Expand DownExpand Up@@ -441,7 +435,6 @@ const styles = {
flexDirection: "column",
gap: 8,
paddingLeft: 16,
marginBottom: 0,
},

workspacesList: (theme) => ({
Expand Down

[8]ページ先頭

©2009-2026 Movatter.jp