mirror of
https://github.com/coder/coder.git
synced 2026-09-21 20:51:01 +08:00
PR feedback
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
import { Story } from "@storybook/react"
|
||||
import {
|
||||
MockCanceledWorkspace,
|
||||
MockCancelingWorkspace,
|
||||
MockDeletedWorkspace,
|
||||
MockDeletingWorkspace,
|
||||
MockFailedWorkspace,
|
||||
MockPendingWorkspace,
|
||||
MockStartingWorkspace,
|
||||
MockStoppedWorkspace,
|
||||
MockStoppingWorkspace,
|
||||
MockWorkspace,
|
||||
} from "testHelpers/entities"
|
||||
import {
|
||||
WorkspaceStatusBadge,
|
||||
WorkspaceStatusBadgeProps,
|
||||
} from "./WorkspaceStatusBadge"
|
||||
|
||||
export default {
|
||||
title: "components/WorkspaceStatusBadge",
|
||||
component: WorkspaceStatusBadge,
|
||||
}
|
||||
|
||||
const Template: Story<WorkspaceStatusBadgeProps> = (args) => (
|
||||
<WorkspaceStatusBadge {...args} />
|
||||
)
|
||||
|
||||
export const Running = Template.bind({})
|
||||
Running.args = {
|
||||
workspace: MockWorkspace,
|
||||
}
|
||||
|
||||
export const Starting = Template.bind({})
|
||||
Starting.args = {
|
||||
workspace: MockStartingWorkspace,
|
||||
}
|
||||
|
||||
export const Stopped = Template.bind({})
|
||||
Stopped.args = {
|
||||
workspace: MockStoppedWorkspace,
|
||||
}
|
||||
|
||||
export const Stopping = Template.bind({})
|
||||
Stopping.args = {
|
||||
workspace: MockStoppingWorkspace,
|
||||
}
|
||||
|
||||
export const Deleting = Template.bind({})
|
||||
Deleting.args = {
|
||||
workspace: MockDeletingWorkspace,
|
||||
}
|
||||
|
||||
export const Deleted = Template.bind({})
|
||||
Deleted.args = {
|
||||
workspace: MockDeletedWorkspace,
|
||||
}
|
||||
|
||||
export const Canceling = Template.bind({})
|
||||
Canceling.args = {
|
||||
workspace: MockCancelingWorkspace,
|
||||
}
|
||||
|
||||
export const Canceled = Template.bind({})
|
||||
Canceled.args = {
|
||||
workspace: MockCanceledWorkspace,
|
||||
}
|
||||
|
||||
export const Failed = Template.bind({})
|
||||
Failed.args = {
|
||||
workspace: MockFailedWorkspace,
|
||||
}
|
||||
|
||||
export const Pending = Template.bind({})
|
||||
Pending.args = {
|
||||
workspace: MockPendingWorkspace,
|
||||
}
|
||||
@@ -94,15 +94,11 @@ export type WorkspaceStatusBadgeProps = {
|
||||
}
|
||||
|
||||
const ImpendingDeletionBadge: FC<
|
||||
PropsWithChildren<Partial<WorkspaceStatusBadgeProps>>
|
||||
> = ({ className }) => {
|
||||
const { entitlements, experiments } = useDashboard()
|
||||
const allowAdvancedScheduling =
|
||||
entitlements.features["advanced_template_scheduling"].enabled
|
||||
// This check can be removed when https://github.com/coder/coder/milestone/19
|
||||
// is merged up
|
||||
const allowWorkspaceActions = experiments.includes("workspace_actions")
|
||||
|
||||
Partial<WorkspaceStatusBadgeProps> & {
|
||||
allowAdvancedScheduling: boolean
|
||||
allowWorkspaceActions: boolean
|
||||
}
|
||||
> = ({ allowAdvancedScheduling, allowWorkspaceActions, className }) => {
|
||||
if (!allowAdvancedScheduling || !allowWorkspaceActions) {
|
||||
return null
|
||||
}
|
||||
@@ -119,8 +115,21 @@ const ImpendingDeletionBadge: FC<
|
||||
export const WorkspaceStatusBadge: FC<
|
||||
PropsWithChildren<WorkspaceStatusBadgeProps>
|
||||
> = ({ workspace, className }) => {
|
||||
const { entitlements, experiments } = useDashboard()
|
||||
const allowAdvancedScheduling =
|
||||
entitlements.features["advanced_template_scheduling"].enabled
|
||||
// This check can be removed when https://github.com/coder/coder/milestone/19
|
||||
// is merged up
|
||||
const allowWorkspaceActions = experiments.includes("workspace_actions")
|
||||
|
||||
if (displayImpendingDeletion(workspace)) {
|
||||
return <ImpendingDeletionBadge className={className} />
|
||||
return (
|
||||
<ImpendingDeletionBadge
|
||||
className={className}
|
||||
allowAdvancedScheduling={allowAdvancedScheduling}
|
||||
allowWorkspaceActions={allowWorkspaceActions}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const { text, icon, type } = getStatus(workspace.latest_build.status)
|
||||
|
||||
Reference in New Issue
Block a user