This commit is contained in:
Timothy Jaeryang Baek
2026-02-10 15:30:16 -06:00
parent 0044902c08
commit c259c87806
4 changed files with 17 additions and 13 deletions
+7 -1
View File
@@ -502,9 +502,10 @@ class PromptsTable:
name: str, name: str,
command: str, command: str,
tags: Optional[list[str]] = None, tags: Optional[list[str]] = None,
access_grants: Optional[list[dict]] = None,
db: Optional[Session] = None, db: Optional[Session] = None,
) -> Optional[PromptModel]: ) -> Optional[PromptModel]:
"""Update only name and command (no history created).""" """Update only name, command, tags, and access grants (no history created)."""
try: try:
with get_db_context(db) as db: with get_db_context(db) as db:
prompt = db.query(Prompt).filter_by(id=prompt_id).first() prompt = db.query(Prompt).filter_by(id=prompt_id).first()
@@ -517,6 +518,11 @@ class PromptsTable:
if tags is not None: if tags is not None:
prompt.tags = tags prompt.tags = tags
if access_grants is not None:
AccessGrants.set_access_grants(
"prompt", prompt_id, access_grants, db=db
)
prompt.updated_at = int(time.time()) prompt.updated_at = int(time.time())
db.commit() db.commit()
+2 -1
View File
@@ -33,6 +33,7 @@ class PromptMetadataForm(BaseModel):
name: str name: str
command: str command: str
tags: Optional[list[str]] = None tags: Optional[list[str]] = None
access_grants: Optional[list[dict]] = None
router = APIRouter() router = APIRouter()
@@ -372,7 +373,7 @@ async def update_prompt_metadata(
) )
updated_prompt = Prompts.update_prompt_metadata( updated_prompt = Prompts.update_prompt_metadata(
prompt.id, form_data.name, form_data.command, form_data.tags, db=db prompt.id, form_data.name, form_data.command, form_data.tags, form_data.access_grants, db=db
) )
if updated_prompt: if updated_prompt:
return updated_prompt return updated_prompt
+3 -2
View File
@@ -331,7 +331,8 @@ export const updatePromptMetadata = async (
promptId: string, promptId: string,
name: string, name: string,
command: string, command: string,
tags: string[] = [] tags: string[] = [],
accessGrants: any[] | null = null
) => { ) => {
let error = null; let error = null;
@@ -342,7 +343,7 @@ export const updatePromptMetadata = async (
'Content-Type': 'application/json', 'Content-Type': 'application/json',
authorization: `Bearer ${token}` authorization: `Bearer ${token}`
}, },
body: JSON.stringify({ name, command, tags }) body: JSON.stringify({ name, command, tags, access_grants: accessGrants })
}) })
.then(async (res) => { .then(async (res) => {
if (!res.ok) throw await res.json(); if (!res.ok) throw await res.json();
@@ -213,14 +213,6 @@
} }
debounceTimer = setTimeout(async () => { debounceTimer = setTimeout(async () => {
// Skip if nothing changed
if (
name === originalName &&
command === originalCommand &&
JSON.stringify(tags) === JSON.stringify(originalTags)
)
return;
if (!validateCommandString(command)) { if (!validateCommandString(command)) {
toast.error( toast.error(
$i18n.t('Only alphanumeric characters and hyphens are allowed in the command string.') $i18n.t('Only alphanumeric characters and hyphens are allowed in the command string.')
@@ -235,7 +227,8 @@
prompt?.id, prompt?.id,
name, name,
command, command,
tags.map((tag) => tag.name) tags.map((tag) => tag.name),
accessGrants
); );
// Update originals on success // Update originals on success
originalName = name; originalName = name;
@@ -290,6 +283,9 @@
accessRoles={['read', 'write']} accessRoles={['read', 'write']}
share={$user?.permissions?.sharing?.prompts || $user?.role === 'admin'} share={$user?.permissions?.sharing?.prompts || $user?.role === 'admin'}
sharePublic={$user?.permissions?.sharing?.public_prompts || $user?.role === 'admin' || edit} sharePublic={$user?.permissions?.sharing?.public_prompts || $user?.role === 'admin' || edit}
onChange={() => {
debouncedSaveMetadata();
}}
/> />
<!-- Edit Modal --> <!-- Edit Modal -->