-
Notifications
You must be signed in to change notification settings - Fork 253
[cueweb/docs] Add Limits page (CueCommander parity) #2412
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
Merged
ramonfigueiredo
merged 5 commits into
AcademySoftwareFoundation:master
from
ramonfigueiredo:cueweb-limits-page
Jun 19, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2f1b0f7
[cueweb] Add Limits page (CueCommander parity)
ramonfigueiredo f44ca5d
[cueweb/docs] Document the Limits page
ramonfigueiredo bf2a8bb
Merge branch 'master' into cueweb-limits-page
ramonfigueiredo 691e01a
Merge branch 'master' into cueweb-limits-page
ramonfigueiredo 24f25b3
Merge branch 'master' into cueweb-limits-page
ramonfigueiredo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /* | ||
| * Copyright Contributors to the OpenCue Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { | ||
| createLimit, | ||
| deleteLimit, | ||
| renameLimit, | ||
| setLimitMaxValue, | ||
| } from '@/app/utils/action_utils'; | ||
| import { accessActionApi } from '@/app/utils/api_utils'; | ||
|
|
||
| jest.mock('@/app/utils/api_utils', () => ({ | ||
| accessActionApi: jest.fn(), | ||
| accessGetApi: jest.fn(), | ||
| })); | ||
|
|
||
| jest.mock('@/app/utils/notify_utils', () => ({ | ||
| toastSuccess: jest.fn(), | ||
| toastWarning: jest.fn(), | ||
| handleError: jest.fn(), | ||
| })); | ||
|
|
||
| jest.mock('@/app/utils/get_utils', () => ({ | ||
| getJobForLayer: jest.fn(), | ||
| getFrameLogDir: jest.fn(), | ||
| })); | ||
|
|
||
| describe('limit action_utils helpers', () => { | ||
| beforeEach(() => jest.clearAllMocks()); | ||
|
|
||
| it('createLimit posts { name, max_value }', async () => { | ||
| (accessActionApi as jest.Mock).mockResolvedValue({ success: true }); | ||
| await expect(createLimit('test1', 0)).resolves.toBe(true); | ||
| expect(accessActionApi).toHaveBeenCalledWith( | ||
| '/api/limit/action/create', | ||
| [JSON.stringify({ name: 'test1', max_value: 0 })], | ||
| ); | ||
| }); | ||
|
|
||
| it('deleteLimit posts { name }', async () => { | ||
| (accessActionApi as jest.Mock).mockResolvedValue({ success: true }); | ||
| await deleteLimit('test1'); | ||
| expect(accessActionApi).toHaveBeenCalledWith( | ||
| '/api/limit/action/delete', | ||
| [JSON.stringify({ name: 'test1' })], | ||
| ); | ||
| }); | ||
|
|
||
| it('renameLimit posts { old_name, new_name }', async () => { | ||
| (accessActionApi as jest.Mock).mockResolvedValue({ success: true }); | ||
| await renameLimit('test1', 'test2'); | ||
| expect(accessActionApi).toHaveBeenCalledWith( | ||
| '/api/limit/action/rename', | ||
| [JSON.stringify({ old_name: 'test1', new_name: 'test2' })], | ||
| ); | ||
| }); | ||
|
|
||
| it('setLimitMaxValue posts { name, max_value }', async () => { | ||
| (accessActionApi as jest.Mock).mockResolvedValue({ success: true }); | ||
| await setLimitMaxValue('test1', 50); | ||
| expect(accessActionApi).toHaveBeenCalledWith( | ||
| '/api/limit/action/setmaxvalue', | ||
| [JSON.stringify({ name: 'test1', max_value: 50 })], | ||
| ); | ||
| }); | ||
|
|
||
| it('returns false when the action reports failure', async () => { | ||
| (accessActionApi as jest.Mock).mockResolvedValue({ error: 'boom' }); | ||
| await expect(createLimit('test1', 0)).resolves.toBe(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * Copyright Contributors to the OpenCue Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { getLimits } from '@/app/utils/get_utils'; | ||
| import { accessGetApi } from '@/app/utils/api_utils'; | ||
|
|
||
| jest.mock('@/app/utils/api_utils', () => ({ | ||
| accessGetApi: jest.fn(), | ||
| })); | ||
|
|
||
| describe('getLimits', () => { | ||
| beforeEach(() => jest.clearAllMocks()); | ||
|
|
||
| it('posts to /api/limit/getall and returns the array', async () => { | ||
| const limits = [{ id: 'l1', name: 'asdf', maxValue: 0, currentRunning: 0 }]; | ||
| (accessGetApi as jest.Mock).mockResolvedValue(limits); | ||
|
|
||
| await expect(getLimits()).resolves.toEqual(limits); | ||
| expect(accessGetApi).toHaveBeenCalledWith('/api/limit/getall', JSON.stringify({})); | ||
| }); | ||
|
|
||
| it('returns [] when the gateway returns a non-array', async () => { | ||
| (accessGetApi as jest.Mock).mockResolvedValue(null); | ||
| await expect(getLimits()).resolves.toEqual([]); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Copyright Contributors to the OpenCue Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { handleRoute } from '@/app/utils/api_utils'; | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
|
|
||
| // Create a limit. Request: { name, max_value }. RPC: /limit.LimitInterface/Create. | ||
| export async function POST(request: NextRequest) { | ||
| const endpoint = "/limit.LimitInterface/Create"; | ||
| const method = request.method; | ||
| if (method !== 'POST') { | ||
| return NextResponse.json({ error: 'Invalid method. Only POST is allowed.' }, { status: 405 }); | ||
| } | ||
|
|
||
| let jsonBody: any; | ||
| try { | ||
| jsonBody = await request.json(); | ||
| } catch { | ||
| return NextResponse.json({ error: 'Invalid JSON in request body' }, { status: 400 }); | ||
| } | ||
| if ( | ||
| !jsonBody || | ||
| typeof jsonBody !== 'object' || | ||
| typeof jsonBody.name !== 'string' || | ||
| jsonBody.name.trim().length === 0 || | ||
| typeof jsonBody.max_value !== 'number' | ||
| ) { | ||
| return NextResponse.json({ error: 'Invalid request body: name and max_value are required' }, { status: 400 }); | ||
| } | ||
|
|
||
| const body = JSON.stringify({ name: jsonBody.name.trim(), max_value: jsonBody.max_value }); | ||
| const response = await handleRoute(method, endpoint, body, true); | ||
| const responseData = await response.json(); | ||
|
|
||
| if (!response.ok) return NextResponse.json({ error: responseData.error }, { status: response.status }); | ||
| return NextResponse.json({ data: responseData.data }, { status: response.status }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Copyright Contributors to the OpenCue Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { handleRoute } from '@/app/utils/api_utils'; | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
|
|
||
| // Delete a limit by name. Request: { name }. RPC: /limit.LimitInterface/Delete. | ||
| export async function POST(request: NextRequest) { | ||
| const endpoint = "/limit.LimitInterface/Delete"; | ||
| const method = request.method; | ||
| if (method !== 'POST') { | ||
| return NextResponse.json({ error: 'Invalid method. Only POST is allowed.' }, { status: 405 }); | ||
| } | ||
|
|
||
| let jsonBody: any; | ||
| try { | ||
| jsonBody = await request.json(); | ||
| } catch { | ||
| return NextResponse.json({ error: 'Invalid JSON in request body' }, { status: 400 }); | ||
| } | ||
| if (!jsonBody || typeof jsonBody !== 'object' || typeof jsonBody.name !== 'string' || jsonBody.name.length === 0) { | ||
| return NextResponse.json({ error: 'Invalid request body: name is required' }, { status: 400 }); | ||
| } | ||
|
|
||
| const body = JSON.stringify({ name: jsonBody.name }); | ||
|
ramonfigueiredo marked this conversation as resolved.
|
||
| const response = await handleRoute(method, endpoint, body, true); | ||
| const responseData = await response.json(); | ||
|
|
||
| if (!response.ok) return NextResponse.json({ error: responseData.error }, { status: response.status }); | ||
| return NextResponse.json({ data: responseData.data }, { status: response.status }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * Copyright Contributors to the OpenCue Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { handleRoute } from '@/app/utils/api_utils'; | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
|
|
||
| // Rename a limit. Request: { old_name, new_name }. RPC: /limit.LimitInterface/Rename. | ||
| export async function POST(request: NextRequest) { | ||
| const endpoint = "/limit.LimitInterface/Rename"; | ||
| const method = request.method; | ||
| if (method !== 'POST') { | ||
| return NextResponse.json({ error: 'Invalid method. Only POST is allowed.' }, { status: 405 }); | ||
| } | ||
|
|
||
| let jsonBody: any; | ||
| try { | ||
| jsonBody = await request.json(); | ||
| } catch { | ||
| return NextResponse.json({ error: 'Invalid JSON in request body' }, { status: 400 }); | ||
| } | ||
| if ( | ||
| !jsonBody || | ||
| typeof jsonBody !== 'object' || | ||
| typeof jsonBody.old_name !== 'string' || | ||
| jsonBody.old_name.length === 0 || | ||
| typeof jsonBody.new_name !== 'string' || | ||
| jsonBody.new_name.trim().length === 0 | ||
| ) { | ||
| return NextResponse.json({ error: 'Invalid request body: old_name and new_name are required' }, { status: 400 }); | ||
| } | ||
|
|
||
| const body = JSON.stringify({ old_name: jsonBody.old_name, new_name: jsonBody.new_name.trim() }); | ||
|
ramonfigueiredo marked this conversation as resolved.
|
||
| const response = await handleRoute(method, endpoint, body, true); | ||
| const responseData = await response.json(); | ||
|
|
||
| if (!response.ok) return NextResponse.json({ error: responseData.error }, { status: response.status }); | ||
| return NextResponse.json({ data: responseData.data }, { status: response.status }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Copyright Contributors to the OpenCue Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { handleRoute } from '@/app/utils/api_utils'; | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
|
|
||
| // Set a limit's max value. Request: { name, max_value }. The value must be a | ||
| // non-negative integer. RPC: /limit.LimitInterface/SetMaxValue. | ||
| export async function POST(request: NextRequest) { | ||
| const endpoint = "/limit.LimitInterface/SetMaxValue"; | ||
| const method = request.method; | ||
| if (method !== 'POST') { | ||
| return NextResponse.json({ error: 'Invalid method. Only POST is allowed.' }, { status: 405 }); | ||
| } | ||
|
|
||
| let jsonBody: any; | ||
| try { | ||
| jsonBody = await request.json(); | ||
| } catch { | ||
| return NextResponse.json({ error: 'Invalid JSON in request body' }, { status: 400 }); | ||
| } | ||
| if ( | ||
| !jsonBody || | ||
| typeof jsonBody !== 'object' || | ||
| typeof jsonBody.name !== 'string' || | ||
| jsonBody.name.length === 0 || | ||
| typeof jsonBody.max_value !== 'number' || | ||
| jsonBody.max_value < 0 | ||
| ) { | ||
| return NextResponse.json({ error: 'Invalid request body: name and a non-negative max_value are required' }, { status: 400 }); | ||
| } | ||
|
ramonfigueiredo marked this conversation as resolved.
|
||
|
|
||
| const body = JSON.stringify({ name: jsonBody.name, max_value: jsonBody.max_value }); | ||
| const response = await handleRoute(method, endpoint, body, true); | ||
| const responseData = await response.json(); | ||
|
|
||
| if (!response.ok) return NextResponse.json({ error: responseData.error }, { status: response.status }); | ||
| return NextResponse.json({ data: responseData.data }, { status: response.status }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Copyright Contributors to the OpenCue Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { handleRoute } from '@/app/utils/api_utils'; | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
|
|
||
| // Lists every limit for the Limits page. Unlike host/show GetAll, the gateway | ||
| // nests the result a single level as { limits: [...] } (LimitGetAllResponse has | ||
| // a `repeated Limit limits`, no inner *Seq), so we unwrap one level. | ||
| // RPC: /limit.LimitInterface/GetAll. | ||
| export async function POST(request: NextRequest) { | ||
| const endpoint = "/limit.LimitInterface/GetAll"; | ||
| const method = request.method; | ||
| if (method !== 'POST') { | ||
| return NextResponse.json({ error: 'Invalid method. Only POST is allowed.' }, { status: 405 }); | ||
| } | ||
|
|
||
| let parsed: unknown = {}; | ||
| try { | ||
| parsed = await request.json(); | ||
| } catch { | ||
| // Empty body is acceptable - GetAll takes no parameters. | ||
| } | ||
| const body = JSON.stringify(parsed ?? {}); | ||
|
|
||
| const response = await handleRoute(method, endpoint, body); | ||
| const responseData = await response.json(); | ||
|
|
||
| if (!response.ok) { | ||
| return NextResponse.json( | ||
| { error: responseData?.error ?? "Failed to fetch limits" }, | ||
| { status: response.status }, | ||
| ); | ||
| } | ||
| const limits = responseData?.data?.limits ?? []; | ||
| return NextResponse.json({ data: limits }, { status: response.status }); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.