{
- unsetModal()
- await toast.promise(doDelete(), {
- loading: `Deleting ${assetType}...`,
- success: `Deleted ${assetType}.`,
- error: `Could not delete ${assetType}.`,
- })
- onSuccess()
- }}
+ onClick={onSubmit}
>
Delete
diff --git a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/dashboard.tsx b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/dashboard.tsx
index aca32eb2426c..fb1d1329ad04 100644
--- a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/dashboard.tsx
+++ b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/dashboard.tsx
@@ -355,6 +355,14 @@ function Dashboard(props: DashboardProps) {
Promise.resolve()}
onSuccess={doRefresh}
@@ -463,10 +471,7 @@ function Dashboard(props: DashboardProps) {
key={user.user.organization_id}
permissions={PERMISSION[user.permission]}
>
-
+ {svg.DEFAULT_USER_ICON}
))}
>
@@ -851,9 +856,21 @@ function Dashboard(props: DashboardProps) {
Promise.resolve()}
+ {...(backend.platform === platformModule.Platform.desktop
+ ? {
+ namePattern: '[A-Z][a-z]*(?:_\\d+|_[A-Z][a-z]*)*',
+ title:
+ 'Names must be in Upper_Snake_Case. ' +
+ '(Numbers (_0, _1) are also allowed.)',
+ }
+ : {})}
+ doRename={async name => {
+ await backend.projectUpdate(projectAsset.id, {
+ ami: null,
+ ideVersion: null,
+ projectName: name,
+ })
+ }}
onSuccess={doRefresh}
/>
))
@@ -861,18 +878,14 @@ function Dashboard(props: DashboardProps) {
// This is not a React component even though it contains JSX.
// eslint-disable-next-line no-restricted-syntax
function doDelete() {
- // The button is disabled when using the desktop backend,
- // so this condition should never be `false`.
- if (backend.platform === platformModule.Platform.cloud) {
- setModal(() => (
- backend.deleteProject(projectAsset.id)}
- onSuccess={doRefresh}
- />
- ))
- }
+ setModal(() => (
+ backend.deleteProject(projectAsset.id)}
+ onSuccess={doRefresh}
+ />
+ ))
}
setModal(() => (
@@ -882,15 +895,8 @@ function Dashboard(props: DashboardProps) {
Open as folder
-
- Rename
-
-
+ Rename
+
Delete
diff --git a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/renameModal.tsx b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/renameModal.tsx
index 4eba8162a859..e9d4ce260892 100644
--- a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/renameModal.tsx
+++ b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/renameModal.tsx
@@ -10,60 +10,75 @@ import Modal from './modal'
export interface RenameModalProps {
assetType: string
name: string
+ namePattern?: string
+ title?: string
doRename: (newName: string) => Promise
onSuccess: () => void
}
function RenameModal(props: RenameModalProps) {
- const { assetType, name, doRename, onSuccess } = props
+ const { assetType, name, namePattern, title, doRename, onSuccess } = props
const { unsetModal } = modalProvider.useSetModal()
+
const [newName, setNewName] = react.useState(null)
+
+ const onSubmit = async (event: React.FormEvent) => {
+ event.preventDefault()
+ if (newName == null) {
+ toast.error('Please provide a new name.')
+ } else {
+ unsetModal()
+ await toast.promise(doRename(newName), {
+ loading: `Renaming ${assetType}...`,
+ success: `Renamed ${assetType}.`,
+ // This is UNSAFE, as the original function's parameter is of type `any`.
+ error: (promiseError: Error) =>
+ `Error renaming ${assetType}: ${promiseError.message}`,
+ })
+ onSuccess()
+ }
+ }
+
+ console.log('what', namePattern, title)
+
return (