Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add more checks for permissions within confirmation methods

Joshen Lim8b0fc5ef8751
diff --git a/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx b/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
index a925bbd150f..4dec24b5031 100644
--- a/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
+++ b/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
@@ -27,6 +27,13 @@ const PauseProjectButton: FC<Props> = observer(({ projectRef, projectId }) => {
const canReboot = checkPermissions(PermissionAction.INFRA_EXECUTE, 'reboot')
const requestPauseProject = async () => {
+ if (!canReboot) {
+ return ui.setNotification({
+ category: 'error',
+ message: 'You do not have the required permissions to pause this project',
+ })
+ }
+
setLoading(true)
const res = await post(`${API_URL}/projects/${projectRef}/pause`, {})
diff --git a/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx b/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx
index 989be3bc8da..3e4fc76b06a 100644
--- a/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx
+++ b/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx
@@ -27,6 +27,13 @@ const RestartServerButton: FC<Props> = observer(({ projectRef, projectId }) => {
const canReboot = checkPermissions(PermissionAction.INFRA_EXECUTE, 'reboot')
const requestServerRestart = async () => {
+ if (!canReboot) {
+ return ui.setNotification({
+ category: 'error',
+ message: 'You do not have the required permissions to restart this project',
+ })
+ }
+
setLoading(true)
const res = await post(`${API_URL}/projects/${projectRef}/restart`, {})
diff --git a/studio/components/layouts/ProjectLayout/ProjectPausedState.tsx b/studio/components/layouts/ProjectLayout/ProjectPausedState.tsx
index 316c7f83e6e..ed95a01401c 100644
--- a/studio/components/layouts/ProjectLayout/ProjectPausedState.tsx
+++ b/studio/components/layouts/ProjectLayout/ProjectPausedState.tsx
@@ -25,6 +25,16 @@ const ProjectPausedState: FC<Props> = ({ project }) => {
const canReboot = checkPermissions(PermissionAction.INFRA_EXECUTE, 'reboot')
+ const onSelectRestore = () => {
+ if (!canReboot) {
+ return ui.setNotification({
+ category: 'error',
+ message: 'You do not have the required permissions to restore this project',
+ })
+ }
+ setShowConfirmRestore(true)
+ }
+
const onConfirmRestore = async () => {
await post(`${API_URL}/projects/${project.ref}/restore`, {})
app.onProjectUpdated({ ...project, status: PROJECT_STATUS.RESTORING })
@@ -61,7 +71,7 @@ const ProjectPausedState: FC<Props> = ({ project }) => {
size="tiny"
type="primary"
disabled={hasExceedActiveFreeProjectsLimit || !canReboot}
- onClick={() => setShowConfirmRestore(true)}
+ onClick={onSelectRestore}
>
Restore project
</Button>