Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove project create form #6710

Merged
merged 1 commit into from
May 17, 2023
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import UploadFileModal from './uploadFileModal'

import DirectoryCreateForm from './directoryCreateForm'
import FileCreateForm from './fileCreateForm'
import ProjectCreateForm from './projectCreateForm'
import SecretCreateForm from './secretCreateForm'

// =============
Expand Down Expand Up @@ -105,10 +104,9 @@ const ASSET_TYPE_NAME: Record<backendModule.AssetType, string> = {

/** Forms to create each asset type. */
const ASSET_TYPE_CREATE_FORM: Record<
backendModule.AssetType,
Exclude<backendModule.AssetType, backendModule.AssetType.project>,
(props: CreateFormProps) => JSX.Element
> = {
[backendModule.AssetType.project]: ProjectCreateForm,
[backendModule.AssetType.file]: FileCreateForm,
[backendModule.AssetType.secret]: SecretCreateForm,
[backendModule.AssetType.directory]: DirectoryCreateForm,
Expand Down Expand Up @@ -536,32 +534,36 @@ function Dashboard(props: DashboardProps) {
/** Heading element for every column. */
function ColumnHeading(column: Column, assetType: backendModule.AssetType) {
return column === Column.name ? (
<div className="inline-flex">
{ASSET_TYPE_NAME[assetType]}
<button
className="mx-1"
onClick={event => {
event.stopPropagation()
const buttonPosition =
// This type assertion is safe as this event handler is on a `button`.
assetType === backendModule.AssetType.project ? (
<>{ASSET_TYPE_NAME[assetType]}</>
) : (
<div className="inline-flex">
{ASSET_TYPE_NAME[assetType]}
<button
className="mx-1"
onClick={event => {
event.stopPropagation()
const buttonPosition =
// This type assertion is safe as this event handler is on a button.
// eslint-disable-next-line no-restricted-syntax
(event.target as HTMLButtonElement).getBoundingClientRect()
// This is a React component even though it doesn't contain JSX.
// eslint-disable-next-line no-restricted-syntax
(event.target as HTMLButtonElement).getBoundingClientRect()
// This is a React component even though it doesn't contain JSX.
// eslint-disable-next-line no-restricted-syntax
const CreateForm = ASSET_TYPE_CREATE_FORM[assetType]
setModal(() => (
<CreateForm
left={buttonPosition.left + window.scrollX}
top={buttonPosition.top + window.scrollY}
directoryId={directoryId}
onSuccess={doRefresh}
/>
))
}}
>
{svg.ADD_ICON}
</button>
</div>
const CreateForm = ASSET_TYPE_CREATE_FORM[assetType]
setModal(() => (
<CreateForm
left={buttonPosition.left + window.scrollX}
top={buttonPosition.top + window.scrollY}
directoryId={directoryId}
onSuccess={doRefresh}
/>
))
}}
>
{svg.ADD_ICON}
</button>
</div>
)
) : (
<>{COLUMN_NAME[column]}</>
)
Expand Down