mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-17 00:20:51 +00:00
feat: add a share dialog and a first-deploy dialog (#11950)
* feat: harmonize flow, script and app settings drawers Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor: name the on-behalf-of setting by the access it grants Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat: add a permissions tab and confirm who apps run on behalf of Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: sandbox draft-only app deploys and keep app settings out of exports Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep drafted run-as users and custom url removals Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat: confirm the run-as user on every deploy that uses one Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: let new raw apps take the folder default and follow synced settings Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat: add a share dialog next to deploy and a first-deploy dialog Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: start AI-session raw apps without a run-as user Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: mock the deployed app read in chat deploy tests and type the list height Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore: point at the ee branch that registers the sharing counters Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: share the deployed path, log first deploys once and report the kept app access Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor: stop drafting an app's access mode and custom url Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep a deployed app's access mode on an mcp deploy Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat: ask who a first deploy runs as in the first-deploy dialog's second step Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: drop the first-deploy footer rule and test the run-as question Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat: let a flow or script deploy turn off run on behalf of Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: apply who can open an app on change, as on main Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: mute the error handler from the editor menu and keep it on deploy Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor: rename the Permissions entries and drawer to Share Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat: confirm deploys that move an item to another folder Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: change only the access mode when it applies on click Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: read the mute flag from the deployed row at its own path Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: read a raw app's access mode after bundling it Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep group members off the list of who a move takes access from Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: change an app's access mode under the deploy row lock Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: defer a mode change to deploy on an app run as another user Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: hold the access toggle while its change is in flight Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: bind the app policy down to the settings drawer Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep app draft labels in the mcp session tools Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * revert: leave the deploy panel's access toggle to the settings drawer PR Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: change only the access mode on click and let deploys keep the deployed one Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: send Share's mode change alone and keep it out of MCP deploys Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep the caller's draft on a mode-only app update Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: leave the access mode out of every update deploy Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat: explain in Share what an item's runs can reach Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: describe a viewer-mode app as using its viewer's access Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat: confirm Share's app access changes with a toast Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: refuse a builder's mode-only change on an unsandboxed app Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: disable Share's access mode for a builder on an unsandboxed app Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test: check the reason for the unsandboxed mode-only refusal Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: defer a builder's access-mode change on an unsandboxed app Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: state the stored access mode in the chat's raw app deploy note Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: state the stored access mode in the MCP raw app deploy note Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: lock the access mode when the server would refuse the change Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: address settings and run-as review findings Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: say to deploy first when Share's access mode is locked Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: hold the run-as confirmation until the folder default has loaded Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep the run-as dialog cancelable while the folder default loads Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor: harmonize flow and script settings layout Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: name who can change a locked access mode without taking the app over Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep the priority input open while it is edited Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat: confirm run-as on flow and script deploy, mute from editor menu Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep settings rows open while edited and name the deploying user for non-admins Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: reread the deployed run-as user after a deploy that keeps the editor open Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: say in Share that admins and deployers can change a locked access mode Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: tell a builder who keeps the run-as user to pick themselves before deploying Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: write a setting before its row opens and show its real state while edited Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: slide settings rows open to their full height Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat: open Share from the menu of Home's favorite and recent cards Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: send the popover's deployment message when Deploy is clicked Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: remount a settings row's fields when its toggle turns it on Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: send the popover's deployment message from Deploy & Stay here Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: count Share opened from a Home card under its own telemetry key Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: clear the deployment message after a successful deploy Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: show the stored access mode in Share after a refused change Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: keep app access mode display in sync with the stored mode and badge app settings tabs Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: clear the app Deploy popover's message after a successful deploy Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: read the deployed row before muting from the menu, title Deploy only when icon-only Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: give the app settings badges the chip label and row key Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: mark the app labels and access rows so their badges reach them Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat: show the app settings as three sections instead of tabs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: drop unused publishAccessMode and app sharing badges Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: update ee-repo-ref to d16494953659e00dd169fb8f73266f22f937b862 This commit updates the EE repository reference after PR #911 was merged in windmill-ee-private. Previous ee-repo-ref: 07f0090acb4a1f206c37f34411819b8c86690388 New ee-repo-ref: d16494953659e00dd169fb8f73266f22f937b862 Automated by sync-ee-ref workflow. --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
Ruben Fiszel
windmill-internal-app[bot]
parent
6df5705223
commit
ef5fa21603
@@ -1 +1 @@
|
||||
e3d765239022d2b7a6615d28348a9da661a3faf5
|
||||
d16494953659e00dd169fb8f73266f22f937b862
|
||||
|
||||
@@ -8,9 +8,9 @@ use serde_json::{json, Map, Value};
|
||||
|
||||
use super::flows::drop_stale_step_locks;
|
||||
use super::workspace::{
|
||||
api_message, app_source_to_draft_value, delete_draft, deployed_item_exists, draft_kind,
|
||||
draft_page, get_deployed, get_draft_item, item_exists, item_type_arg, path_enc, service,
|
||||
unified_patch, ITEM_TYPES, TRIGGER_KINDS,
|
||||
api_message, app_source_to_draft_value, delete_draft, deployed_execution_mode,
|
||||
deployed_item_exists, draft_kind, draft_page, get_deployed, get_draft_item, item_exists,
|
||||
item_type_arg, path_enc, service, unified_patch, ITEM_TYPES, TRIGGER_KINDS,
|
||||
};
|
||||
use super::{
|
||||
array, bool_arg, enc, is_not_found, js_str, matches_glob, non_null, opt_str_arg, pretty,
|
||||
@@ -323,6 +323,18 @@ async fn guest_access_is_live(ctx: &Ctx<'_>) -> bool {
|
||||
truthy(usage.get("available"))
|
||||
}
|
||||
|
||||
/// Settles the access mode a raw app deploy states. Who can open a deployed app is set from the
|
||||
/// Share dialog, so an update states none and the server keeps the deployed mode, under the row
|
||||
/// lock a mode change also takes. A new app takes the drafted mode, members-only when the draft
|
||||
/// names none.
|
||||
fn settle_execution_mode(policy: &mut Map<String, Value>, exists: bool) {
|
||||
if exists {
|
||||
policy.remove("execution_mode");
|
||||
} else if !truthy(policy.get("execution_mode")) {
|
||||
policy.insert("execution_mode".into(), json!("publisher"));
|
||||
}
|
||||
}
|
||||
|
||||
/// Deploys a raw app draft from its sources: the server bundles them on a worker and
|
||||
/// derives the policy's triggerables from the runnables. Returns the note for the result.
|
||||
async fn deploy_app(
|
||||
@@ -354,10 +366,6 @@ async fn deploy_app(
|
||||
.unwrap_or_default()
|
||||
};
|
||||
let runnables = object_or_empty("runnables");
|
||||
let mut policy = object_or_empty("policy");
|
||||
if !truthy(policy.get("execution_mode")) {
|
||||
policy.insert("execution_mode".into(), json!("publisher"));
|
||||
}
|
||||
|
||||
let mut notes = Vec::new();
|
||||
let undeployed = undeployed_runnable_targets(ctx, &runnables).await;
|
||||
@@ -368,23 +376,6 @@ async fn deploy_app(
|
||||
undeployed.join(", ")
|
||||
));
|
||||
}
|
||||
// What a runnable runs as is the server's to decide, so the note names who can
|
||||
// reach the app and never an identity.
|
||||
match policy.get("execution_mode").and_then(Value::as_str) {
|
||||
Some("anonymous") => notes.push(
|
||||
"This app is deployed as anonymous: its backend runnables are now reachable by anyone \
|
||||
with the URL, without logging in. Tell the user plainly what is now reachable and by whom."
|
||||
.to_string(),
|
||||
),
|
||||
// `guest` is stored whether or not a guest is admitted: silent unless it is live.
|
||||
Some("guest") if guest_access_is_live(ctx).await => notes.push(
|
||||
"This app is deployed as guest: anyone the instance's identity provider authenticates \
|
||||
can now open it and run its backend runnables, member of this workspace or not. Tell \
|
||||
the user plainly what is now reachable and by whom."
|
||||
.to_string(),
|
||||
),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// An editor-created draft is parked at a synthetic storage key, its chosen path in
|
||||
// the stored draft. Only a missing item justifies falling back to the storage path.
|
||||
@@ -404,6 +395,11 @@ async fn deploy_app(
|
||||
Err(e) if is_not_found(&e) => path.to_string(),
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
let exists = item_exists(ctx, "app", None, &target).await?;
|
||||
|
||||
let mut policy = object_or_empty("policy");
|
||||
settle_execution_mode(&mut policy, exists);
|
||||
let created_mode = policy.get("execution_mode").cloned();
|
||||
|
||||
let mut app = Map::new();
|
||||
app.insert("path".into(), json!(target));
|
||||
@@ -432,7 +428,7 @@ async fn deploy_app(
|
||||
if let Some(message) = message {
|
||||
app.insert("deployment_message".into(), json!(message));
|
||||
}
|
||||
if item_exists(ctx, "app", None, &target).await? {
|
||||
if exists {
|
||||
// `custom_path` stays out of an update: the server keeps it when absent, and
|
||||
// sending it takes admin rights.
|
||||
ctx.post(
|
||||
@@ -447,6 +443,35 @@ async fn deploy_app(
|
||||
ctx.post(&ctx.ws("apps/create_raw_source"), Value::Object(app))
|
||||
.await?;
|
||||
}
|
||||
|
||||
// An update keeps the deployed mode, so the note states the stored row's, read after the
|
||||
// write. What a runnable runs as is the server's to decide, so the note names who can reach
|
||||
// the app and never an identity.
|
||||
let mode = if exists {
|
||||
deployed_execution_mode(ctx, &target).await.ok().flatten()
|
||||
} else {
|
||||
created_mode
|
||||
};
|
||||
match mode.as_ref().and_then(Value::as_str) {
|
||||
Some("anonymous") => notes.push(
|
||||
"This app is deployed as anonymous: its backend runnables are now reachable by anyone \
|
||||
with the URL, without logging in. Tell the user plainly what is now reachable and by whom."
|
||||
.to_string(),
|
||||
),
|
||||
// `guest` is stored whether or not a guest is admitted: silent unless it is live.
|
||||
Some("guest") if guest_access_is_live(ctx).await => notes.push(
|
||||
"This app is deployed as guest: anyone the instance's identity provider authenticates \
|
||||
can now open it and run its backend runnables, member of this workspace or not. Tell \
|
||||
the user plainly what is now reachable and by whom."
|
||||
.to_string(),
|
||||
),
|
||||
None => notes.push(
|
||||
"Its access mode could not be read back after the deploy, so tell the user to check \
|
||||
who can open the app."
|
||||
.to_string(),
|
||||
),
|
||||
_ => {}
|
||||
}
|
||||
Ok((!notes.is_empty()).then(|| notes.join(" ")))
|
||||
}
|
||||
|
||||
@@ -2350,4 +2375,24 @@ mod tests {
|
||||
assert!(!matches_glob("f/dash/main/src/App.tsx", "f/dash/*.tsx"));
|
||||
assert!(!matches_glob("f/dash/main", "*.tsx"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_update_leaves_the_access_mode_to_the_server() {
|
||||
let settled = |drafted: Value, exists: bool| {
|
||||
let mut policy = drafted.as_object().cloned().unwrap_or_default();
|
||||
settle_execution_mode(&mut policy, exists);
|
||||
policy.get("execution_mode").cloned()
|
||||
};
|
||||
// An update states no mode, whatever the draft names, so the deployed one stands.
|
||||
assert_eq!(
|
||||
settled(json!({ "execution_mode": "anonymous" }), true),
|
||||
None
|
||||
);
|
||||
// A new app takes the drafted mode, members-only when there is none.
|
||||
assert_eq!(
|
||||
settled(json!({ "execution_mode": "anonymous" }), false),
|
||||
Some(json!("anonymous"))
|
||||
);
|
||||
assert_eq!(settled(json!({}), false), Some(json!("publisher")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,6 +277,18 @@ pub(super) async fn get_deployed(
|
||||
.await
|
||||
}
|
||||
|
||||
/// Who can open the deployed app at `path`, which the Share dialog sets and a deploy keeps.
|
||||
pub(super) async fn deployed_execution_mode(
|
||||
ctx: &Ctx<'_>,
|
||||
path: &str,
|
||||
) -> Result<Option<Value>, String> {
|
||||
Ok(ctx
|
||||
.get(&ctx.ws(&format!("apps/get/lite/{}", path_enc(path))))
|
||||
.await?
|
||||
.pointer("/policy/execution_mode")
|
||||
.cloned())
|
||||
}
|
||||
|
||||
pub(super) struct Draft {
|
||||
pub value: Value,
|
||||
pub created_at: Option<String>,
|
||||
@@ -1493,12 +1505,19 @@ async fn read_workspace_item(ctx: &Ctx<'_>, args: &Value) -> ToolResult {
|
||||
|
||||
if !deployed_only && !hub {
|
||||
if let Some((item, _)) = get_draft_item(ctx, item_type, path, trigger_kind).await? {
|
||||
// The mode reported is the draft's, which is what deploying it will write.
|
||||
// The mode reported is the one deploying the draft leaves: a deployed app keeps
|
||||
// its own, which the Share dialog sets, and a never-deployed one takes the draft's.
|
||||
let mode = if item_type == "app" {
|
||||
let mode = item
|
||||
.get("value")
|
||||
.and_then(|v| v.get("policy"))
|
||||
.and_then(|p| p.get("execution_mode"));
|
||||
let deployed = if item_exists(ctx, "app", None, path).await? {
|
||||
deployed_execution_mode(ctx, path).await?
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let mode = deployed.as_ref().or_else(|| {
|
||||
item.get("value")
|
||||
.and_then(|v| v.get("policy"))
|
||||
.and_then(|p| p.get("execution_mode"))
|
||||
});
|
||||
describe_app_exposure(ctx, mode).await
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
anonymous usage-stats payload. It answers "does anyone use this, and which variant do they pick"
|
||||
without any identifying data leaving the instance.
|
||||
|
||||
It currently carries 91 registered actions across thirty-five features (`ai_session`, `ai_chat`,
|
||||
It currently carries 93 registered actions across thirty-six features (`ai_session`, `ai_chat`,
|
||||
`ai_fix`, `ai_agent`, `ai_decision`, `ai_agent_eval`, `app_sandbox`, `datatable`, `db_manager`, `flow_editor`,
|
||||
`flow_run`, `flow_step`, `home`, `header_nav`, `run_form`, `debugger`, `trigger`, `command_script`,
|
||||
`mcp`, `mcp_workspace`, `hub_script`, `usage_meter`, `sso_groups_claim`, `cloud_trial_offer`,
|
||||
`job_token_scopes`, `worker_draining`, `worker_group`, `worker_resource_stats`,
|
||||
`dev_workspace_isolation`, `slack_agent`, `variable_expiration`, `anthropic_federation`,
|
||||
`deployment_request`, `fork_roles`, `git_sync_review`). Nearly all of the
|
||||
`flow_run`, `flow_step`, `home`, `header_nav`, `run_form`, `sharing`, `debugger`, `trigger`,
|
||||
`command_script`, `mcp`, `mcp_workspace`, `hub_script`, `usage_meter`, `sso_groups_claim`,
|
||||
`cloud_trial_offer`, `job_token_scopes`, `worker_draining`, `worker_group`,
|
||||
`worker_resource_stats`, `dev_workspace_isolation`, `slack_agent`, `variable_expiration`,
|
||||
`anthropic_federation`, `deployment_request`, `fork_roles`, `git_sync_review`). Nearly all of the
|
||||
product is uninstrumented, so new user-facing work is the opportunity to change that.
|
||||
|
||||
## When to instrument
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import DeployOnBehalfOfDialog from '$lib/components/itemSettings/DeployOnBehalfOfDialog.svelte'
|
||||
import { deployAsksOnBehalfOf } from '$lib/components/itemSettings/onBehalfOf'
|
||||
import { movesToAnotherOwner } from '$lib/components/itemSettings/inheritedAccess'
|
||||
import { useFolderDefaultPermissionedAs } from '$lib/components/useFolderDefaultPermissionedAs.svelte'
|
||||
import {
|
||||
FlowService,
|
||||
@@ -78,9 +79,24 @@
|
||||
import { setNoteEditorContext } from './graph/noteEditor.svelte'
|
||||
import { GroupEditor, setGroupEditorContext } from './graph/groupEditor.svelte'
|
||||
import { cleanFlow } from './flows/utils.svelte'
|
||||
import { DiffIcon, HistoryIcon, FileJson, Settings, Undo, Redo, Disc } from 'lucide-svelte'
|
||||
import {
|
||||
DiffIcon,
|
||||
HistoryIcon,
|
||||
FileJson,
|
||||
Settings,
|
||||
Undo,
|
||||
Redo,
|
||||
Disc,
|
||||
UserPlus
|
||||
} from 'lucide-svelte'
|
||||
import { muteErrorHandlerMenuItem } from './details/errorHandlerToggle'
|
||||
import { useDeployedItem } from './details/deployedItem.svelte'
|
||||
import ShareDialog from './itemSettings/ShareDialog.svelte'
|
||||
import FirstDeployDialog, {
|
||||
applyFirstDeployMembers,
|
||||
type FirstDeployChoice
|
||||
} from './itemSettings/FirstDeployDialog.svelte'
|
||||
import ShareButton from './itemSettings/ShareButton.svelte'
|
||||
import Awareness from './Awareness.svelte'
|
||||
import { getAllModules } from './flows/flowExplorer'
|
||||
import { type FlowCopilotContext } from './copilot/flow'
|
||||
@@ -206,7 +222,6 @@
|
||||
|
||||
let savedOnBehalfOfEmail = writable<string | undefined>(savedFlow?.on_behalf_of_email)
|
||||
let savedOnBehalfOfPermissionedAs = writable<string | undefined>(savedFlow?.on_behalf_of)
|
||||
const isNewFlow = $derived(newFlow || initialPath == '')
|
||||
let deployDialogOpen = $state(false)
|
||||
let deployDialogMsg = $state('')
|
||||
let deployButton: DeployButton | undefined = $state(undefined)
|
||||
@@ -215,7 +230,7 @@
|
||||
// who the flow runs as: `savedFlow` carries its draft's user. A flow that runs on behalf of
|
||||
// nobody has no email field at all, so its absence is synced too.
|
||||
$effect(() => {
|
||||
const saved = deployedFlowPath ? deployedItem.current : savedFlow
|
||||
const saved = deployedRowPath ? deployedItem.current : savedFlow
|
||||
if (saved) {
|
||||
savedOnBehalfOfEmail.set(saved.on_behalf_of_email)
|
||||
savedOnBehalfOfPermissionedAs.set(saved.on_behalf_of)
|
||||
@@ -491,11 +506,35 @@
|
||||
}
|
||||
|
||||
async function handleSaveFlow(deploymentMsg?: string) {
|
||||
pendingFirstDeploy = undefined
|
||||
if (ownsPageHeader && neverDeployed) {
|
||||
// The dialog also asks who the flow runs on behalf of, for the path it chose.
|
||||
const choice = await firstDeployDialog?.ask({
|
||||
kind: 'flow',
|
||||
summary: flowStore.val.summary ?? '',
|
||||
path: $pathStore,
|
||||
runAs: {
|
||||
email: flowStore.val.on_behalf_of_email,
|
||||
permissionedAs: flowStore.val.on_behalf_of,
|
||||
targetWorkspace: opWorkspace ?? ''
|
||||
}
|
||||
})
|
||||
if (!choice) return
|
||||
flowStore.val.summary = choice.summary
|
||||
$pathStore = choice.path
|
||||
if (choice.runAs) {
|
||||
flowStore.val.on_behalf_of_email = choice.runAs.email
|
||||
flowStore.val.on_behalf_of = choice.runAs.permissionedAs
|
||||
}
|
||||
pendingFirstDeploy = choice
|
||||
await deployFlow(choice.message)
|
||||
return
|
||||
}
|
||||
// Compares against the user deployed right now, which updates the saved stores; a failed
|
||||
// lookup asks rather than trusting the draft's user.
|
||||
const deployed = deployedFlowPath ? await deployedItem.refetch() : undefined
|
||||
if (
|
||||
(deployedFlowPath && !deployed) ||
|
||||
const deployed = deployedRowPath ? await deployedItem.refetch() : undefined
|
||||
const asksRunAs =
|
||||
(!!deployedRowPath && !deployed) ||
|
||||
// Asks while the folder default is loading: the backend would apply it unconfirmed.
|
||||
folderDefault.loading ||
|
||||
deployAsksOnBehalfOf('flow', {
|
||||
@@ -506,7 +545,16 @@
|
||||
savedPermissionedAs: deployed?.on_behalf_of,
|
||||
folderDefault: folderDefault.value
|
||||
})
|
||||
const from = deployedRowPath
|
||||
if (
|
||||
shareDialog &&
|
||||
from &&
|
||||
movesToAnotherOwner(from, $pathStore) &&
|
||||
!(await shareDialog.confirmMove('flow', from, $pathStore, asksRunAs ? 'Next' : 'Deploy'))
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (asksRunAs) {
|
||||
deployDialogMsg = deploymentMsg ?? ''
|
||||
deployDialogOpen = true
|
||||
return
|
||||
@@ -520,6 +568,30 @@
|
||||
})
|
||||
}
|
||||
|
||||
let shareDialog: ShareDialog | undefined = $state()
|
||||
let firstDeployDialog: FirstDeployDialog | undefined = $state()
|
||||
/** Where a deploy from this editor left the flow, which an embedder may keep mounted: the
|
||||
* route's path then still names the draft or the pre-rename row. */
|
||||
let deployedPath: string | undefined = $state()
|
||||
const neverDeployed = $derived(
|
||||
deployedPath === undefined && (newFlow || initialPath == '' || savedFlow?.no_deployed === true)
|
||||
)
|
||||
let pendingFirstDeploy: FirstDeployChoice | undefined = undefined
|
||||
// Where the deployed flow is, which a staged path change moves it from: `initialPath` is
|
||||
// re-seeded from a staged rename.
|
||||
const deployedRowPath = $derived(
|
||||
neverDeployed ? undefined : (deployedPath ?? (userDraftPath || initialPath))
|
||||
)
|
||||
|
||||
function openShare() {
|
||||
if (!deployedRowPath) return
|
||||
shareDialog?.openDialog('flow', deployedRowPath, {
|
||||
source: 'editor_header',
|
||||
fromEditor: true,
|
||||
stagedPath: $pathStore
|
||||
})
|
||||
}
|
||||
|
||||
async function handleSaveFlowInternal(deploymentMsg?: string) {
|
||||
await compareVersions()
|
||||
if (onLatest || initialPath == '' || newFlow) {
|
||||
@@ -779,6 +851,12 @@
|
||||
path: $pathStore
|
||||
} as Flow
|
||||
setDraftTriggers([])
|
||||
deployedPath = $pathStore
|
||||
if (pendingFirstDeploy) {
|
||||
const { members } = pendingFirstDeploy
|
||||
pendingFirstDeploy = undefined
|
||||
await applyFirstDeployMembers(opWorkspace!, 'flow', $pathStore, members)
|
||||
}
|
||||
loadingSave = false
|
||||
// Settings shows the deployed run-as user while the editor stays open, a session's
|
||||
// included: read the version just written.
|
||||
@@ -816,7 +894,7 @@
|
||||
const pathStore = writable<string>(untrack(() => pathStoreInit) ?? initialPath)
|
||||
// Only the flow's first deploy takes the folder's default user.
|
||||
const folderDefault = useFolderDefaultPermissionedAs(
|
||||
() => (isNewFlow ? $pathStore : undefined),
|
||||
() => (neverDeployed ? $pathStore : undefined),
|
||||
() => opWorkspace
|
||||
)
|
||||
|
||||
@@ -1051,7 +1129,8 @@
|
||||
outputPickerOpenFns,
|
||||
savedOnBehalfOfEmail,
|
||||
savedOnBehalfOfPermissionedAs,
|
||||
opWorkspace: () => opWorkspace
|
||||
opWorkspace: () => opWorkspace,
|
||||
deployedPath: () => deployedRowPath
|
||||
})
|
||||
|
||||
// Set up NoteEditor context for note editing capabilities
|
||||
@@ -1402,7 +1481,20 @@
|
||||
const mod = isMac() ? '⌘' : 'Ctrl+'
|
||||
|
||||
function getMoreItems(): Item[] {
|
||||
const leadingItems = [...diffMenuItems, ...baseMenuItems]
|
||||
const leadingItems = [
|
||||
...diffMenuItems,
|
||||
...(ownsPageHeader
|
||||
? [
|
||||
{
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
disabled: neverDeployed,
|
||||
action: openShare
|
||||
}
|
||||
]
|
||||
: []),
|
||||
...baseMenuItems
|
||||
]
|
||||
return [
|
||||
...leadingItems,
|
||||
{
|
||||
@@ -1428,27 +1520,21 @@
|
||||
// Before the first deploy the switch edits the flow, and the create sends it.
|
||||
muteErrorHandlerMenuItem({
|
||||
kind: 'flow',
|
||||
deployed: !!deployedFlowPath,
|
||||
muted: deployedFlowPath ? deployedItem.muted : !!editedFlow().ws_error_handler_muted,
|
||||
deployed: !!deployedRowPath,
|
||||
muted: deployedRowPath ? deployedItem.muted : !!editedFlow().ws_error_handler_muted,
|
||||
hasEnterpriseLicense: !!$enterpriseLicense,
|
||||
onToggle: () => {
|
||||
if (deployedFlowPath) deployedItem.toggle()
|
||||
if (deployedRowPath) deployedItem.toggle()
|
||||
else editedFlow().ws_error_handler_muted = !editedFlow().ws_error_handler_muted
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
const editedFlow = () => flowStore.val as ExtendedOpenFlow
|
||||
// The URL path: `initialPath` is the staged name once a draft that renames the flow reloads.
|
||||
const deployedFlowPath = $derived(
|
||||
!newFlow && savedFlow && savedFlow.no_deployed !== true
|
||||
? userDraftPath || initialPath || undefined
|
||||
: undefined
|
||||
)
|
||||
const deployedItem = useDeployedItem(
|
||||
'flow',
|
||||
() => opWorkspace,
|
||||
() => deployedFlowPath
|
||||
() => deployedRowPath
|
||||
)
|
||||
|
||||
function onCustomUiChange(
|
||||
@@ -1635,15 +1721,20 @@
|
||||
|
||||
{@render children?.()}
|
||||
|
||||
{#if ownsPageHeader}
|
||||
<ShareDialog bind:this={shareDialog} />
|
||||
<FirstDeployDialog bind:this={firstDeployDialog} />
|
||||
{/if}
|
||||
|
||||
<DeployOnBehalfOfDialog
|
||||
kind="flow"
|
||||
bind:open={deployDialogOpen}
|
||||
bind:message={deployDialogMsg}
|
||||
bind:email={flowStore.val.on_behalf_of_email}
|
||||
bind:permissionedAs={flowStore.val.on_behalf_of}
|
||||
savedEmail={isNewFlow ? undefined : $savedOnBehalfOfEmail}
|
||||
savedPermissionedAs={isNewFlow ? undefined : $savedOnBehalfOfPermissionedAs}
|
||||
isNew={isNewFlow}
|
||||
savedEmail={neverDeployed ? undefined : $savedOnBehalfOfEmail}
|
||||
savedPermissionedAs={neverDeployed ? undefined : $savedOnBehalfOfPermissionedAs}
|
||||
isNew={neverDeployed}
|
||||
folderDefault={folderDefault.value}
|
||||
folderDefaultLoading={folderDefault.loading}
|
||||
targetWorkspace={opWorkspace ?? ''}
|
||||
@@ -1892,6 +1983,14 @@
|
||||
{/if}
|
||||
|
||||
<OpenInSessionButton source={headerSessionOpen} />
|
||||
{#if !phoneTopbar}
|
||||
<ShareButton
|
||||
deployed={!neverDeployed}
|
||||
iconOnly={compactTopbar}
|
||||
unifiedSize={headerBtnSize}
|
||||
onclick={openShare}
|
||||
/>
|
||||
{/if}
|
||||
<DeployButton
|
||||
bind:this={deployButton}
|
||||
on:save={async ({ detail }) => await handleSaveFlow(detail)}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
import DeployOnBehalfOfDialog from '$lib/components/itemSettings/DeployOnBehalfOfDialog.svelte'
|
||||
import { deployAsksOnBehalfOf } from '$lib/components/itemSettings/onBehalfOf'
|
||||
import { movesToAnotherOwner } from '$lib/components/itemSettings/inheritedAccess'
|
||||
import PathMoveNote from '$lib/components/itemSettings/PathMoveNote.svelte'
|
||||
import { useFolderDefaultPermissionedAs } from '$lib/components/useFolderDefaultPermissionedAs.svelte'
|
||||
import {
|
||||
ScriptService,
|
||||
@@ -49,12 +51,18 @@
|
||||
type Value
|
||||
} from '$lib/utils'
|
||||
import Path from './Path.svelte'
|
||||
import ShareDialog from './itemSettings/ShareDialog.svelte'
|
||||
import FirstDeployDialog, {
|
||||
applyFirstDeployMembers,
|
||||
type FirstDeployChoice
|
||||
} from './itemSettings/FirstDeployDialog.svelte'
|
||||
import ShareButton from './itemSettings/ShareButton.svelte'
|
||||
import { invalidateWorkspacePaths } from './PathNameAutocomplete.svelte'
|
||||
import { notifyContractWarnings } from './assets/AssetGraph/schemaContracts'
|
||||
import ScriptEditor from './ScriptEditor.svelte'
|
||||
import DbtEditor from './dbt/DbtEditor.svelte'
|
||||
import { findModulePathClash } from './scriptModulePath'
|
||||
import { Alert, Button, Drawer, Tab, TabContent, Tabs } from './common'
|
||||
import { Button, Drawer, Tab, TabContent, Tabs } from './common'
|
||||
import LanguageIcon from './common/languageIcons/LanguageIcon.svelte'
|
||||
import type { SupportedLanguage } from '$lib/common'
|
||||
import Tooltip from './Tooltip.svelte'
|
||||
@@ -72,6 +80,7 @@
|
||||
Settings,
|
||||
Shuffle,
|
||||
Tag,
|
||||
UserPlus,
|
||||
X
|
||||
} from 'lucide-svelte'
|
||||
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
|
||||
@@ -236,6 +245,31 @@
|
||||
const operatingUser = useOperatingUser()
|
||||
const actingUser = $derived(operatingUser.current)
|
||||
const opWorkspace = $derived(autosaveWorkspace ?? $operatingWorkspace)
|
||||
|
||||
let shareDialog: ShareDialog | undefined = $state()
|
||||
let firstDeployDialog: FirstDeployDialog | undefined = $state()
|
||||
/** Where a deploy from this editor left the script. After a deploy that stays,
|
||||
* `savedScript.no_deployed` survives and the route's path still names the draft or the
|
||||
* pre-rename row. */
|
||||
let deployedPath: string | undefined = $state()
|
||||
const neverDeployed = $derived(
|
||||
deployedPath === undefined && (initialPath == '' || savedScript?.no_deployed === true)
|
||||
)
|
||||
let pendingFirstDeploy: FirstDeployChoice | undefined = undefined
|
||||
// Where the deployed script is, which a staged path change moves it from: `initialPath` is
|
||||
// re-seeded from a staged rename.
|
||||
const deployedRowPath = $derived(
|
||||
neverDeployed ? undefined : (deployedPath ?? (userDraftPath || initialPath))
|
||||
)
|
||||
|
||||
function openShare() {
|
||||
if (!deployedRowPath) return
|
||||
shareDialog?.openDialog('script', deployedRowPath, {
|
||||
source: 'editor_header',
|
||||
fromEditor: true,
|
||||
stagedPath: script.path
|
||||
})
|
||||
}
|
||||
const indicatorPath = $derived(autosavePath ?? userDraftPath)
|
||||
|
||||
// The shared `workerTags` store caches tags for the navigation workspace. A
|
||||
@@ -245,17 +279,13 @@
|
||||
let localWorkerTags = $state<string[] | undefined>(undefined)
|
||||
const scriptWorkerTags = $derived(usesLocalTags ? localWorkerTags : $workerTags)
|
||||
|
||||
const scriptIsDeployed = $derived(!!initialPath && !!savedScript && !savedScript.no_deployed)
|
||||
// The URL path: `initialPath` is the staged name once a draft that renames the script reloads.
|
||||
const deployedItem = useDeployedItem(
|
||||
'script',
|
||||
() => opWorkspace,
|
||||
() => (scriptIsDeployed ? userDraftPath || initialPath : undefined)
|
||||
() => deployedRowPath
|
||||
)
|
||||
// Who the deployed script runs as: `savedScript` carries its draft's user.
|
||||
const savedRunAs = $derived(
|
||||
scriptIsDeployed ? (deployedItem.current ?? savedScript) : savedScript
|
||||
)
|
||||
const savedRunAs = $derived(deployedRowPath ? (deployedItem.current ?? savedScript) : savedScript)
|
||||
const offersMute = $derived(customUi?.settingsPanel?.metadata?.disableMute !== true)
|
||||
|
||||
function getMoreMenuItems(): Item[] {
|
||||
@@ -266,11 +296,11 @@
|
||||
// Before the first deploy the switch edits the script, and the deploy sends it.
|
||||
muteErrorHandlerMenuItem({
|
||||
kind: 'script',
|
||||
deployed: scriptIsDeployed,
|
||||
muted: scriptIsDeployed ? deployedItem.muted : !!script.ws_error_handler_muted,
|
||||
deployed: !!deployedRowPath,
|
||||
muted: deployedRowPath ? deployedItem.muted : !!script.ws_error_handler_muted,
|
||||
hasEnterpriseLicense: !!$enterpriseLicense,
|
||||
onToggle: () => {
|
||||
if (scriptIsDeployed) deployedItem.toggle()
|
||||
if (deployedRowPath) deployedItem.toggle()
|
||||
else script.ws_error_handler_muted = !script.ws_error_handler_muted
|
||||
}
|
||||
})
|
||||
@@ -296,6 +326,9 @@
|
||||
...(phoneTopbar && customUi?.topBar?.settings != false
|
||||
? [{ displayName: 'Settings', icon: Settings, action: () => (metadataOpen = true) }]
|
||||
: []),
|
||||
...(phoneTopbar && ownsPageHeader
|
||||
? [{ displayName: 'Share', icon: UserPlus, disabled: neverDeployed, action: openShare }]
|
||||
: []),
|
||||
...(customUi?.topBar?.tagEdit != false && hasTags
|
||||
? [
|
||||
{
|
||||
@@ -314,11 +347,10 @@
|
||||
let args: Record<string, any> = $state(untrack(() => initialArgs)) // Test args input
|
||||
let selectedInputTab: 'main' | 'preprocessor' | 'diagram' = $state('main')
|
||||
let hasPreprocessor = $state(false)
|
||||
const isNewScript = $derived(initialPath == '' || savedScript?.no_deployed === true)
|
||||
// Only the script's first deploy takes the folder's default user.
|
||||
// A rename is a create at the new path, so the backend applies that path's folder default too.
|
||||
const folderDefault = useFolderDefaultPermissionedAs(
|
||||
() => (isNewScript || script.path !== (userDraftPath || initialPath) ? script.path : undefined),
|
||||
() => (!deployedRowPath || script.path !== deployedRowPath ? script.path : undefined),
|
||||
() => opWorkspace
|
||||
)
|
||||
let deployDialogOpen = $state(false)
|
||||
@@ -662,11 +694,38 @@
|
||||
}
|
||||
|
||||
async function handleEditScript(stay: boolean, deployMsg?: string): Promise<void> {
|
||||
// Every deploy path of the full-page editor comes through here, the message popover and
|
||||
// "Deploy & Stay here" included.
|
||||
pendingFirstDeploy = undefined
|
||||
if (ownsPageHeader && neverDeployed) {
|
||||
// The dialog also asks who the script runs on behalf of, for the path it chose.
|
||||
const choice = await firstDeployDialog?.ask({
|
||||
kind: 'script',
|
||||
summary: script.summary,
|
||||
path: script.path,
|
||||
pathChosen: dirtyPath,
|
||||
runAs: {
|
||||
email: script.on_behalf_of_email,
|
||||
permissionedAs: script.on_behalf_of,
|
||||
targetWorkspace: opWorkspace ?? ''
|
||||
}
|
||||
})
|
||||
if (!choice) return
|
||||
script.summary = choice.summary
|
||||
script.path = choice.path
|
||||
if (choice.runAs) {
|
||||
script.on_behalf_of_email = choice.runAs.email
|
||||
script.on_behalf_of = choice.runAs.permissionedAs
|
||||
}
|
||||
pendingFirstDeploy = choice
|
||||
await deployScript(stay, choice.message)
|
||||
return
|
||||
}
|
||||
// Compares against the user deployed right now; a failed lookup asks rather than trusting
|
||||
// the draft's user.
|
||||
const deployed = scriptIsDeployed ? await deployedItem.refetch() : undefined
|
||||
if (
|
||||
(scriptIsDeployed && !deployed) ||
|
||||
const deployed = deployedRowPath ? await deployedItem.refetch() : undefined
|
||||
const asksRunAs =
|
||||
(!!deployedRowPath && !deployed) ||
|
||||
// Asks while the folder default is loading: the backend would apply it unconfirmed.
|
||||
folderDefault.loading ||
|
||||
deployAsksOnBehalfOf('script', {
|
||||
@@ -677,7 +736,16 @@
|
||||
savedPermissionedAs: deployed?.on_behalf_of,
|
||||
folderDefault: folderDefault.value
|
||||
})
|
||||
const from = deployedRowPath
|
||||
if (
|
||||
shareDialog &&
|
||||
from &&
|
||||
movesToAnotherOwner(from, script.path) &&
|
||||
!(await shareDialog.confirmMove('script', from, script.path, asksRunAs ? 'Next' : 'Deploy'))
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (asksRunAs) {
|
||||
deployDialogStay = stay
|
||||
deployDialogMsg = deployMsg ?? ''
|
||||
deployDialogOpen = true
|
||||
@@ -850,11 +918,10 @@
|
||||
|
||||
// Muting applies to the deployed script at once, from the editor menu or the script's
|
||||
// page, and a new version without the value is unmuted: keep the one deployed now.
|
||||
// The deployed row sits at the URL path: `initialPath` is the staged name after a reload.
|
||||
const deployedMuted = scriptIsDeployed
|
||||
const deployedMuted = deployedRowPath
|
||||
? await ScriptService.getScriptByPath({
|
||||
workspace: opWorkspace!,
|
||||
path: userDraftPath || initialPath
|
||||
path: deployedRowPath
|
||||
})
|
||||
.then((s) => !!s.ws_error_handler_muted)
|
||||
.catch(() => undefined)
|
||||
@@ -942,6 +1009,12 @@
|
||||
const { draft_triggers: _, ...newScript } = structuredClone($state.snapshot(script))
|
||||
savedScript = structuredClone($state.snapshot(newScript))
|
||||
setDraftTriggers([])
|
||||
deployedPath = script.path
|
||||
if (pendingFirstDeploy) {
|
||||
const { members } = pendingFirstDeploy
|
||||
pendingFirstDeploy = undefined
|
||||
await applyFirstDeployMembers(opWorkspace!, 'script', script.path, members)
|
||||
}
|
||||
|
||||
if (!disableHistoryChange) {
|
||||
history.replaceState(history.state, '', `/scripts/edit/${script.path}`)
|
||||
@@ -1476,9 +1549,9 @@
|
||||
bind:message={deployDialogMsg}
|
||||
bind:email={script.on_behalf_of_email}
|
||||
bind:permissionedAs={script.on_behalf_of}
|
||||
savedEmail={isNewScript ? undefined : savedRunAs?.on_behalf_of_email}
|
||||
savedPermissionedAs={isNewScript ? undefined : savedRunAs?.on_behalf_of}
|
||||
isNew={isNewScript}
|
||||
savedEmail={neverDeployed ? undefined : savedRunAs?.on_behalf_of_email}
|
||||
savedPermissionedAs={neverDeployed ? undefined : savedRunAs?.on_behalf_of}
|
||||
isNew={neverDeployed}
|
||||
folderDefault={folderDefault.value}
|
||||
folderDefaultLoading={folderDefault.loading}
|
||||
targetWorkspace={opWorkspace ?? ''}
|
||||
@@ -1511,6 +1584,11 @@
|
||||
onCanceled={() => (perpetualRunsToConfirm = undefined)}
|
||||
/>
|
||||
|
||||
{#if ownsPageHeader}
|
||||
<ShareDialog bind:this={shareDialog} />
|
||||
<FirstDeployDialog bind:this={firstDeployDialog} />
|
||||
{/if}
|
||||
|
||||
{#if editRights.roleCanAuthor('script')}
|
||||
<Drawer
|
||||
placement="right"
|
||||
@@ -1644,14 +1722,11 @@
|
||||
kind="script"
|
||||
workspaceOverride={opWorkspace}
|
||||
/>
|
||||
{#if initialPath && script.path && script.path !== initialPath}
|
||||
<Alert
|
||||
type="info"
|
||||
size="xs"
|
||||
title="Deploy the script to make the path change effective."
|
||||
class="mt-2"
|
||||
/>
|
||||
{/if}
|
||||
<PathMoveNote
|
||||
kind="script"
|
||||
deployedPath={deployedRowPath}
|
||||
path={script.path}
|
||||
/>
|
||||
</Label>
|
||||
<Label label="Description">
|
||||
<MetadataGen
|
||||
@@ -1909,7 +1984,7 @@
|
||||
savedEmail={savedRunAs?.on_behalf_of_email}
|
||||
savedPermissionedAs={savedRunAs?.on_behalf_of}
|
||||
targetWorkspace={opWorkspace ?? ''}
|
||||
isNew={isNewScript}
|
||||
isNew={neverDeployed}
|
||||
/>
|
||||
<InvisibleRunsSetting
|
||||
kind="script"
|
||||
@@ -2252,6 +2327,14 @@
|
||||
{#if ownsPageHeader}
|
||||
<OpenInSessionButton source={headerSessionOpen()} />
|
||||
{/if}
|
||||
{#if ownsPageHeader && !phoneTopbar}
|
||||
<ShareButton
|
||||
deployed={!neverDeployed}
|
||||
iconOnly={compactTopbar}
|
||||
unifiedSize={headerBtnSize}
|
||||
onclick={openShare}
|
||||
/>
|
||||
{/if}
|
||||
<DeployButton
|
||||
bind:this={deployButton}
|
||||
loading={!fullyLoaded}
|
||||
|
||||
@@ -1,50 +1,25 @@
|
||||
<script lang="ts">
|
||||
import TableCustom from './TableCustom.svelte'
|
||||
|
||||
import {
|
||||
GroupService,
|
||||
UserService,
|
||||
GranularAclService,
|
||||
ResourceService,
|
||||
FolderService
|
||||
} from '$lib/gen'
|
||||
import type { Folder } from '$lib/gen/types.gen'
|
||||
import { ResourceService } from '$lib/gen'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
|
||||
import { Alert, Button, Drawer } from './common'
|
||||
import { Drawer } from './common'
|
||||
import DrawerContent from './common/drawer/DrawerContent.svelte'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import { isOwner } from '$lib/utils'
|
||||
import ToggleButtonGroup from './common/toggleButton-v2/ToggleButtonGroup.svelte'
|
||||
import ToggleButton from './common/toggleButton-v2/ToggleButton.svelte'
|
||||
import Select from './select/Select.svelte'
|
||||
import { safeSelectItems } from './select/utils.svelte'
|
||||
import Toggle from './Toggle.svelte'
|
||||
import { Trash } from 'lucide-svelte'
|
||||
import { DEMO_RESTRICTION_HINT, isDemoWorkspaceRestricted } from '$lib/cloud'
|
||||
import { useScheduleLock, useTriggerLock } from '$lib/operatorWriteRights'
|
||||
import {
|
||||
useOperatingWorkspace,
|
||||
useOperatingUser,
|
||||
useReadOnlyWorkspace
|
||||
} from '$lib/components/operatingWorkspace.svelte'
|
||||
const scheduleLock = useScheduleLock()
|
||||
const triggerLock = useTriggerLock()
|
||||
import { useOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte'
|
||||
import ItemAccessList from './itemSettings/ItemAccessList.svelte'
|
||||
import ShareDialog, { type ShareKind } from './itemSettings/ShareDialog.svelte'
|
||||
|
||||
interface Props {
|
||||
/** Where this is mounted, for the Share dialog's telemetry. */
|
||||
source?: 'list' | 'detail' | 'home'
|
||||
}
|
||||
|
||||
let { source = 'list' }: Props = $props()
|
||||
|
||||
const operatingWorkspace = useOperatingWorkspace()
|
||||
const operatingUser = useOperatingUser()
|
||||
const readOnly = useReadOnlyWorkspace()
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
let restricted = $derived(
|
||||
isDemoWorkspaceRestricted(
|
||||
$operatingWorkspace,
|
||||
operatingUser.current?.is_admin,
|
||||
operatingUser.current?.is_super_admin
|
||||
)
|
||||
)
|
||||
|
||||
type Kind =
|
||||
| 'script'
|
||||
| 'group_'
|
||||
@@ -66,78 +41,18 @@
|
||||
| 'amqp_trigger'
|
||||
| 'email_trigger'
|
||||
| 'volume'
|
||||
// $state so the write lock below tracks whichever object the drawer was last opened on. The
|
||||
// cast keeps TS from narrowing it to the initial value, which openDrawer always replaces.
|
||||
// $state so the access list tracks whichever object the drawer was last opened on. The cast
|
||||
// keeps TS from narrowing it to the initial value, which openDrawer always replaces.
|
||||
let kind: Kind = $state('script' as Kind)
|
||||
|
||||
// Sharing a schedule or trigger is a write operators can lose. Gated here rather than at the
|
||||
// dozen menu entries opening this drawer, so a new entry point is covered; reading stays open.
|
||||
// Matched on the suffix, unlike the server (the real boundary, which lists kinds), so a
|
||||
// trigger kind added later greys out here without a second edit.
|
||||
let writeLock = $derived(
|
||||
kind === 'schedule' ? $scheduleLock : kind.endsWith('_trigger') ? $triggerLock : undefined
|
||||
)
|
||||
let sharingDisabled = $derived(restricted || !!writeLock)
|
||||
|
||||
let path: string = $state('')
|
||||
|
||||
let ownerKind: 'user' | 'group' = $state('user')
|
||||
let owner: string = $state('')
|
||||
|
||||
let newOwner: string = $derived.by(
|
||||
() => owner && [ownerKind === 'group' ? 'g' : 'u', owner].join('/')
|
||||
)
|
||||
let write: boolean = false
|
||||
let acls: [string, boolean][] = $state([])
|
||||
let groups: String[] = $state([])
|
||||
let usernames: string[] = $state([])
|
||||
let isOwnerOverride: boolean | undefined = $state()
|
||||
|
||||
let drawer: Drawer | undefined = $state()
|
||||
let shareDialog: ShareDialog | undefined = $state()
|
||||
|
||||
let linkedVarPaths: string[] = $state([])
|
||||
let alsoApplyToLinked: boolean = $state(true)
|
||||
|
||||
let defaultPerms: { label: string; write: boolean }[] = $state([])
|
||||
let defaultPermsLabel: string = $state('')
|
||||
|
||||
async function loadDefaultPerms() {
|
||||
const currentPath = path
|
||||
const parts = currentPath.split('/')
|
||||
if (parts[0] === 'f' && parts.length >= 2) {
|
||||
const folderName = parts[1]
|
||||
defaultPermsLabel = `Folder f/${folderName} permissions`
|
||||
try {
|
||||
const folder: Folder = await FolderService.getFolder({
|
||||
workspace: $operatingWorkspace!,
|
||||
name: folderName
|
||||
})
|
||||
if (path !== currentPath) return
|
||||
const perms: { label: string; write: boolean }[] = []
|
||||
for (const owner of folder.owners) {
|
||||
perms.push({ label: owner, write: true })
|
||||
}
|
||||
for (const [owner, write] of Object.entries(folder.extra_perms ?? {})) {
|
||||
if (!folder.owners.includes(owner)) {
|
||||
perms.push({ label: owner, write })
|
||||
}
|
||||
}
|
||||
defaultPerms = perms
|
||||
} catch {
|
||||
if (path !== currentPath) return
|
||||
defaultPerms = []
|
||||
}
|
||||
} else if (parts[0] === 'u' && parts.length >= 2) {
|
||||
defaultPermsLabel = `User u/${parts[1]} permissions`
|
||||
defaultPerms = [{ label: `u/${parts[1]}`, write: true }]
|
||||
} else if (parts[0] === 'g' && parts.length >= 2) {
|
||||
defaultPermsLabel = `Group g/${parts[1]} permissions`
|
||||
defaultPerms = [{ label: `g/${parts[1]}`, write: true }]
|
||||
} else {
|
||||
defaultPerms = []
|
||||
defaultPermsLabel = ''
|
||||
}
|
||||
}
|
||||
|
||||
function collectVarRefs(value: unknown): string[] {
|
||||
const paths: string[] = []
|
||||
function walk(v: unknown) {
|
||||
@@ -172,228 +87,51 @@
|
||||
}
|
||||
}
|
||||
|
||||
let ownsItem = $state(false)
|
||||
// A session can switch to Use while the drawer is open, so read-only is read live.
|
||||
const own = $derived(ownsItem && !readOnly($operatingWorkspace))
|
||||
export async function openDrawer(newPath: string, kind_l: Kind, isOwnerOverride?: boolean) {
|
||||
const SHARE_DIALOG_KINDS: Kind[] = ['flow', 'script', 'app', 'raw_app']
|
||||
|
||||
export async function openDrawer(newPath: string, kind_l: Kind, isOwnerOverride_l?: boolean) {
|
||||
if (SHARE_DIALOG_KINDS.includes(kind_l)) {
|
||||
shareDialog?.openDialog(kind_l as ShareKind, newPath, { source })
|
||||
return
|
||||
}
|
||||
path = newPath
|
||||
kind = kind_l
|
||||
isOwnerOverride = isOwnerOverride_l
|
||||
alsoApplyToLinked = true
|
||||
loadAcls()
|
||||
loadGroups()
|
||||
loadUsernames()
|
||||
loadLinkedVarPaths()
|
||||
loadDefaultPerms()
|
||||
if (isOwnerOverride !== undefined) {
|
||||
ownsItem = isOwnerOverride
|
||||
} else {
|
||||
loadOwner()
|
||||
}
|
||||
drawer?.openDrawer()
|
||||
}
|
||||
|
||||
async function loadOwner() {
|
||||
ownsItem = isOwner(path, operatingUser.current!, $operatingWorkspace!)
|
||||
}
|
||||
|
||||
async function loadAcls() {
|
||||
acls = Object.entries(
|
||||
await GranularAclService.getGranularAcls({ workspace: $operatingWorkspace!, path, kind })
|
||||
)
|
||||
}
|
||||
|
||||
async function loadGroups(): Promise<void> {
|
||||
groups = await GroupService.listGroupNames({ workspace: $operatingWorkspace! })
|
||||
}
|
||||
|
||||
async function loadUsernames(): Promise<void> {
|
||||
usernames = await UserService.listUsernames({ workspace: $operatingWorkspace! })
|
||||
}
|
||||
|
||||
async function deleteAcl(owner: string) {
|
||||
try {
|
||||
await GranularAclService.removeGranularAcls({
|
||||
workspace: $operatingWorkspace!,
|
||||
path,
|
||||
kind,
|
||||
requestBody: { owner }
|
||||
})
|
||||
if (alsoApplyToLinked) {
|
||||
for (const varPath of linkedVarPaths) {
|
||||
try {
|
||||
await GranularAclService.removeGranularAcls({
|
||||
workspace: $operatingWorkspace!,
|
||||
path: varPath,
|
||||
kind: 'variable',
|
||||
requestBody: { owner }
|
||||
})
|
||||
} catch (err) {
|
||||
sendUserToast(`Failed to update variable ${varPath}: ${err}`, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
loadAcls()
|
||||
dispatch('change', { path, kind })
|
||||
} catch (err) {
|
||||
sendUserToast(err.toString(), true)
|
||||
}
|
||||
}
|
||||
|
||||
async function addAcl(owner: string, write: boolean) {
|
||||
await GranularAclService.addGranularAcls({
|
||||
workspace: $operatingWorkspace!,
|
||||
path,
|
||||
kind,
|
||||
requestBody: { owner, write }
|
||||
})
|
||||
if (alsoApplyToLinked) {
|
||||
for (const varPath of linkedVarPaths) {
|
||||
try {
|
||||
await GranularAclService.addGranularAcls({
|
||||
workspace: $operatingWorkspace!,
|
||||
path: varPath,
|
||||
kind: 'variable',
|
||||
requestBody: { owner, write }
|
||||
})
|
||||
} catch (err) {
|
||||
sendUserToast(`Failed to update variable ${varPath}: ${err}`, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
loadAcls()
|
||||
dispatch('change', { path, kind })
|
||||
}
|
||||
</script>
|
||||
|
||||
<ShareDialog bind:this={shareDialog} onChange={() => dispatch('change', { path, kind })} />
|
||||
|
||||
<Drawer bind:this={drawer}>
|
||||
<DrawerContent title="Permissions for {path}" on:close={drawer?.closeDrawer}>
|
||||
<div class="flex flex-col gap-4">
|
||||
{#if defaultPerms.length > 0}
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-emphasis">{defaultPermsLabel}</span>
|
||||
{#each defaultPerms as perm (perm.label)}
|
||||
<div class="flex items-center justify-between text-xs text-primary">
|
||||
<span>{perm.label}</span>
|
||||
<span class="text-tertiary">{perm.write ? 'Writer' : 'Viewer'}</span>
|
||||
</div>
|
||||
{/each}
|
||||
<DrawerContent title="Share {path}" on:close={drawer?.closeDrawer}>
|
||||
<!-- Full height, so a long access list scrolls inside the drawer under its own header. -->
|
||||
<div class="flex flex-col gap-4 h-full">
|
||||
{#if linkedVarPaths.length > 0}
|
||||
<div class="flex flex-col gap-1.5 p-3 border rounded bg-surface-secondary text-xs">
|
||||
<Toggle
|
||||
size="xs"
|
||||
bind:checked={alsoApplyToLinked}
|
||||
options={{ right: 'Also apply to linked variables' }}
|
||||
/>
|
||||
<ul class="text-2xs text-secondary list-disc ml-4">
|
||||
{#each linkedVarPaths as varPath (varPath)}
|
||||
<li>{varPath}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="flex flex-col gap-2">
|
||||
<span class="text-sm font-semibold text-emphasis">Extra members ({acls?.length ?? 0})</span>
|
||||
{#if linkedVarPaths.length > 0}
|
||||
<div class="flex flex-col gap-1.5 p-3 border rounded bg-surface-secondary text-xs">
|
||||
<Toggle
|
||||
size="xs"
|
||||
bind:checked={alsoApplyToLinked}
|
||||
options={{ right: 'Also apply to linked variables' }}
|
||||
/>
|
||||
<ul class="text-2xs text-secondary list-disc ml-4">
|
||||
{#each linkedVarPaths as varPath (varPath)}
|
||||
<li>{varPath}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
{#if !own}
|
||||
{#if readOnly($operatingWorkspace)}
|
||||
<Alert type="info" title="Use mode">
|
||||
This session cannot change permissions while it is in Use mode.
|
||||
</Alert>
|
||||
{:else}
|
||||
<Alert type="warning" title="Not owner"
|
||||
>Since you do not own this item, you cannot modify its permission</Alert
|
||||
>
|
||||
{/if}
|
||||
{/if}
|
||||
<div>
|
||||
{#if own && sharingDisabled}
|
||||
<Alert type="info" title="Sharing disabled">
|
||||
{writeLock ?? DEMO_RESTRICTION_HINT}
|
||||
</Alert>
|
||||
{:else if own}
|
||||
<div class="flex flex-row flex-wrap gap-2 items-center">
|
||||
<div>
|
||||
<ToggleButtonGroup bind:selected={ownerKind} on:selected={() => (owner = '')}>
|
||||
{#snippet children({ item })}
|
||||
<ToggleButton value="user" label="User" {item} />
|
||||
<ToggleButton value="group" label="Group" {item} />
|
||||
{/snippet}
|
||||
</ToggleButtonGroup>
|
||||
</div>
|
||||
{#key ownerKind}
|
||||
<Select
|
||||
items={safeSelectItems(
|
||||
(ownerKind === 'user' ? usernames : groups).map((x) => x.toString())
|
||||
)}
|
||||
bind:value={owner}
|
||||
class="grow min-w-48"
|
||||
/>
|
||||
{/key}
|
||||
<Button
|
||||
size="lg"
|
||||
variant="accent"
|
||||
disabled={!newOwner}
|
||||
on:click={() => addAcl(newOwner, write)}>Add member</Button
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
{#if acls?.length > 0}
|
||||
<TableCustom>
|
||||
{#snippet headerRow()}
|
||||
<tr>
|
||||
<th>member</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
{/snippet}
|
||||
{#snippet body()}
|
||||
<tbody>
|
||||
{#each acls as [owner, write]}
|
||||
<tr>
|
||||
<td>{owner}</td>
|
||||
<td
|
||||
>{#if own && !sharingDisabled}
|
||||
<div>
|
||||
<ToggleButtonGroup
|
||||
selected={write ? 'writer' : 'viewer'}
|
||||
on:selected={async (e) => {
|
||||
const role = e.detail
|
||||
if (role == 'writer') {
|
||||
await addAcl(owner, true)
|
||||
} else {
|
||||
await addAcl(owner, false)
|
||||
}
|
||||
loadAcls()
|
||||
}}
|
||||
>
|
||||
{#snippet children({ item })}
|
||||
<ToggleButton value="viewer" small label="Viewer" {item} />
|
||||
<ToggleButton value="writer" small label="Writer" {item} />
|
||||
{/snippet}
|
||||
</ToggleButtonGroup>
|
||||
</div>
|
||||
{:else}{write ? 'Writer' : 'Viewer'}{/if}</td
|
||||
>
|
||||
<td>
|
||||
{#if own && !writeLock}
|
||||
<Button
|
||||
variant="default"
|
||||
destructive
|
||||
size="xs"
|
||||
on:click={() => deleteAcl(owner)}
|
||||
startIcon={{ icon: Trash }}
|
||||
/>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
{/snippet}
|
||||
</TableCustom>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div></DrawerContent
|
||||
>
|
||||
{#key `${kind}:${path}`}
|
||||
<ItemAccessList
|
||||
{kind}
|
||||
{path}
|
||||
alsoApplyTo={alsoApplyToLinked ? linkedVarPaths : []}
|
||||
{isOwnerOverride}
|
||||
onChange={() => dispatch('change', { path, kind })}
|
||||
/>
|
||||
{/key}
|
||||
</div>
|
||||
</DrawerContent>
|
||||
</Drawer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import { deployRawAppValue } from '$lib/rawAppDeploy'
|
||||
import { policyForUpdate } from './publishAccessMode'
|
||||
import { withoutSharedPolicySettings } from './appDraftSettings'
|
||||
import DeploymentHistory from './DeploymentHistory.svelte'
|
||||
|
||||
interface Props {
|
||||
@@ -30,7 +30,6 @@
|
||||
value: app.value,
|
||||
summary: app.summary,
|
||||
policy: app.policy,
|
||||
customPath: app.custom_path,
|
||||
allowKindChange: true
|
||||
})
|
||||
} else {
|
||||
@@ -39,7 +38,7 @@
|
||||
path: app.path,
|
||||
requestBody: {
|
||||
...app,
|
||||
policy: app.policy && policyForUpdate(app.policy)
|
||||
policy: app.policy && withoutSharedPolicySettings(app.policy)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@
|
||||
Redo,
|
||||
Zap,
|
||||
Globe,
|
||||
Settings
|
||||
Settings,
|
||||
UserPlus
|
||||
} from 'lucide-svelte'
|
||||
import { getContext, onDestroy, untrack, type Snippet } from 'svelte'
|
||||
import { orderedJsonStringify, type Value, replaceFalseWithUndefined } from '../../../utils'
|
||||
@@ -76,8 +77,15 @@
|
||||
import AppSettingsDrawer from './AppSettingsDrawer.svelte'
|
||||
import DeployButton from '$lib/components/DeployButton.svelte'
|
||||
import { updatePolicy } from './appPolicy'
|
||||
import { policyForUpdate, publishAccessMode } from './publishAccessMode'
|
||||
import { appDraftSettings } from './appDraftSettings'
|
||||
import { appDraftSettings, withoutSharedPolicySettings } from './appDraftSettings'
|
||||
import ShareDialog from '$lib/components/itemSettings/ShareDialog.svelte'
|
||||
import FirstDeployDialog, {
|
||||
applyFirstDeployMembers
|
||||
} from '$lib/components/itemSettings/FirstDeployDialog.svelte'
|
||||
import ShareButton from '$lib/components/itemSettings/ShareButton.svelte'
|
||||
import { accessModeOf } from '$lib/components/itemSettings/appAccess'
|
||||
import { movesToAnotherOwner } from '$lib/components/itemSettings/inheritedAccess'
|
||||
import { computeSecretUrl } from './appDeploy.svelte'
|
||||
import { classicAppDraftParts } from '$lib/appDiffSides'
|
||||
import { editInForkAllowed, editInForkLabel, openEditInFork } from '$lib/utils/editInFork'
|
||||
import { isCloudHosted } from '$lib/cloud'
|
||||
@@ -182,7 +190,6 @@
|
||||
let deployedBy: string | undefined = $state(undefined) // Author
|
||||
let confirmCallback: () => void = $state(() => {}) // What happens when user clicks `override` in warning
|
||||
let open: boolean = $state(false) // Is confirmation modal open
|
||||
let customPathError: string = $state('')
|
||||
|
||||
const {
|
||||
app,
|
||||
@@ -268,11 +275,11 @@
|
||||
let selectedJobId: string | undefined = $state(undefined)
|
||||
|
||||
let pathError: string = $state('')
|
||||
|
||||
let appExport: AppExportButton | undefined = $state()
|
||||
|
||||
let settingsOpen = $state(false)
|
||||
let settingsDrawer: AppSettingsDrawer | undefined = $state()
|
||||
let deployRefused = $state(false)
|
||||
let inputsDrawerOpen = $state(untrack(() => fromHub))
|
||||
let historyBrowserDrawerOpen = $state(false)
|
||||
let debugAppDrawerOpen = $state(false)
|
||||
@@ -310,20 +317,12 @@
|
||||
return classicAppDraftParts(a).value as T
|
||||
}
|
||||
|
||||
async function setAccessMode(mode: NonNullable<Policy['execution_mode']>) {
|
||||
await publishAccessMode($workspaceStore!, $appPath, mode)
|
||||
if (savedApp) savedApp.policy = { ...savedApp.policy, execution_mode: mode }
|
||||
sendUserToast(
|
||||
mode == 'anonymous'
|
||||
? 'App require no login to be accessed'
|
||||
: 'App require login and read-access'
|
||||
)
|
||||
}
|
||||
|
||||
async function createApp(path: string) {
|
||||
/** Resolves to whether the app was created. */
|
||||
async function createApp(path: string): Promise<boolean> {
|
||||
// In place: the settings drawer and the draft mirror hold this object.
|
||||
Object.assign(policy, await updatePolicy($app, policy))
|
||||
setDeployedOnBehalfOf(policy, operatingUser.current, folderDefault.value)
|
||||
// Read for the path being created: the first-deploy dialog may have just chosen it.
|
||||
setDeployedOnBehalfOf(policy, operatingUser.current, await folderDefault.refetch())
|
||||
try {
|
||||
await AppService.createApp({
|
||||
workspace: $workspaceStore!,
|
||||
@@ -364,8 +363,10 @@
|
||||
})
|
||||
}
|
||||
onSavedNewAppPath?.(path)
|
||||
return true
|
||||
} catch (e) {
|
||||
sendUserToast('Error creating app', e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,13 +451,13 @@
|
||||
requestBody: {
|
||||
value: withoutDraftBase($app!),
|
||||
summary: $summary,
|
||||
policy: policyForUpdate(policy),
|
||||
// Without the mode, which the Share dialog sets: the server keeps the deployed one,
|
||||
// read under the row lock a mode change also takes.
|
||||
policy: withoutSharedPolicySettings(policy),
|
||||
path: npath,
|
||||
deployment_message: deploymentMsg,
|
||||
// custom_path requires admin so to accept update without it, we need to send as undefined when non-admin (when undefined, it will be ignored)
|
||||
// it also means that customPath needs to be set to '' instead of undefined to unset it (when admin)
|
||||
custom_path:
|
||||
$userStore?.is_admin || $userStore?.is_super_admin ? (customPath ?? '') : undefined,
|
||||
// Absent keeps the custom URL, which the Share dialog sets.
|
||||
custom_path: undefined,
|
||||
preserve_on_behalf_of: true,
|
||||
labels
|
||||
}
|
||||
@@ -514,17 +515,57 @@
|
||||
settingsDrawer?.openAt(setting)
|
||||
}
|
||||
|
||||
let shareDialog: ShareDialog | undefined = $state()
|
||||
let firstDeployDialog: FirstDeployDialog | undefined = $state()
|
||||
|
||||
function openShare() {
|
||||
shareDialog?.openDialog('app', $appPath!, {
|
||||
source: 'editor_header',
|
||||
fromEditor: true,
|
||||
stagedPath: newEditedPath
|
||||
})
|
||||
}
|
||||
|
||||
// Chosen in the first-deploy dialog, added once the run-as confirmation has created the app.
|
||||
let firstDeployMembers: Record<string, boolean> = {}
|
||||
|
||||
async function deploy(message?: string) {
|
||||
if (pathError != '' || customPathError != '') {
|
||||
deployRefused = true
|
||||
openSettings(pathError != '' ? undefined : 'custom-url')
|
||||
if (pathError != '') {
|
||||
openSettings()
|
||||
return
|
||||
}
|
||||
deploymentMsg = message ?? ''
|
||||
firstDeployMembers = {}
|
||||
if (newApp && ownsPageHeader) {
|
||||
// The dialog also asks who the app runs on behalf of, for the path it chose.
|
||||
const choice = await firstDeployDialog?.ask({
|
||||
kind: 'app',
|
||||
summary: $summary,
|
||||
path: newEditedPath,
|
||||
appMode: accessModeOf(policy),
|
||||
runAs: {
|
||||
email: policy.on_behalf_of_email,
|
||||
permissionedAs: policy.on_behalf_of,
|
||||
targetWorkspace: $workspaceStore ?? ''
|
||||
}
|
||||
})
|
||||
if (!choice) return
|
||||
$summary = choice.summary
|
||||
newEditedPath = choice.path
|
||||
policy.execution_mode = choice.appMode
|
||||
if (choice.runAs) {
|
||||
policy.on_behalf_of_email = choice.runAs.email
|
||||
policy.on_behalf_of = choice.runAs.permissionedAs
|
||||
}
|
||||
deploymentMsg = choice.message
|
||||
firstDeployMembers = choice.members
|
||||
await deployNow()
|
||||
return
|
||||
}
|
||||
// Compares against the user deployed right now; a failed lookup asks rather than trusting
|
||||
// the loaded one.
|
||||
deployedRunAs = newApp ? undefined : await fetchDeployedRunAs($workspaceStore!, $appPath!)
|
||||
if (
|
||||
const asksRunAs =
|
||||
(!newApp && !deployedRunAs) ||
|
||||
// Asks while the folder default is loading: the backend would apply it unconfirmed.
|
||||
folderDefault.loading ||
|
||||
@@ -536,7 +577,20 @@
|
||||
savedPermissionedAs: deployedRunAs?.on_behalf_of,
|
||||
folderDefault: folderDefault.value
|
||||
})
|
||||
if (
|
||||
shareDialog &&
|
||||
$appPath &&
|
||||
movesToAnotherOwner($appPath, newEditedPath) &&
|
||||
!(await shareDialog.confirmMove(
|
||||
'app',
|
||||
$appPath,
|
||||
newEditedPath,
|
||||
asksRunAs ? 'Next' : 'Deploy'
|
||||
))
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (asksRunAs) {
|
||||
deployDialogOpen = true
|
||||
return
|
||||
}
|
||||
@@ -547,7 +601,10 @@
|
||||
// Use `newApp` (set for /apps/add and draft-only paths), not
|
||||
// `$appPath` — its `draft_{uuid}` is a poor create signal.
|
||||
if (newApp) {
|
||||
await createApp(newEditedPath)
|
||||
const members = firstDeployMembers
|
||||
if (await createApp(newEditedPath)) {
|
||||
await applyFirstDeployMembers($workspaceStore!, 'app', newEditedPath, members)
|
||||
}
|
||||
} else {
|
||||
await handleUpdateApp(newEditedPath)
|
||||
}
|
||||
@@ -770,10 +827,27 @@
|
||||
icon: Settings,
|
||||
action: () => openSettings()
|
||||
},
|
||||
...(ownsPageHeader
|
||||
? [
|
||||
{
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
disabled: newApp,
|
||||
action: openShare
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
displayName: 'Public URL',
|
||||
icon: Globe,
|
||||
action: () => openSettings('access')
|
||||
disabled: newApp,
|
||||
action: async () => {
|
||||
const secretUrl = await AppService.getPublicSecretOfApp({
|
||||
workspace: $workspaceStore!,
|
||||
path: $appPath!
|
||||
})
|
||||
window.open(computeSecretUrl(secretUrl, $workspaceStore), '_blank')
|
||||
}
|
||||
},
|
||||
{
|
||||
displayName: 'App inputs',
|
||||
@@ -898,7 +972,7 @@
|
||||
}
|
||||
})
|
||||
|
||||
let settingsHaveErrors = $derived(pathError != '' || customPathError != '')
|
||||
let settingsHaveErrors = $derived(pathError != '')
|
||||
let hasErrors = $derived(Object.keys($errorByComponent).length > 0)
|
||||
</script>
|
||||
|
||||
@@ -963,15 +1037,26 @@
|
||||
appPath={$appPath}
|
||||
{savedApp}
|
||||
bind:summary={$summary}
|
||||
bind:customPath
|
||||
bind:customPathError
|
||||
bind:pathError
|
||||
bind:newEditedPath
|
||||
bind:labels
|
||||
showErrors={deployRefused}
|
||||
{setAccessMode}
|
||||
/>
|
||||
|
||||
{#if ownsPageHeader}
|
||||
<ShareDialog
|
||||
bind:this={shareDialog}
|
||||
onAppChanged={(row) => {
|
||||
policy.execution_mode = row.policy.execution_mode
|
||||
customPath = row.custom_path ?? undefined
|
||||
if (savedApp) {
|
||||
savedApp.policy = { ...savedApp.policy, execution_mode: row.policy.execution_mode }
|
||||
savedApp.custom_path = row.custom_path ?? undefined
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<FirstDeployDialog bind:this={firstDeployDialog} />
|
||||
{/if}
|
||||
|
||||
<Drawer bind:open={inputsDrawerOpen} size="600px">
|
||||
<DrawerContent title="App inputs configuration" on:close={() => (inputsDrawerOpen = false)}>
|
||||
<AppInputs />
|
||||
@@ -1338,6 +1423,9 @@
|
||||
Settings
|
||||
</Button>
|
||||
</div>
|
||||
{#if ownsPageHeader}
|
||||
<ShareButton deployed={!newApp} iconOnly={compactTopbar} onclick={openShare} />
|
||||
{/if}
|
||||
{/if}
|
||||
<DeployButton
|
||||
bind:this={deployButton}
|
||||
|
||||
@@ -83,8 +83,7 @@
|
||||
path,
|
||||
value: parsed,
|
||||
summary: app?.summary,
|
||||
policy: app?.policy,
|
||||
customPath: app?.custom_path
|
||||
policy: app?.policy
|
||||
})
|
||||
dispatch('change')
|
||||
UserDraft.remove('raw_app', path)
|
||||
|
||||
@@ -1,48 +1,26 @@
|
||||
<script lang="ts">
|
||||
import { Alert, Drawer, DrawerContent, Section } from '$lib/components/common'
|
||||
import { tick } from 'svelte'
|
||||
import { revealSetting } from '$lib/components/itemSettings/ActiveSettingChips.svelte'
|
||||
import Toggle from '$lib/components/Toggle.svelte'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
import { enterpriseLicense, userStore } from '$lib/stores'
|
||||
import { useRoleCapabilities } from '$lib/operatorWriteRights'
|
||||
import { Loader2 } from 'lucide-svelte'
|
||||
|
||||
import Tooltip from '$lib/components/Tooltip.svelte'
|
||||
|
||||
import ClipboardPanel from '$lib/components/details/ClipboardPanel.svelte'
|
||||
import { tick, untrack } from 'svelte'
|
||||
import { revealSetting } from '$lib/components/itemSettings/ActiveSettingChips.svelte'
|
||||
import { AppService, SettingService, WorkspaceService } from '$lib/gen'
|
||||
import type { GuestUsage, Policy } from '$lib/gen'
|
||||
import ToggleButtonGroup from '$lib/components/common/toggleButton-v2/ToggleButtonGroup.svelte'
|
||||
import ToggleButton from '$lib/components/common/toggleButton-v2/ToggleButton.svelte'
|
||||
import Path from '$lib/components/Path.svelte'
|
||||
import { computeSecretUrl } from './appDeploy.svelte'
|
||||
import { isCloudHosted } from '$lib/cloud'
|
||||
import { useRoleCapabilities } from '$lib/operatorWriteRights'
|
||||
import type { Policy } from '$lib/gen'
|
||||
import TextInput from '$lib/components/text_input/TextInput.svelte'
|
||||
import LabelsInput from '$lib/components/LabelsInput.svelte'
|
||||
import RunOnBehalfOfSetting from '$lib/components/itemSettings/RunOnBehalfOfSetting.svelte'
|
||||
import {
|
||||
appOnBehalfOfTooltip,
|
||||
canPreserveOnBehalfOf
|
||||
} from '$lib/components/itemSettings/onBehalfOf'
|
||||
import { appOnBehalfOfTooltip } from '$lib/components/itemSettings/onBehalfOf'
|
||||
import SettingToggle from '$lib/components/itemSettings/SettingToggle.svelte'
|
||||
import SettingIcons from '$lib/components/itemSettings/SettingIcons.svelte'
|
||||
import {
|
||||
getAppMetadataBadges,
|
||||
getAppPermissionBadges,
|
||||
getAppSharingBadges
|
||||
} from './appSettingsBadges'
|
||||
import { canUserBypassRuleKind, protectionRulesState } from '$lib/workspaceProtectionRules.svelte'
|
||||
import { getAppMetadataBadges, getAppPermissionBadges } from './appSettingsBadges'
|
||||
import PathMoveNote from '$lib/components/itemSettings/PathMoveNote.svelte'
|
||||
import { FRONTEND_SDK_SCOPES, sdkScopesToConfirm } from '$lib/components/raw_apps/sdkScopes'
|
||||
import { logFeatureUsage } from '$lib/utils/featureUsage'
|
||||
import {
|
||||
useOperatingUser,
|
||||
useOperatingWorkspace
|
||||
} from '$lib/components/operatingWorkspace.svelte'
|
||||
import { useOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte'
|
||||
|
||||
const operatingWorkspaceStore = useOperatingWorkspace()
|
||||
const operatingUser = useOperatingUser()
|
||||
const actingUser = $derived(operatingUser.current)
|
||||
const roleCaps = useRoleCapabilities()
|
||||
// The server forces a composed app into sandbox isolation.
|
||||
const composeOnlyApps = $derived($roleCaps.apps === 'compose')
|
||||
@@ -51,48 +29,34 @@
|
||||
open = $bindable(),
|
||||
policy = $bindable(),
|
||||
appPath,
|
||||
customPath = $bindable(),
|
||||
savedApp,
|
||||
summary = $bindable(),
|
||||
customPathError = $bindable(),
|
||||
pathError = $bindable(),
|
||||
newEditedPath = $bindable(),
|
||||
newPath,
|
||||
labels = $bindable(),
|
||||
rawApp = false,
|
||||
newApp = false,
|
||||
operatingWorkspace = undefined,
|
||||
showErrors = false,
|
||||
setAccessMode
|
||||
operatingWorkspace = undefined
|
||||
}: {
|
||||
open: boolean
|
||||
/** Mutated in place and deployed with the app, except who can open it: see `setAccessMode`. */
|
||||
/** Mutated in place; deployed with the app, like every other setting here. */
|
||||
policy: Policy
|
||||
appPath: string
|
||||
customPath: string | undefined
|
||||
savedApp: { path: string; policy: any; custom_path?: string } | undefined
|
||||
summary: string
|
||||
customPathError: string
|
||||
pathError: string
|
||||
newEditedPath: string
|
||||
newPath: string
|
||||
labels?: string[] | undefined
|
||||
// Only raw apps are offered the `wm_coep` embedding hint: on a classic
|
||||
// (low-code) app COEP breaks no-CORP cross-origin subresources (external
|
||||
// images, {@html} embeds, CDN imports) that the app cannot opt out of.
|
||||
// Only raw apps are offered frontend API access, which exists for sandboxed raw apps.
|
||||
rawApp?: boolean
|
||||
/** True while the editor is on a draft-only URL (`/edit/u/{user}/draft_{uuid}`
|
||||
* with no deployed row yet). Suppresses the public-secret-URL fetch
|
||||
* (`/secret_of/...` 404s with no `app` row) and renders a placeholder
|
||||
* instead of the eternally-spinning link. */
|
||||
* with no deployed row yet). */
|
||||
newApp?: boolean
|
||||
/** Workspace the app is deployed to. The secret-URL / custom-path / folder /
|
||||
* on-behalf-of lookups target it; defaults to the operating workspace. */
|
||||
/** Workspace the app is deployed to. The path and on-behalf-of lookups target it;
|
||||
* defaults to the operating workspace. */
|
||||
operatingWorkspace?: string
|
||||
/** A deploy was refused over these errors: show them before the fields are edited. */
|
||||
showErrors?: boolean
|
||||
/** Changes who can open the deployed app at once, leaving the rest of its deployed policy. */
|
||||
setAccessMode: (mode: NonNullable<Policy['execution_mode']>) => Promise<void>
|
||||
} = $props()
|
||||
|
||||
let body: HTMLElement | undefined = $state()
|
||||
@@ -107,175 +71,8 @@
|
||||
|
||||
const opWs = $derived(operatingWorkspace ?? $operatingWorkspaceStore)
|
||||
|
||||
// Admins always pass the backend check. For everyone else, fail closed
|
||||
// while the workspace protection rules are still loading so the toggle
|
||||
// is never briefly enabled for a user the rules will end up restricting.
|
||||
let rulesetsLoaded = $derived(protectionRulesState.rulesets !== undefined)
|
||||
let canSetAnonymous = $derived(
|
||||
!!actingUser?.is_admin ||
|
||||
!!actingUser?.is_super_admin ||
|
||||
(rulesetsLoaded &&
|
||||
canUserBypassRuleKind('RestrictAnonymousAppDeployment', $userStore ?? undefined))
|
||||
)
|
||||
let canSetGuest = $derived(
|
||||
!!actingUser?.is_admin ||
|
||||
!!actingUser?.is_super_admin ||
|
||||
(rulesetsLoaded &&
|
||||
canUserBypassRuleKind('RestrictGuestAppDeployment', $userStore ?? undefined))
|
||||
)
|
||||
// The three rungs of the access control, widest last. `viewer` is a fourth
|
||||
// execution mode that this control never sets (it runs components as the viewer,
|
||||
// which a guest cannot be), so an app in it shows as members-only here.
|
||||
let accessMode = $derived(
|
||||
policy.execution_mode == 'anonymous'
|
||||
? 'anonymous'
|
||||
: policy.execution_mode == 'guest'
|
||||
? 'guest'
|
||||
: 'publisher'
|
||||
)
|
||||
let guestUsage: GuestUsage | undefined = $state(undefined)
|
||||
// Whether the deployment can have guests at all; off, the mode is not on offer. The
|
||||
// backend decides; the hostname stands in until it has answered, the shared cloud
|
||||
// being the only deployment where guests are unavailable.
|
||||
let guestsAvailable = $derived.by(() => guestUsage?.available ?? !isCloudHosted())
|
||||
|
||||
$effect(() => {
|
||||
const ws = opWs
|
||||
if (ws === undefined) return
|
||||
untrack(() => {
|
||||
WorkspaceService.getGuestUsage({ workspace: ws })
|
||||
.then((u) => (guestUsage = u))
|
||||
.catch(() => (guestUsage = undefined))
|
||||
})
|
||||
})
|
||||
|
||||
// The server refuses to change the mode alone of an app that runs as someone else unless the
|
||||
// caller may keep that identity, and always for a builder, who is also refused on an app whose
|
||||
// deployed policy is not sandboxed. The control is locked rather than holding the choice for a
|
||||
// deploy: no draft carries the mode, so a held choice would be lost on reload or Review & Deploy.
|
||||
let deployedApp = $derived(!!savedApp && !newApp)
|
||||
let deployedRunsAs = $derived(savedApp?.policy?.on_behalf_of as string | undefined)
|
||||
let runsAsAnotherForCaller = $derived(
|
||||
deployedApp &&
|
||||
!!deployedRunsAs &&
|
||||
deployedRunsAs !== (actingUser?.username ? `u/${actingUser.username}` : undefined) &&
|
||||
(!canPreserveOnBehalfOf(actingUser) || composeOnlyApps)
|
||||
)
|
||||
let unsandboxedForBuilder = $derived(
|
||||
deployedApp && composeOnlyApps && savedApp?.policy?.sandbox !== true
|
||||
)
|
||||
let accessModeLocked = $derived(runsAsAnotherForCaller || unsandboxedForBuilder)
|
||||
// One change at a time: a failed request puts back the mode it replaced, which would
|
||||
// overwrite a newer selection that already succeeded.
|
||||
let accessModePending = $state(false)
|
||||
async function onAccessModeChange(mode: string | undefined) {
|
||||
if (mode === undefined || mode === accessMode || accessModePending || accessModeLocked) return
|
||||
const previous = policy.execution_mode
|
||||
policy.execution_mode = mode as Policy['execution_mode']
|
||||
// A not-yet-deployed app has no row to update: its first deploy carries the mode.
|
||||
if (!deployedApp) return
|
||||
accessModePending = true
|
||||
try {
|
||||
await setAccessMode(mode as NonNullable<Policy['execution_mode']>)
|
||||
} catch (e) {
|
||||
policy.execution_mode = previous
|
||||
throw e
|
||||
} finally {
|
||||
accessModePending = false
|
||||
}
|
||||
}
|
||||
|
||||
let isAdmin = $derived(!!actingUser?.is_admin || !!actingUser?.is_super_admin)
|
||||
|
||||
// The URLs below only serve what is deployed, so a pending custom URL must not read as live.
|
||||
let sharingChanged = $derived(!newApp && (customPath ?? null) !== (savedApp?.custom_path ?? null))
|
||||
let pathChanged = $derived(
|
||||
!newApp && !!savedApp?.path && !!newEditedPath && newEditedPath !== savedApp.path
|
||||
)
|
||||
|
||||
let dirtyCustomPath = $state(false)
|
||||
let path: Path | undefined = $state(undefined)
|
||||
|
||||
let dirtyPath = $state(false)
|
||||
|
||||
async function appExists(customPath: string) {
|
||||
return await AppService.customPathExists({
|
||||
workspace: opWs!,
|
||||
customPath
|
||||
})
|
||||
}
|
||||
|
||||
let globalWorkspacedRoute = $state(false)
|
||||
|
||||
async function loadGlobalWorkspacedRouteSetting() {
|
||||
try {
|
||||
const setting = await SettingService.getGlobal({ key: 'app_workspaced_route' })
|
||||
globalWorkspacedRoute = (setting as boolean) ?? false
|
||||
} catch (error) {
|
||||
globalWorkspacedRoute = false
|
||||
}
|
||||
}
|
||||
|
||||
loadGlobalWorkspacedRouteSetting()
|
||||
|
||||
let secretUrl: string | undefined = $state(undefined)
|
||||
let secretUrlHref = $derived(secretUrl ? computeSecretUrl(secretUrl, opWs) : undefined)
|
||||
let fullCustomUrl = $derived(
|
||||
`${window.location.origin}/a/${
|
||||
isCloudHosted() || globalWorkspacedRoute ? opWs + '/' : ''
|
||||
}${customPath}`
|
||||
)
|
||||
|
||||
// The app URL a guest JWT rides on: append `guest.<jwt>` and the viewer authenticates the
|
||||
// token as a seatless guest. Uses the custom URL when set, else the public secret URL.
|
||||
let guestJwtBase = $derived(customPath !== undefined ? fullCustomUrl : secretUrlHref)
|
||||
|
||||
let embedMode = $state(false)
|
||||
function toEmbedSnippet(url: string): string {
|
||||
return `<iframe src="${url}" title="Windmill app" width="100%" height="600"></iframe>`
|
||||
}
|
||||
async function getSecretUrl() {
|
||||
secretUrl = await AppService.getPublicSecretOfApp({
|
||||
workspace: opWs!,
|
||||
path: appPath
|
||||
})
|
||||
}
|
||||
|
||||
let validateTimeout: number | undefined = undefined
|
||||
async function validateCustomPath(customPath: string): Promise<void> {
|
||||
customPathError = ''
|
||||
if (validateTimeout) {
|
||||
clearTimeout(validateTimeout)
|
||||
}
|
||||
validateTimeout = setTimeout(async () => {
|
||||
if (!/^[\w-]+(\/[\w-]+)*$/.test(customPath)) {
|
||||
customPathError = 'Invalid path'
|
||||
} else if (customPath !== savedApp?.custom_path && (await appExists(customPath))) {
|
||||
customPathError = 'Path already taken'
|
||||
} else {
|
||||
customPathError = ''
|
||||
}
|
||||
validateTimeout = undefined
|
||||
}, 500)
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
;[customPath]
|
||||
untrack(() => customPath !== undefined && validateCustomPath(customPath))
|
||||
})
|
||||
|
||||
$effect(() => {
|
||||
// Skip the secret URL fetch on draft-only items — `/secret_of/...`
|
||||
// has no `app` row to look up and would 404, leaving the UI
|
||||
// component spinning indefinitely.
|
||||
open &&
|
||||
!newApp &&
|
||||
appPath &&
|
||||
appPath != '' &&
|
||||
savedApp &&
|
||||
secretUrl == undefined &&
|
||||
untrack(() => getSecretUrl())
|
||||
})
|
||||
</script>
|
||||
|
||||
{#snippet sandboxHint()}
|
||||
@@ -289,10 +86,6 @@
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
{#snippet adminOnlyHint()}
|
||||
Only workspace admins can set a custom URL.
|
||||
{/snippet}
|
||||
|
||||
<Drawer bind:open size="800px">
|
||||
<DrawerContent noPadding title="Settings" on:close={() => (open = false)}>
|
||||
<div bind:this={body} class="h-full overflow-y-auto">
|
||||
@@ -347,14 +140,11 @@
|
||||
autofocus={false}
|
||||
workspaceOverride={operatingWorkspace}
|
||||
/>
|
||||
{#if pathChanged}
|
||||
<Alert
|
||||
type="info"
|
||||
size="xs"
|
||||
title="Deploy the app to make the path change effective."
|
||||
class="mt-2"
|
||||
/>
|
||||
{/if}
|
||||
<PathMoveNote
|
||||
kind="app"
|
||||
deployedPath={newApp ? undefined : savedApp?.path}
|
||||
path={newEditedPath}
|
||||
/>
|
||||
</Label>
|
||||
</div>
|
||||
</Section>
|
||||
@@ -456,231 +246,6 @@
|
||||
</SettingToggle>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section label="Sharing">
|
||||
{#snippet labelExtra()}
|
||||
<SettingIcons badges={getAppSharingBadges(policy.execution_mode, customPath)} />
|
||||
{/snippet}
|
||||
<div class="flex flex-col gap-6">
|
||||
{#if sharingChanged}
|
||||
<Alert type="info" size="xs" title="Deploy the app to apply these changes." />
|
||||
{/if}
|
||||
<div data-setting="access">
|
||||
<Label label="Access">
|
||||
{#if rulesetsLoaded && !canSetAnonymous && policy.execution_mode != 'anonymous'}
|
||||
<Alert type="warning" title="Restricted by a workspace protection rule" size="xs">
|
||||
Opening this app to anyone with the link is restricted to workspace admins and
|
||||
bypass users by a workspace protection rule
|
||||
</Alert>
|
||||
{/if}
|
||||
{#if rulesetsLoaded && !canSetGuest && policy.execution_mode != 'guest' && guestsAvailable}
|
||||
<Alert type="warning" title="Restricted by a workspace protection rule" size="xs">
|
||||
Opening this app to guests is restricted to workspace admins and bypass users by
|
||||
a workspace protection rule
|
||||
</Alert>
|
||||
{/if}
|
||||
<div>
|
||||
<!-- Bound through accessors: given `selected` one way, the group keeps the
|
||||
choice it was clicked to, and a refused change would stay shown. -->
|
||||
<ToggleButtonGroup
|
||||
bind:selected={() => accessMode, (mode) => onAccessModeChange(mode)}
|
||||
disabled={accessModePending || accessModeLocked}
|
||||
>
|
||||
{#snippet children({ item })}
|
||||
<ToggleButton
|
||||
label="Members"
|
||||
value="publisher"
|
||||
tooltip="Workspace members with read access on this app."
|
||||
{item}
|
||||
/>
|
||||
<ToggleButton
|
||||
label="Guests"
|
||||
value="guest"
|
||||
disabled={policy.execution_mode != 'guest' &&
|
||||
(!guestsAvailable || !canSetGuest)}
|
||||
tooltip={!guestsAvailable
|
||||
? 'Not available on Windmill Cloud. Guests require a self-hosted instance or a dedicated Windmill Cloud deployment.'
|
||||
: "Anyone your identity provider authenticates who has no Windmill account, plus workspace members. No membership, no seat up to the instance's allowance."}
|
||||
{item}
|
||||
/>
|
||||
<ToggleButton
|
||||
label="Public"
|
||||
value="anonymous"
|
||||
disabled={!canSetAnonymous && policy.execution_mode != 'anonymous'}
|
||||
tooltip="Anyone with the secret URL. No login."
|
||||
{item}
|
||||
/>
|
||||
{/snippet}
|
||||
</ToggleButtonGroup>
|
||||
</div>
|
||||
{#if accessModeLocked}
|
||||
<div class="text-xs text-secondary">
|
||||
{#if runsAsAnotherForCaller}
|
||||
This app runs on behalf of <strong>{deployedRunsAs}</strong>. Deploy it so it
|
||||
runs on behalf of you, then change who can open it.
|
||||
{#if !composeOnlyApps}
|
||||
An admin or a member of <code>wm_deployers</code> can change it without taking
|
||||
the app over.
|
||||
{/if}
|
||||
{:else}
|
||||
This app is not sandboxed yet. Deploy it so it is sandboxed, then change who
|
||||
can open it.
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="text-xs text-secondary">
|
||||
{#if policy.execution_mode == 'anonymous'}
|
||||
Anyone holding the secret URL below can open this app without signing in.
|
||||
{:else if policy.execution_mode == 'guest'}
|
||||
{#if !guestsAvailable}
|
||||
Guests are not available on Windmill Cloud, so this app still admits members
|
||||
only. They require a self-hosted instance or a dedicated Windmill Cloud
|
||||
deployment.
|
||||
{:else}
|
||||
Anyone your identity provider authenticates can open this app without a
|
||||
Windmill account. They join no workspace. Members of this workspace can open
|
||||
it too.
|
||||
{#if guestUsage}
|
||||
{guestUsage.guest_count} of {guestUsage.free_allowance} free guests used across
|
||||
this instance in the last {guestUsage.window_days} days; beyond that,
|
||||
{guestUsage.metered
|
||||
? 'every four guests count as one seat'
|
||||
: 'new guests are refused until the count drops'}.
|
||||
{/if}
|
||||
{/if}
|
||||
{:else}
|
||||
Only workspace members with read access on this app can open it.
|
||||
{/if}
|
||||
</div>
|
||||
</Label>
|
||||
</div>
|
||||
|
||||
<Label
|
||||
label="Secret URL"
|
||||
tooltip="An unguessable link to the app. Who it lets in depends on the access above."
|
||||
>
|
||||
{#snippet action()}
|
||||
{#if savedApp && !newApp && secretUrlHref}
|
||||
<Toggle
|
||||
size="xs"
|
||||
checked={embedMode}
|
||||
on:change={(e) => (embedMode = e.detail)}
|
||||
options={{ left: 'URL', right: 'Embed' }}
|
||||
/>
|
||||
{/if}
|
||||
{/snippet}
|
||||
{#if !savedApp || newApp}
|
||||
<ClipboardPanel
|
||||
content={`Deploy this app once to get the public secret URL`}
|
||||
size="md"
|
||||
/>
|
||||
{:else if secretUrlHref}
|
||||
<ClipboardPanel
|
||||
content={embedMode ? toEmbedSnippet(secretUrlHref) : secretUrlHref}
|
||||
size="md"
|
||||
/>
|
||||
{:else}<Loader2 size={16} class="animate-spin" />
|
||||
{/if}
|
||||
<div class="text-2xs text-secondary">
|
||||
{#if embedMode}
|
||||
Paste this iframe snippet into another app.
|
||||
{#if rawApp}
|
||||
To embed it in a cross-origin isolated page, add <code>wm_coep=on</code>
|
||||
<Tooltip
|
||||
>Sets the cross-origin isolation headers (COEP) on the app, which such a page
|
||||
requires of its iframes. The app then only loads cross-origin resources that
|
||||
send CORS or a Cross-Origin-Resource-Policy header.</Tooltip
|
||||
> to the URL.
|
||||
{/if}
|
||||
(if requiring login, top-level domain of embedding app must be the same as the one
|
||||
of Windmill)
|
||||
{:else}
|
||||
Share this URL directly, or switch to <b>Embed</b> to get an iframe snippet. Only the
|
||||
latest deployed version is served.
|
||||
{/if}
|
||||
</div>
|
||||
</Label>
|
||||
|
||||
{#if embedMode && policy.execution_mode == 'guest' && guestJwtBase && guestsAvailable}
|
||||
<Label label="Embed for your own authenticated users (guest JWT)">
|
||||
<div class="text-xs text-secondary">
|
||||
To open this app for a user your own product already authenticates, mint a
|
||||
short-lived JWT in your backend and append it to the app URL as <code
|
||||
>guest.<jwt></code
|
||||
>. Each token is its own seatless guest, confined to this app. Unlike the plain
|
||||
secret URL above, there is no shared secret and no Windmill account.
|
||||
</div>
|
||||
<div class="text-xs text-secondary">
|
||||
Windmill verifies the token against the workspace's guest JWT key (Workspace
|
||||
settings → Guests): a PEM public key or a JWKS URL{#if !isCloudHosted()}, or the
|
||||
instance's configured issuer (<code>JWT_EXT_JWKS_URL</code>) when no workspace
|
||||
key is set{/if}. Set the <b>public</b> half there; in your backend, sign each
|
||||
token with the matching
|
||||
<b>private</b> key using RS256/384/512, PS256/384/512 or ES256/384 (symmetric HS*
|
||||
is refused), carrying <code>email</code>,
|
||||
<code>workspace_id</code>
|
||||
=
|
||||
<code>{opWs}</code>, <code>app_path</code> = <code>{appPath}</code> and
|
||||
<code>exp</code> (at most 24h ahead).
|
||||
</div>
|
||||
<ClipboardPanel
|
||||
content={toEmbedSnippet(`${guestJwtBase}/guest.YOUR_GUEST_JWT`)}
|
||||
size="md"
|
||||
/>
|
||||
<div class="text-2xs text-secondary">
|
||||
Replace <code>YOUR_GUEST_JWT</code> with the token your backend signs per user. Past
|
||||
the instance's free guest allowance a new guest email is refused (see the count above);
|
||||
guests already seen in the window keep working.
|
||||
</div>
|
||||
</Label>
|
||||
{/if}
|
||||
|
||||
<SettingToggle
|
||||
setting="custom-url"
|
||||
label="Custom URL"
|
||||
tooltip="Serve the app at a path you pick, on top of its secret URL."
|
||||
eeOnly
|
||||
disabled={!$enterpriseLicense || !isAdmin}
|
||||
checked={customPath !== undefined}
|
||||
hint={!isAdmin ? adminOnlyHint : undefined}
|
||||
onchange={(on) => {
|
||||
customPath = on ? '' : undefined
|
||||
if (!on) {
|
||||
customPathError = ''
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Label label="Custom path" for="customPath">
|
||||
<TextInput
|
||||
inputProps={{
|
||||
id: 'customPath',
|
||||
autocomplete: 'off',
|
||||
disabled: !isAdmin,
|
||||
oninput: () => {
|
||||
dirtyCustomPath = true
|
||||
}
|
||||
}}
|
||||
bind:value={customPath}
|
||||
error={dirtyCustomPath || showErrors ? customPathError : undefined}
|
||||
/>
|
||||
{#if (dirtyCustomPath || showErrors) && customPathError}
|
||||
<div class="text-2xs text-red-600 dark:text-red-400">{customPathError}</div>
|
||||
{/if}
|
||||
</Label>
|
||||
<Label label="Custom public URL">
|
||||
<ClipboardPanel
|
||||
content={embedMode ? toEmbedSnippet(fullCustomUrl) : fullCustomUrl}
|
||||
size="md"
|
||||
/>
|
||||
</Label>
|
||||
</SettingToggle>
|
||||
|
||||
<a
|
||||
href="https://www.windmill.dev/docs/advanced/external_auth_with_jwt#embed-public-apps-using-your-own-authentification"
|
||||
class="text-2xs">Embed this app in your own product to be used by your own users</a
|
||||
>
|
||||
</div>
|
||||
</Section>
|
||||
</div>
|
||||
</div>
|
||||
</DrawerContent>
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
import { AppService, OpenAPI } from '$lib/gen'
|
||||
import { userStore, workspaceStore, type UserExt } from '$lib/stores'
|
||||
import { getUserExt } from '$lib/user'
|
||||
import { ExternalLink, Pen } from 'lucide-svelte'
|
||||
import { ExternalLink, Pen, UserPlus } from 'lucide-svelte'
|
||||
import ShareModal from '$lib/components/ShareModal.svelte'
|
||||
import ShareButton from '$lib/components/itemSettings/ShareButton.svelte'
|
||||
import { page } from '$app/state'
|
||||
import { isMenuHidden } from '$lib/components/sessions/sessionMode.svelte'
|
||||
import { setOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte'
|
||||
@@ -102,6 +104,15 @@
|
||||
const hideRefreshBar = page.url.searchParams.get('hideRefreshBar') === 'true'
|
||||
|
||||
const showEdit = $derived(canWriteApp && !hideEditBtn)
|
||||
// Share sits beside Edit in this page's own header, for anyone whose role builds apps; the
|
||||
// dialog decides what each of them may change there.
|
||||
const showShare = $derived(
|
||||
ownsPageHeader && !!appPerms && editRights.roleCanAuthor(isRawApp ? 'raw_app' : 'app')
|
||||
)
|
||||
let shareModal: ShareModal | undefined = $state()
|
||||
function openShare() {
|
||||
shareModal?.openDrawer(appPerms?.path ?? path, isRawApp ? 'raw_app' : 'app')
|
||||
}
|
||||
// Decides where Edit goes, not whether it appears: without the workspace navigation there is
|
||||
// no band to put it in. Same rule the layout hides the sidebar by.
|
||||
const menuHidden = $derived(isMenuHidden(page.url))
|
||||
@@ -176,7 +187,7 @@
|
||||
// Edit button: determine write access and which editor to open on this
|
||||
// real-origin page (cookie). The sandboxed low-code app never loads on this
|
||||
// page (it loads inside the opaque iframe), so `app` can't be the source.
|
||||
async function loadPerms() {
|
||||
async function loadPerms(recordVisit = true) {
|
||||
try {
|
||||
const lite: any = await AppService.getAppLiteByPath({ workspace, path })
|
||||
appPerms = { path: lite?.path ?? path, extraPerms: lite?.extra_perms ?? {} }
|
||||
@@ -184,7 +195,7 @@
|
||||
executionMode = lite?.policy?.execution_mode ?? lite?.execution_mode
|
||||
summary = lite?.summary || undefined
|
||||
// Only the route's own page is a visit; a session's preview tab opens it on its own.
|
||||
if (ownsPageHeader) {
|
||||
if (ownsPageHeader && recordVisit) {
|
||||
recentItems.record(workspace, {
|
||||
kind: isRawApp ? 'raw_app' : 'app',
|
||||
path: appPerms.path,
|
||||
@@ -231,27 +242,34 @@
|
||||
if (workspace && path) loadPerms()
|
||||
})
|
||||
|
||||
// Both of this page's buttons carry a label, and a phone's bar has room for neither beside the
|
||||
// app's path — so below that width they become one menu. Unmeasured (0) counts as wide: the bar
|
||||
// This page's buttons all carry a label, and a phone's bar has room for none beside the app's
|
||||
// path — so below that width they become one menu. Unmeasured (0) counts as wide: the bar
|
||||
// measures itself on mount, and starting compact would pop them out a frame later.
|
||||
const compact = $derived(pageHeader.barWidth > 0 && pageHeader.barWidth < PHONE_BAR)
|
||||
const compactItems: Item[] = $derived([
|
||||
...(hasPublicUrl
|
||||
? [
|
||||
{
|
||||
displayName: 'Public url',
|
||||
icon: ExternalLink,
|
||||
action: () => openPublicUrl()
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
displayName: 'Edit',
|
||||
icon: Pen,
|
||||
href: onEdit ? undefined : editHref,
|
||||
action: onEdit ? () => onEdit() : undefined
|
||||
}
|
||||
])
|
||||
function compactItems(share: boolean): Item[] {
|
||||
return [
|
||||
...(hasPublicUrl
|
||||
? [
|
||||
{
|
||||
displayName: 'Public url',
|
||||
icon: ExternalLink,
|
||||
action: () => openPublicUrl()
|
||||
}
|
||||
]
|
||||
: []),
|
||||
...(share ? [{ displayName: 'Share', icon: UserPlus, action: openShare }] : []),
|
||||
...(showEdit
|
||||
? [
|
||||
{
|
||||
displayName: 'Edit',
|
||||
icon: Pen,
|
||||
href: onEdit ? undefined : editHref,
|
||||
action: onEdit ? () => onEdit() : undefined
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="h-full">
|
||||
@@ -285,9 +303,11 @@
|
||||
{#if ownsPageHeader}
|
||||
<PageHeaderContent
|
||||
item={{ kind: 'app', path, summary }}
|
||||
actions={showEdit && !menuHidden ? editAction : undefined}
|
||||
actions={(showEdit || showShare) && !menuHidden ? headerActions : undefined}
|
||||
separator="always"
|
||||
/>
|
||||
<!-- Share can change who opens the app, which decides whether it has a public url. -->
|
||||
<ShareModal bind:this={shareModal} source="detail" on:change={() => loadPerms(false)} />
|
||||
{/if}
|
||||
|
||||
<!-- Edit is the bar's action when this viewer owns the bar, and floats over the canvas otherwise:
|
||||
@@ -296,15 +316,19 @@
|
||||
sit beside the session's name and act on the panel below it. -->
|
||||
{#if showEdit && (menuHidden || !ownsPageHeader)}
|
||||
<div class="absolute bottom-4 right-4 z-50">
|
||||
{@render editAction()}
|
||||
{@render appActions(false)}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#snippet editAction()}
|
||||
{#snippet headerActions()}
|
||||
{@render appActions(showShare)}
|
||||
{/snippet}
|
||||
|
||||
{#snippet appActions(share: boolean)}
|
||||
{#if compact}
|
||||
<!-- Too little bar to seat both: they fold into one menu rather than losing their labels,
|
||||
<!-- Too little bar to seat them: they fold into one menu rather than losing their labels,
|
||||
which are what say where each one goes. -->
|
||||
<DropdownV2 items={compactItems} placement="bottom-end" size="sm" />
|
||||
<DropdownV2 items={compactItems(share)} placement="bottom-end" size="sm" />
|
||||
{:else}
|
||||
{#if hasPublicUrl}
|
||||
<!-- The app on its own, at the url anyone it is shared with uses. A new tab rather than
|
||||
@@ -318,16 +342,21 @@
|
||||
title="Open the app's public url in a new tab">Public url</Button
|
||||
>
|
||||
{/if}
|
||||
<!-- `onEdit` wins over the href: a host that embeds this viewer opens its own editor rather
|
||||
than navigating the frame to one. -->
|
||||
<Button
|
||||
unifiedSize="sm"
|
||||
startIcon={{ icon: Pen }}
|
||||
variant="default"
|
||||
href={onEdit ? undefined : editHref}
|
||||
on:click={() => onEdit?.()}
|
||||
title="Edit this app"
|
||||
id="app-edit-btn">Edit</Button
|
||||
>
|
||||
{#if share}
|
||||
<ShareButton deployed unifiedSize="sm" onclick={openShare} />
|
||||
{/if}
|
||||
{#if showEdit}
|
||||
<!-- `onEdit` wins over the href: a host that embeds this viewer opens its own editor
|
||||
rather than navigating the frame to one. -->
|
||||
<Button
|
||||
unifiedSize="sm"
|
||||
startIcon={{ icon: Pen }}
|
||||
variant="default"
|
||||
href={onEdit ? undefined : editHref}
|
||||
on:click={() => onEdit?.()}
|
||||
title="Edit this app"
|
||||
id="app-edit-btn">Edit</Button
|
||||
>
|
||||
{/if}
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { Policy } from '$lib/gen'
|
||||
import { withDraftPolicySettings } from './appDraftSettings'
|
||||
import { withDraftPolicySettings, withoutSharedPolicySettings } from './appDraftSettings'
|
||||
|
||||
describe('withoutSharedPolicySettings', () => {
|
||||
it('drops who can open the app and keeps the rest of the policy', () => {
|
||||
const policy = { execution_mode: 'anonymous', sandbox: true } as unknown as Policy
|
||||
expect(withoutSharedPolicySettings(policy)).toEqual({ sandbox: true })
|
||||
expect(withoutSharedPolicySettings(undefined)).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('withDraftPolicySettings', () => {
|
||||
it('keeps a setting the draft turned off, and the undrafted fields from the deployed policy', () => {
|
||||
|
||||
@@ -19,6 +19,15 @@ export function policySettings(policy: Policy | Partial<Policy> | undefined): Pa
|
||||
return settings as Partial<Policy>
|
||||
}
|
||||
|
||||
/** A policy without who can open the app, which the Share dialog writes straight to a deployed
|
||||
* app. A raw app drafts the rest of its policy whole, and an update deploy sends the rest: for a
|
||||
* policy that states no mode, the server keeps the deployed one. */
|
||||
export function withoutSharedPolicySettings<T>(policy: T): T {
|
||||
if (!policy || typeof policy !== 'object') return policy
|
||||
const { execution_mode: _, ...rest } = policy as Record<string, unknown>
|
||||
return rest as T
|
||||
}
|
||||
|
||||
export type AppDraftSettings = {
|
||||
policy: Partial<Policy>
|
||||
labels: string[]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Globe, Link, PlugZap, ShieldCheck, Tag, UserCog, Users } from 'lucide-svelte'
|
||||
import { PlugZap, ShieldCheck, Tag, UserCog } from 'lucide-svelte'
|
||||
import type { Policy } from '$lib/gen'
|
||||
import type { ScriptSettingsBadge } from '$lib/components/scriptSettings'
|
||||
|
||||
@@ -57,41 +57,3 @@ export function getAppPermissionBadges(
|
||||
}
|
||||
return badges
|
||||
}
|
||||
|
||||
/** The badges of an app's Sharing section: who beyond members can open it, and its custom URL. */
|
||||
export function getAppSharingBadges(
|
||||
executionMode: Policy['execution_mode'],
|
||||
customPath: string | undefined
|
||||
): ScriptSettingsBadge[] {
|
||||
const badges: ScriptSettingsBadge[] = []
|
||||
if (executionMode === 'anonymous') {
|
||||
badges.push({
|
||||
key: 'access',
|
||||
short: 'Public',
|
||||
setting: 'access',
|
||||
label: 'Public',
|
||||
icon: Globe,
|
||||
detail: 'Anyone with the secret URL, no login'
|
||||
})
|
||||
} else if (executionMode === 'guest') {
|
||||
badges.push({
|
||||
key: 'access',
|
||||
short: 'Guests',
|
||||
setting: 'access',
|
||||
label: 'Guests',
|
||||
icon: Users,
|
||||
detail: 'Guests your identity provider authenticates, plus members'
|
||||
})
|
||||
}
|
||||
if (customPath) {
|
||||
badges.push({
|
||||
key: 'custom_path',
|
||||
short: 'Custom URL',
|
||||
setting: 'custom-url',
|
||||
label: 'Custom URL',
|
||||
icon: Link,
|
||||
detail: customPath
|
||||
})
|
||||
}
|
||||
return badges
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { AppService, type Policy } from '$lib/gen'
|
||||
|
||||
/** Writes who can open the app to the deployed app at once. The server applies the mode alone to
|
||||
* the deployed policy under the deploy's row lock: sandbox, SDK scopes and the run-as user wait
|
||||
* for a deploy, and a concurrent deploy neither reverts the mode nor is reverted by it. */
|
||||
export async function publishAccessMode(
|
||||
workspace: string,
|
||||
path: string,
|
||||
mode: NonNullable<Policy['execution_mode']>
|
||||
): Promise<void> {
|
||||
await AppService.updateApp({
|
||||
workspace,
|
||||
path,
|
||||
requestBody: {
|
||||
execution_mode: mode,
|
||||
// The clicker's draft holds edits this write does not deploy.
|
||||
skip_draft_deletion: true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** The policy an update deploy sends. The mode changes only through `publishAccessMode`, so an
|
||||
* update states none and the server keeps the deployed one, read under the row lock: a policy read
|
||||
* earlier would otherwise put back a mode changed since. */
|
||||
export function policyForUpdate<P extends Partial<Policy>>(policy: P): P {
|
||||
const sent = { ...policy }
|
||||
delete sent.execution_mode
|
||||
return sent
|
||||
}
|
||||
@@ -61,6 +61,11 @@
|
||||
* the dialog otherwise hugs its content, and percentage heights inside it do not
|
||||
* resolve (the centering wrapper is `min-h-full`, i.e. height:auto). */
|
||||
fillHeight?: boolean
|
||||
/** Grow with the content only up to the height the dialog is anchored to, then lay the
|
||||
* body out as `fillHeight` does: content sized with `h-full` can shrink its flexible part
|
||||
* (`min-h-0`), and the body scrolls once nothing shrinks further. Off by default: a taller
|
||||
* dialog otherwise runs past the viewport and the whole overlay scrolls. */
|
||||
fitHeight?: boolean
|
||||
/** Force a minimum z-index base. Defaults to elevating above the AI chat
|
||||
* side panel when it is open. Pass an explicit value to stack above other
|
||||
* surfaces (e.g. a modal opened over the /sessions preview-pane editor). */
|
||||
@@ -86,6 +91,7 @@
|
||||
trail = undefined,
|
||||
description = undefined,
|
||||
fillHeight = false,
|
||||
fitHeight = false,
|
||||
paginated = false,
|
||||
enterConfirms = true,
|
||||
minZIndex: minZIndexProp = undefined,
|
||||
@@ -213,7 +219,9 @@
|
||||
|
||||
<div class="{posClass} inset-0 z-10 overflow-y-auto">
|
||||
<div
|
||||
class="flex {fillHeight ? 'h-full' : 'min-h-full'} items-center justify-center p-4"
|
||||
class="flex {fillHeight || fitHeight
|
||||
? 'h-full'
|
||||
: 'min-h-full'} items-center justify-center p-4"
|
||||
>
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
@@ -221,8 +229,18 @@
|
||||
class={twMerge(
|
||||
'relative transform overflow-hidden rounded-md bg-surface px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:w-full sm:max-w-lg sm:p-6',
|
||||
// The margins are what keeps a content-sized dialog off the viewport edges; a
|
||||
// filling one takes its inset from the wrapper's padding instead.
|
||||
fillHeight ? 'h-full flex flex-col' : 'sm:my-8',
|
||||
// filling or fitting one takes its inset from the wrapper's padding instead.
|
||||
// Fitting is a grid, not a flex column: a grid row gives the body a definite
|
||||
// height while the dialog still hugs its content, so `h-full` resolves in it.
|
||||
// The column's 0 minimum is the grid's `min-w-0`: long unbreakable content
|
||||
// would otherwise widen it past the dialog.
|
||||
fillHeight
|
||||
? 'h-full flex flex-col'
|
||||
: fitHeight
|
||||
? kind == 'button'
|
||||
? 'max-h-full grid grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)_auto]'
|
||||
: 'max-h-full grid grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)]'
|
||||
: 'sm:my-8',
|
||||
c,
|
||||
open
|
||||
? 'ease-out duration-300 opacity-100 translate-y-0 sm:scale-100'
|
||||
@@ -235,10 +253,14 @@
|
||||
><CloseButton on:close={() => (open = false)} /></div
|
||||
>
|
||||
{/if}
|
||||
<div class="flex {fillHeight ? 'flex-1 min-h-0' : ''}">
|
||||
<div class="flex {fillHeight ? 'flex-1 min-h-0' : fitHeight ? 'min-h-0' : ''}">
|
||||
<!-- min-w-0: without it this flex item takes its content's min-content width and
|
||||
stretches the modal past its max-width instead of letting content shrink. -->
|
||||
<div class="text-left flex-1 min-w-0 {fillHeight ? 'flex flex-col min-h-0' : ''}">
|
||||
<div
|
||||
class="text-left flex-1 min-w-0 {fillHeight || fitHeight
|
||||
? 'flex flex-col min-h-0'
|
||||
: ''}"
|
||||
>
|
||||
<!-- pr-8 under `kind="X"`: the close button is absolutely positioned, so a long
|
||||
heading or the header actions would otherwise run under it. -->
|
||||
<div
|
||||
@@ -308,11 +330,13 @@
|
||||
{/if}
|
||||
|
||||
<!-- `mt-1` when paginated: a page carries its own description as its first line,
|
||||
and it belongs where the dialog's own sat, right under the title. -->
|
||||
and it belongs where the dialog's own sat, right under the title. Fitting, the
|
||||
body is the scroller of last resort: 4px of padding, taken back by the margins,
|
||||
keeps the focus rings of controls along its edges from being clipped. -->
|
||||
<div
|
||||
class="{paginated ? 'mt-1' : 'mt-4'} text-sm text-primary {fillHeight
|
||||
? 'flex-1 min-h-0'
|
||||
: ''}"
|
||||
class={fitHeight
|
||||
? 'mt-3 -mx-1 -mb-1 p-1 flex-1 min-h-0 overflow-y-auto text-sm text-primary'
|
||||
: `${paginated ? 'mt-1' : 'mt-4'} text-sm text-primary ${fillHeight ? 'flex-1 min-h-0' : ''}`}
|
||||
>
|
||||
{@render children_render?.()}
|
||||
</div>
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
draftOnly: Boolean(agent.draft_only),
|
||||
wsSpecific: agent.ws_specific,
|
||||
noCode: !$roleCapabilities.code,
|
||||
onPermissions: () => shareModal.openDrawer?.(agent.path, 'resource'),
|
||||
onShare: () => shareModal.openDrawer?.(agent.path, 'resource'),
|
||||
onDeploy: () => deploymentDrawer.openDrawer(agent.path, 'resource'),
|
||||
onHistory: () => history?.open(),
|
||||
onDelete: (event) => {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
ChevronUpSquare,
|
||||
History,
|
||||
Pen,
|
||||
Shield,
|
||||
UserPlus,
|
||||
Trash,
|
||||
Copy
|
||||
} from 'lucide-svelte'
|
||||
@@ -302,8 +302,8 @@
|
||||
hide: !fullApps
|
||||
},
|
||||
{
|
||||
displayName: 'Permissions',
|
||||
icon: Shield,
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
action: () => {
|
||||
shareModal.openDrawer && shareModal.openDrawer(path, 'app')
|
||||
},
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
FolderOpen,
|
||||
ChevronUpSquare,
|
||||
Calendar,
|
||||
Shield,
|
||||
UserPlus,
|
||||
Archive,
|
||||
Copy,
|
||||
Eye,
|
||||
@@ -321,8 +321,8 @@
|
||||
hide: hideForOperator || !$roleCapabilities.manage_schedules
|
||||
},
|
||||
{
|
||||
displayName: 'Permissions',
|
||||
icon: Shield,
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
action: () => {
|
||||
shareModal.openDrawer && shareModal.openDrawer(path, 'flow')
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import Row from './Row.svelte'
|
||||
import type DeployWorkspaceDrawer from '$lib/components/DeployWorkspaceDrawer.svelte'
|
||||
import { Globe, Shield } from 'lucide-svelte'
|
||||
import { Globe, UserPlus } from 'lucide-svelte'
|
||||
import { isDeployable } from '$lib/utils_deployable'
|
||||
import { cachedDeployUiSettings, warmDeployUiSettings } from '$lib/components/home/deploy_ui'
|
||||
|
||||
@@ -66,8 +66,8 @@
|
||||
]
|
||||
: []),
|
||||
{
|
||||
displayName: 'Permissions',
|
||||
icon: Shield,
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
action: () => {
|
||||
shareModal.openDrawer && shareModal.openDrawer(path, 'raw_app')
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
Globe2,
|
||||
List,
|
||||
Pen,
|
||||
Shield,
|
||||
UserPlus,
|
||||
Trash,
|
||||
History,
|
||||
FileText,
|
||||
@@ -414,8 +414,8 @@
|
||||
hide: !$roleCapabilities.code || !$roleCapabilities.manage_schedules
|
||||
},
|
||||
{
|
||||
displayName: 'Permissions',
|
||||
icon: Shield,
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
action: () => {
|
||||
shareModal.openDrawer && shareModal.openDrawer(script.path, 'script')
|
||||
},
|
||||
|
||||
@@ -233,9 +233,8 @@ vi.mock('$lib/gen', async () => {
|
||||
getAppByVersion: vi.fn(async () => {
|
||||
throw new Error('getAppByVersion mock not configured')
|
||||
}),
|
||||
getAppLiteByPath: vi.fn(async () => {
|
||||
throw new Error('getAppLiteByPath mock not configured')
|
||||
}),
|
||||
// A row without an access mode, so a deploy keeps the drafted one.
|
||||
getAppLiteByPath: vi.fn(async () => ({ policy: {} }) as any),
|
||||
listApps: vi.fn(async () => [])
|
||||
}),
|
||||
ResourceService: wrapService(actual.ResourceService, {
|
||||
@@ -3750,7 +3749,7 @@ describe('global AI tools', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// The draft carries the deployed policy from the fork, so nothing is fetched to answer.
|
||||
// Deploying the draft keeps the deployed app's mode, which the draft does not carry.
|
||||
it('reports exposure for an app that has a draft over it', async () => {
|
||||
seedBackendDraft(
|
||||
'raw_app',
|
||||
@@ -3758,10 +3757,14 @@ describe('global AI tools', () => {
|
||||
{
|
||||
files: { '/src/App.tsx': 'x' },
|
||||
runnables: {},
|
||||
policy: { execution_mode: 'anonymous' }
|
||||
policy: {}
|
||||
} as any,
|
||||
{ workspace: WORKSPACE }
|
||||
)
|
||||
vi.mocked(AppService.existsApp).mockResolvedValueOnce(true)
|
||||
vi.mocked(AppService.getAppLiteByPath).mockResolvedValueOnce({
|
||||
policy: { execution_mode: 'anonymous' }
|
||||
} as any)
|
||||
|
||||
const read = await callGlobalTool('read_workspace_item', {
|
||||
type: 'app',
|
||||
@@ -4661,12 +4664,19 @@ describe('global AI tools', () => {
|
||||
)
|
||||
|
||||
vi.mocked(AppService.getAppByPath).mockResolvedValueOnce({} as any)
|
||||
// The deployed mode, read for the exposure note.
|
||||
vi.mocked(AppService.getAppLiteByPath).mockResolvedValueOnce({
|
||||
policy: { execution_mode: 'publisher' }
|
||||
} as any)
|
||||
|
||||
await callGlobalTool('deploy_workspace_item', {
|
||||
type: 'app',
|
||||
path: 'f/apps/report'
|
||||
})
|
||||
|
||||
// Who can open a deployed app is set from the Share dialog: the update states no mode, so
|
||||
// the server keeps the deployed one rather than the drafted `anonymous`.
|
||||
|
||||
expect(AppService.updateAppRaw).toHaveBeenCalledWith({
|
||||
workspace: WORKSPACE,
|
||||
path: 'f/apps/report',
|
||||
@@ -4679,7 +4689,6 @@ describe('global AI tools', () => {
|
||||
data: { tables: ['orders'] }
|
||||
},
|
||||
summary: 'Updated report',
|
||||
// An update leaves the mode to the deployed row, so a stale draft can't revert it.
|
||||
policy: expect.not.objectContaining({ execution_mode: expect.anything() }),
|
||||
deployment_message: undefined
|
||||
},
|
||||
@@ -4694,15 +4703,16 @@ describe('global AI tools', () => {
|
||||
// Deploying is what makes an app's runnables reachable, so it is the one moment the
|
||||
// exposure is both true and known.
|
||||
it('discloses who can open an app after a deploy', async () => {
|
||||
// The deployed app is in the mode its draft names, unless `deployedMode` says otherwise.
|
||||
const deployApp = async (
|
||||
path: string,
|
||||
policy: Record<string, unknown>,
|
||||
storedMode = policy.execution_mode
|
||||
deployedMode = policy.execution_mode
|
||||
) => {
|
||||
vi.mocked(AppService.existsApp).mockResolvedValueOnce(true)
|
||||
vi.mocked(AppService.getAppByPath).mockResolvedValueOnce({} as any)
|
||||
vi.mocked(AppService.getAppLiteByPath).mockResolvedValueOnce({
|
||||
policy: { execution_mode: storedMode }
|
||||
policy: { execution_mode: deployedMode }
|
||||
} as any)
|
||||
seedBackendDraft(
|
||||
'raw_app',
|
||||
@@ -4729,8 +4739,16 @@ describe('global AI tools', () => {
|
||||
// anyone outside the deployers group — so the note must not name an identity.
|
||||
expect(open.message).not.toContain('u/alice')
|
||||
|
||||
// An update keeps the deployed mode, so the note follows the stored row, not a stale draft.
|
||||
const keptPublic = await deployApp('f/apps/kept', { execution_mode: 'publisher' }, 'anonymous')
|
||||
// A deploy keeps the deployed app's mode, so the note follows the deployed row: a draft naming
|
||||
// a wider mode discloses nothing, and one naming a narrower mode still discloses the wider one.
|
||||
const kept = await deployApp('f/apps/kept', { execution_mode: 'anonymous' }, 'publisher')
|
||||
expect(kept.success).toBe(true)
|
||||
expect(kept.message).not.toContain('anyone with the URL')
|
||||
const keptPublic = await deployApp(
|
||||
'f/apps/kept_public',
|
||||
{ execution_mode: 'publisher' },
|
||||
'anonymous'
|
||||
)
|
||||
expect(keptPublic.message).toContain('anyone with the URL, without logging in')
|
||||
|
||||
// Guest is a real widening only where the deployment admits guests; stored on one
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
formatDataTableRef
|
||||
} from '$lib/components/raw_apps/dataTableRefUtils'
|
||||
import { appSourceToDraftValue } from '$lib/components/raw_apps/rawAppDraftValue'
|
||||
import { policyForUpdate } from '$lib/components/apps/editor/publishAccessMode'
|
||||
import { withoutSharedPolicySettings } from '$lib/components/apps/editor/appDraftSettings'
|
||||
import { conformBuilderAppPolicy } from '$lib/components/raw_apps/builderAppPolicy'
|
||||
import { capabilitiesInWorkspace } from '$lib/operatorWriteRights'
|
||||
import { capabilitiesIn, withoutBuilding } from '$lib/roleCapabilities'
|
||||
@@ -2543,6 +2543,17 @@ async function guestAccessIsLive(workspace: string): Promise<boolean | undefined
|
||||
return !!usage.available
|
||||
}
|
||||
|
||||
/** Who can open a deployed app, which the Share dialog sets and a deploy keeps; undefined for an
|
||||
* app that is not deployed. */
|
||||
async function deployedAppExecutionMode(
|
||||
workspace: string,
|
||||
path: string
|
||||
): Promise<string | undefined> {
|
||||
if (!(await AppService.existsApp({ workspace, path }))) return undefined
|
||||
const row = await AppService.getAppLiteByPath({ workspace, path })
|
||||
return row.policy.execution_mode ?? undefined
|
||||
}
|
||||
|
||||
/** Who may open an app, from the mode stored on it. An app sits in `guest` mode whether
|
||||
* or not anyone is admitted by it, so reporting the mode bare would say strangers can
|
||||
* open an app that admits members only. Say it is inert rather than hide it, as the
|
||||
@@ -4367,14 +4378,14 @@ export const globalTools: SessionTool<{}>[] = [
|
||||
toolCallbacks.setToolStatus(toolId, {
|
||||
content: `Read draft ${type} "${parsed.path}"`
|
||||
})
|
||||
// The mode reported is the draft's, which is what deploying it will write. The
|
||||
// deployed app's own mode is a different question, asked with version:
|
||||
// "deployed", and must not be fetched here.
|
||||
// The mode reported is the one deploying the draft leaves: a deployed app keeps its
|
||||
// own, which the Share dialog sets, and a never-deployed one takes the draft's.
|
||||
const executionMode =
|
||||
type === 'app'
|
||||
? await describeAppExposure(
|
||||
workspace,
|
||||
(draft.value as AppDraftValue)?.policy?.execution_mode
|
||||
(await deployedAppExecutionMode(workspace, parsed.path)) ??
|
||||
(draft.value as AppDraftValue)?.policy?.execution_mode
|
||||
)
|
||||
: undefined
|
||||
return JSON.stringify(serializeWorkspaceItemForRead({ ...draft, executionMode }), null, 2)
|
||||
@@ -9689,9 +9700,8 @@ async function deployDraft(
|
||||
deployedPath = targetPath
|
||||
const isUpdate = await AppService.existsApp({ workspace, path: targetPath })
|
||||
if (isUpdate) {
|
||||
// Omit custom_path on update for now. The backend preserves it when absent, while
|
||||
// sending it requires admin privileges; this chat deploy path does not yet mirror
|
||||
// the raw app editor's user/admin-specific custom_path handling.
|
||||
// Who can open the app and its custom URL are set from the Share dialog: the update
|
||||
// states neither, and the server keeps the deployed ones.
|
||||
await AppService.updateAppRaw({
|
||||
workspace,
|
||||
path: targetPath,
|
||||
@@ -9700,7 +9710,7 @@ async function deployDraft(
|
||||
path: targetPath,
|
||||
value: rawAppValue,
|
||||
summary,
|
||||
policy: policyForUpdate(policy),
|
||||
policy: withoutSharedPolicySettings(policy),
|
||||
labels: appValue.labels,
|
||||
deployment_message: deploymentMessage,
|
||||
// Preserve the policy's on_behalf_of: this chat deploy path has no
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import { pageHeader } from '$lib/components/pageHeaderRegistry.svelte'
|
||||
import type { TriggerContext } from '../triggers'
|
||||
import type { Item } from '$lib/utils'
|
||||
import { Bell, BellOff, Calendar } from 'lucide-svelte'
|
||||
import { Bell, BellOff, Calendar, UserPlus } from 'lucide-svelte'
|
||||
import { toggleWorkspaceErrorHandler } from './errorHandlerToggle'
|
||||
import {
|
||||
operatingWorkspaceContextEntry,
|
||||
@@ -84,6 +84,8 @@
|
||||
/** Marks that belong to the item's name, such as its favorite star: drawn right after the
|
||||
* summary rather than among the badges and buttons at the far end. */
|
||||
name_marks?: import('svelte').Snippet
|
||||
/** Opens the item's Share dialog, from a Share button placed right before Edit. */
|
||||
onShare?: () => void
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -104,7 +106,8 @@
|
||||
ownsPageHeader = false,
|
||||
wide = true,
|
||||
leading_actions,
|
||||
name_marks
|
||||
name_marks,
|
||||
onShare
|
||||
}: Props = $props()
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
@@ -139,10 +142,27 @@
|
||||
const fold = $derived(ownsPageHeader ? pageHeader.actionFold : wide ? 0 : 1)
|
||||
const wideRow = $derived(wide && fold <= 1)
|
||||
|
||||
const rowButtons = $derived(mainButtons.filter((b) => !b.placement))
|
||||
// Share is a main button the header places itself: right before Edit, or last for someone
|
||||
// who gets no Edit. It folds like the other main buttons, before Edit does.
|
||||
const shareButton: MainButton | undefined = $derived(
|
||||
onShare
|
||||
? {
|
||||
label: 'Share',
|
||||
buttonProps: { onClick: onShare, variant: 'default', startIcon: UserPlus }
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
const buttons = $derived.by(() => {
|
||||
if (!shareButton) return mainButtons
|
||||
const edit = mainButtons.findIndex((b) => b.label === 'Edit')
|
||||
const at = edit === -1 ? mainButtons.length : edit
|
||||
return [...mainButtons.slice(0, at), shareButton, ...mainButtons.slice(at)]
|
||||
})
|
||||
|
||||
const rowButtons = $derived(buttons.filter((b) => !b.placement))
|
||||
const barButtons = $derived(
|
||||
fold === 0
|
||||
? mainButtons.filter((b) => !b.alwaysPlaced)
|
||||
? buttons.filter((b) => !b.alwaysPlaced)
|
||||
: fold === 1
|
||||
? rowButtons
|
||||
: fold === 2
|
||||
@@ -160,7 +180,7 @@
|
||||
* dropdown would have held, then the secondary actions with no bar button to hang from. */
|
||||
const menuButtons = $derived.by(() => {
|
||||
const folded = rowButtons.filter((b) => !barButtons.includes(b))
|
||||
const homeless = mainButtons.filter(
|
||||
const homeless = buttons.filter(
|
||||
(b) => b.placement && !barButtons.includes(b) && !dropdownHost(b)
|
||||
)
|
||||
const childOf = (host: MainButton) =>
|
||||
@@ -215,8 +235,14 @@
|
||||
}))
|
||||
])
|
||||
|
||||
// The session button goes right before the page's main action, the last bar button (Edit), and
|
||||
// before Share too when Share sits beside it, so the two stay together.
|
||||
const sessionAt = $derived(
|
||||
barButtons.length - (barButtons.length >= 2 && barButtons.at(-2) === shareButton ? 2 : 1)
|
||||
)
|
||||
|
||||
function dropdownItemsOf(host: MainButton) {
|
||||
const items = mainButtons
|
||||
const items = buttons
|
||||
.filter((b) => dropdownHost(b) === host)
|
||||
.map((b) => ({
|
||||
label: b.label,
|
||||
@@ -303,13 +329,12 @@
|
||||
unifiedSize={size}
|
||||
/>
|
||||
{/if}
|
||||
<!-- The session button goes right before the last bar button, the one the page is for (Edit). -->
|
||||
{#if ownsPageHeader && barButtons.length === 0}
|
||||
<OpenInSessionButton source={sessionSource} />
|
||||
{/if}
|
||||
{#each barButtons as btn, i (btn.label)}
|
||||
{@const dropdownItems = dropdownItemsOf(btn)}
|
||||
{#if ownsPageHeader && i === barButtons.length - 1}
|
||||
{#if ownsPageHeader && i === sessionAt}
|
||||
<OpenInSessionButton source={sessionSource} />
|
||||
{/if}
|
||||
<Button
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
Archive,
|
||||
Trash,
|
||||
ChevronUpSquare,
|
||||
Shield,
|
||||
Loader2,
|
||||
GitFork,
|
||||
Play,
|
||||
@@ -542,13 +541,6 @@
|
||||
|
||||
const menuItems: any = []
|
||||
|
||||
menuItems.push({
|
||||
label: 'Permissions',
|
||||
onclick: () => shareModal?.openDrawer(flow?.path ?? '', 'flow'),
|
||||
Icon: Shield,
|
||||
disabled: !can_write
|
||||
})
|
||||
|
||||
if (showEditButtons) {
|
||||
menuItems.push({
|
||||
label: 'Move/Rename',
|
||||
@@ -679,7 +671,7 @@
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} />
|
||||
<DeployWorkspaceDrawer bind:this={deploymentDrawer} />
|
||||
<ShareModal bind:this={shareModal} />
|
||||
<ShareModal bind:this={shareModal} source="detail" />
|
||||
<MoveDrawer
|
||||
bind:this={moveDrawer}
|
||||
on:update={async (e) => {
|
||||
@@ -713,6 +705,9 @@
|
||||
}}
|
||||
{mainButtons}
|
||||
menuItems={getMenuItems(flow, deployUiSettings)}
|
||||
onShare={flow && canAuthorFlow
|
||||
? () => shareModal?.openDrawer(flow?.path ?? '', 'flow')
|
||||
: undefined}
|
||||
bind:errorHandlerMuted={
|
||||
() => flow?.ws_error_handler_muted ?? false,
|
||||
(v) => {
|
||||
|
||||
@@ -71,7 +71,6 @@
|
||||
Loader2,
|
||||
Pen,
|
||||
ChevronUpSquare,
|
||||
Shield,
|
||||
Trash,
|
||||
Play,
|
||||
ClipboardCopy,
|
||||
@@ -722,14 +721,6 @@
|
||||
}
|
||||
})
|
||||
|
||||
menuItems.push({
|
||||
label: 'Permissions',
|
||||
Icon: Shield,
|
||||
onclick: () => {
|
||||
shareModal?.openDrawer(script?.path ?? '', 'script')
|
||||
}
|
||||
})
|
||||
|
||||
if (!$disableHubStore) {
|
||||
menuItems.push({
|
||||
label: 'Publish to Hub',
|
||||
@@ -848,7 +839,7 @@
|
||||
|
||||
<DeployWorkspaceDrawer bind:this={deploymentDrawer} />
|
||||
<PersistentScriptDrawer bind:this={persistentScriptDrawer} />
|
||||
<ShareModal bind:this={shareModal} />
|
||||
<ShareModal bind:this={shareModal} source="detail" />
|
||||
|
||||
<Drawer bind:open={versionsDrawerOpen} size="1200px">
|
||||
<DrawerContent title="Versions History" on:close={() => (versionsDrawerOpen = false)} noPadding>
|
||||
@@ -874,6 +865,9 @@
|
||||
ownsPageHeader={!embedded}
|
||||
{mainButtons}
|
||||
menuItems={getMenuItems(script, deployUiSettings)}
|
||||
onShare={script && caps.code
|
||||
? () => shareModal?.openDrawer(script?.path ?? '', 'script')
|
||||
: undefined}
|
||||
bind:errorHandlerMuted={
|
||||
() => script?.ws_error_handler_muted ?? false,
|
||||
(v) => {
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
import { Copy, Eye, FileUp, History, LayoutDashboard, List, Shield, Trash } from 'lucide-svelte'
|
||||
import {
|
||||
Copy,
|
||||
Eye,
|
||||
FileUp,
|
||||
History,
|
||||
LayoutDashboard,
|
||||
List,
|
||||
Trash,
|
||||
UserPlus
|
||||
} from 'lucide-svelte'
|
||||
import { DraftService, ResourceService, type AiAgent, type OpenFlow } from '$lib/gen'
|
||||
import { mintDraftPath } from '$lib/mintDraftPath'
|
||||
import { keepsManagedMemory } from './agentFormFields'
|
||||
@@ -90,7 +99,7 @@ export function agentMenuItems(agent: {
|
||||
noCode?: boolean
|
||||
/** Undefined until loaded, when nothing is offered for deploy. */
|
||||
deployUiSettings: WorkspaceDeployUISettings | undefined
|
||||
onPermissions: () => void
|
||||
onShare: () => void
|
||||
onDeploy: () => void
|
||||
onHistory: () => void
|
||||
onDelete: (event?: MouseEvent) => void
|
||||
@@ -136,10 +145,10 @@ export function agentMenuItems(agent: {
|
||||
]
|
||||
: []),
|
||||
{
|
||||
displayName: 'Permissions',
|
||||
icon: Shield,
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
disabled: !agent.canWrite || Boolean(agent.draftOnly),
|
||||
action: agent.onPermissions
|
||||
action: agent.onShare
|
||||
},
|
||||
...(deployable
|
||||
? [{ displayName: 'Deploy to prod/staging', icon: FileUp, action: agent.onDeploy }]
|
||||
|
||||
@@ -226,7 +226,7 @@
|
||||
noCode: !canCode,
|
||||
wsSpecific: agent?.state?.wsSpecific,
|
||||
deployUiSettings: deployUiSettings.current,
|
||||
onPermissions: () => shareModal?.openDrawer?.(path, 'resource'),
|
||||
onShare: () => shareModal?.openDrawer?.(path, 'resource'),
|
||||
onDeploy: () => deploymentDrawer?.openDrawer(path, 'resource'),
|
||||
onHistory: () => history?.open(),
|
||||
onDelete: () => (deleteOpen = true),
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import Path from '$lib/components/Path.svelte'
|
||||
import FlowCard from '../common/FlowCard.svelte'
|
||||
import JobTokenScopesSetting from '$lib/components/JobTokenScopesSetting.svelte'
|
||||
import { Alert, Tab, TabContent, Tabs } from '$lib/components/common'
|
||||
import { Tab, TabContent, Tabs } from '$lib/components/common'
|
||||
import { getContext, tick } from 'svelte'
|
||||
import type { FlowEditorContext } from '../types'
|
||||
import SimpleEditor from '$lib/components/SimpleEditor.svelte'
|
||||
@@ -26,6 +26,7 @@
|
||||
import DeleteAfterUseSetting from '$lib/components/itemSettings/DeleteAfterUseSetting.svelte'
|
||||
import RunOnBehalfOfSetting from '$lib/components/itemSettings/RunOnBehalfOfSetting.svelte'
|
||||
import InvisibleRunsSetting from '$lib/components/itemSettings/InvisibleRunsSetting.svelte'
|
||||
import PathMoveNote from '$lib/components/itemSettings/PathMoveNote.svelte'
|
||||
import SettingIcons from '$lib/components/itemSettings/SettingIcons.svelte'
|
||||
import ActiveSettingChips, {
|
||||
revealSetting
|
||||
@@ -61,8 +62,11 @@
|
||||
customUi,
|
||||
savedOnBehalfOfEmail,
|
||||
savedOnBehalfOfPermissionedAs,
|
||||
opWorkspace
|
||||
opWorkspace,
|
||||
deployedPath
|
||||
} = getContext<FlowEditorContext>('FlowEditorContext')
|
||||
// Without the deployed path, the path the editor opened on stands in.
|
||||
const deployedFlowPath = $derived(deployedPath ? deployedPath() : $initialPathStore)
|
||||
|
||||
type FlowSettingsTab = 'metadata' | 'runtime' | 'permissions'
|
||||
|
||||
@@ -205,14 +209,7 @@
|
||||
kind="flow"
|
||||
workspaceOverride={opWorkspace?.()}
|
||||
/>
|
||||
{#if $initialPathStore && $pathStore && $pathStore !== $initialPathStore}
|
||||
<Alert
|
||||
type="info"
|
||||
size="xs"
|
||||
title="Deploy the flow to make the path change effective."
|
||||
class="mt-2"
|
||||
/>
|
||||
{/if}
|
||||
<PathMoveNote kind="flow" deployedPath={deployedFlowPath} path={$pathStore} />
|
||||
</Label>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -107,6 +107,9 @@ export type FlowEditorContext = {
|
||||
// $workspaceStore inside a fork-scoped session; worker-tag pickers read it so
|
||||
// their tag list and availability match the deploy target. Getter for reactivity.
|
||||
opWorkspace?: () => string | undefined
|
||||
// Where the deployed flow is, which a path change in its settings moves it from on deploy.
|
||||
// Undefined before the first deploy. Getter for reactivity.
|
||||
deployedPath?: () => string | undefined
|
||||
// The agent whose editor hosts this flow, when one does. An agent editor hosts its flow under
|
||||
// that agent's own path, so `pathStore` alone cannot say whether a step belongs to a flow or to
|
||||
// an agent being edited — a flow and a resource may share a path string.
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
Pen,
|
||||
Star as StarIcon,
|
||||
StarOff,
|
||||
UserPlus,
|
||||
X
|
||||
} from 'lucide-svelte'
|
||||
import { Button } from '$lib/components/common'
|
||||
import DropdownV2 from '$lib/components/DropdownV2.svelte'
|
||||
import ShareModal from '$lib/components/ShareModal.svelte'
|
||||
import { useEditRights } from '$lib/operatorWriteRights'
|
||||
import { roleCapabilities, userStore } from '$lib/stores'
|
||||
import { AppService } from '$lib/gen'
|
||||
@@ -113,6 +115,7 @@
|
||||
// Only the role is checked: the cards don't carry the item's own permissions, and an
|
||||
// editor opened without write access says so itself.
|
||||
const editRights = useEditRights()
|
||||
let shareModal: ShareModal | undefined = $state()
|
||||
|
||||
// A favorite app arrives as plain `app` (the layout lists apps without their subtype), and
|
||||
// `/apps/edit` mounts the low-code editor whatever it opens, so the editor routes ask which
|
||||
@@ -127,8 +130,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
// The row menus' actions that need nothing but the kind and path. Moving, deleting,
|
||||
// deploying and sharing need the full item and the row's own drawers, so they stay there.
|
||||
// The row menus' actions that need nothing but the kind and path. Moving, deleting and
|
||||
// deploying need the full item and the row's own drawers, so they stay there.
|
||||
async function menuItems(item: Entry, favorite: boolean): Promise<Item[]> {
|
||||
const kind = await editorKind(item)
|
||||
const base = kind === 'raw_app' ? 'apps_raw' : `${kind}s`
|
||||
@@ -158,6 +161,12 @@
|
||||
href: `/${base}/add?template=${item.path}`,
|
||||
hide: !showEditButtons || !$roleCapabilities.code || kind === 'agent'
|
||||
},
|
||||
{
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
action: () => kind !== 'agent' && shareModal?.openDrawer(item.path, kind),
|
||||
hide: kind === 'agent' || !editRights.roleCanAuthor(kind)
|
||||
},
|
||||
{
|
||||
displayName: 'View runs',
|
||||
icon: List,
|
||||
@@ -518,3 +527,5 @@
|
||||
{/if}
|
||||
</HomeSectionLabel>
|
||||
{/if}
|
||||
|
||||
<ShareModal bind:this={shareModal} source="home" />
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
import Tooltip from '$lib/components/Tooltip.svelte'
|
||||
</script>
|
||||
|
||||
<Tooltip documentationLink="https://www.windmill.dev/docs/core_concepts/roles_and_permissions">
|
||||
<div class="flex flex-col gap-1">
|
||||
<span>Access comes from three places:</span>
|
||||
<span><b>Folder</b>: the members of the folder it lives in. Most access is set there.</span>
|
||||
<span><b>Owner</b>: the user or group its path starts with.</span>
|
||||
<span><b>Extra permission</b>: people given access to this item alone.</span>
|
||||
<span>Workspace admins can always see, run and edit it.</span>
|
||||
<span>Viewers can see and run it. Writers can also edit and deploy it.</span>
|
||||
</div>
|
||||
</Tooltip>
|
||||
@@ -0,0 +1,405 @@
|
||||
<script lang="ts">
|
||||
import { Alert, Button } from '$lib/components/common'
|
||||
import ToggleButtonGroup from '$lib/components/common/toggleButton-v2/ToggleButtonGroup.svelte'
|
||||
import ToggleButton from '$lib/components/common/toggleButton-v2/ToggleButton.svelte'
|
||||
import Toggle from '$lib/components/Toggle.svelte'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
import Description from '$lib/components/Description.svelte'
|
||||
import Tooltip from '$lib/components/Tooltip.svelte'
|
||||
import TextInput from '$lib/components/text_input/TextInput.svelte'
|
||||
import ClipboardPanel from '$lib/components/details/ClipboardPanel.svelte'
|
||||
import { Loader2, Pen, Plus, Trash } from 'lucide-svelte'
|
||||
import { AppService, SettingService, WorkspaceService } from '$lib/gen'
|
||||
import type { GuestUsage } from '$lib/gen'
|
||||
import { enterpriseLicense, userStore } from '$lib/stores'
|
||||
import { isCloudHosted } from '$lib/cloud'
|
||||
import { canUserBypassRuleKind, protectionRulesState } from '$lib/workspaceProtectionRules.svelte'
|
||||
import { useOperatingUser } from '$lib/components/operatingWorkspace.svelte'
|
||||
import { customPathError, type AppAccessMode } from './appAccess'
|
||||
|
||||
interface Props {
|
||||
workspace: string
|
||||
/** The deployed path, or the path the app will be created at. */
|
||||
appPath: string
|
||||
rawApp?: boolean
|
||||
mode: AppAccessMode
|
||||
onModeChange: (mode: AppAccessMode) => void | Promise<void>
|
||||
/** Links, embedding and the custom URL, which exist only for a deployed app. */
|
||||
deployed?: {
|
||||
customPath: string | undefined
|
||||
onCustomPathChange: (customPath: string | null) => Promise<void>
|
||||
}
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
let {
|
||||
workspace,
|
||||
appPath,
|
||||
rawApp = false,
|
||||
mode,
|
||||
onModeChange,
|
||||
deployed,
|
||||
disabled = false
|
||||
}: Props = $props()
|
||||
|
||||
// The toggle group keeps the option it was clicked to, so a change the server refuses would
|
||||
// stay highlighted while `mode` never moved. Remounting it once each change settles makes it
|
||||
// show the stored mode either way.
|
||||
let toggleKey = $state(0)
|
||||
async function selectMode(next: AppAccessMode) {
|
||||
try {
|
||||
await onModeChange(next)
|
||||
} finally {
|
||||
toggleKey++
|
||||
}
|
||||
}
|
||||
|
||||
const operatingUser = useOperatingUser()
|
||||
const actingUser = $derived(operatingUser.current)
|
||||
let isAdmin = $derived(!!actingUser?.is_admin || !!actingUser?.is_super_admin)
|
||||
|
||||
// Admins always pass the backend check. Everyone else fails closed while the workspace
|
||||
// protection rules load, so a toggle the rules will restrict is never briefly enabled.
|
||||
let rulesetsLoaded = $derived(protectionRulesState.rulesets !== undefined)
|
||||
let canSetAnonymous = $derived(
|
||||
isAdmin ||
|
||||
(rulesetsLoaded &&
|
||||
canUserBypassRuleKind('RestrictAnonymousAppDeployment', $userStore ?? undefined))
|
||||
)
|
||||
let canSetGuest = $derived(
|
||||
isAdmin ||
|
||||
(rulesetsLoaded &&
|
||||
canUserBypassRuleKind('RestrictGuestAppDeployment', $userStore ?? undefined))
|
||||
)
|
||||
|
||||
let guestUsage = $state<GuestUsage | undefined>(undefined)
|
||||
// The backend decides; the hostname stands in until it answers, the shared cloud being the
|
||||
// only deployment where guests are unavailable.
|
||||
let guestsAvailable = $derived(guestUsage?.available ?? !isCloudHosted())
|
||||
|
||||
let globalWorkspacedRoute = $state(false)
|
||||
let secretUrl: string | undefined = $state(undefined)
|
||||
|
||||
function load() {
|
||||
WorkspaceService.getGuestUsage({ workspace })
|
||||
.then((u) => (guestUsage = u))
|
||||
.catch(() => (guestUsage = undefined))
|
||||
if (!deployed) return
|
||||
SettingService.getGlobal({ key: 'app_workspaced_route' })
|
||||
.then((s) => (globalWorkspacedRoute = (s as boolean) ?? false))
|
||||
.catch(() => (globalWorkspacedRoute = false))
|
||||
AppService.getPublicSecretOfApp({ workspace, path: appPath })
|
||||
.then((s) => (secretUrl = s))
|
||||
.catch(() => (secretUrl = undefined))
|
||||
}
|
||||
load()
|
||||
|
||||
let embedMode = $state(false)
|
||||
let secretUrlHref = $derived(
|
||||
secretUrl ? `${window.location.origin}/public/${workspace}/${secretUrl}` : undefined
|
||||
)
|
||||
let appUrl = $derived(
|
||||
`${window.location.origin}/${rawApp ? 'apps_raw' : 'apps'}/get/${appPath}?workspace=${workspace}`
|
||||
)
|
||||
|
||||
// Custom URL: at most one per app. Adding, editing and removing it each write at once.
|
||||
let editingCustomPath = $state(false)
|
||||
let customPathInput = $state('')
|
||||
let customPathErr: string | undefined = $state(undefined)
|
||||
let savingCustomPath = $state(false)
|
||||
// Shown to admins on EE; the dialog's own writes disable the controls rather than hide them.
|
||||
let mayEditCustomPath = $derived(!!$enterpriseLicense && isAdmin)
|
||||
let canSaveCustomPath = $derived(
|
||||
!disabled &&
|
||||
!savingCustomPath &&
|
||||
customPathInput !== '' &&
|
||||
customPathInput !== deployed?.customPath
|
||||
)
|
||||
// The Embed toggle only shows outside Members, so it must not linger on from another mode.
|
||||
let customUrlEmbed = $derived(embedMode && mode != 'publisher')
|
||||
let customUrlBase = $derived(
|
||||
`${window.location.origin}/a/${isCloudHosted() || globalWorkspacedRoute ? workspace + '/' : ''}`
|
||||
)
|
||||
let fullCustomUrl = $derived(customUrlBase + (deployed?.customPath ?? ''))
|
||||
// The guest JWT rides on the custom URL when set, else on the secret URL.
|
||||
let guestJwtBase = $derived(deployed?.customPath ? fullCustomUrl : secretUrlHref)
|
||||
|
||||
function editCustomPath() {
|
||||
customPathInput = deployed?.customPath ?? ''
|
||||
customPathErr = undefined
|
||||
editingCustomPath = true
|
||||
}
|
||||
|
||||
async function saveCustomPath(next: string | null) {
|
||||
if (!deployed || savingCustomPath) return
|
||||
savingCustomPath = true
|
||||
try {
|
||||
customPathErr =
|
||||
next === null ? undefined : await customPathError(workspace, next, deployed.customPath)
|
||||
if (customPathErr) return
|
||||
await deployed.onCustomPathChange(next)
|
||||
} catch (err) {
|
||||
customPathErr = `Could not check whether the path is free: ${err}`
|
||||
} finally {
|
||||
savingCustomPath = false
|
||||
}
|
||||
// A refused write leaves the deployed path as it was: keep the field open to retry.
|
||||
if ((deployed.customPath ?? null) === next) editingCustomPath = false
|
||||
}
|
||||
|
||||
function toEmbedSnippet(url: string): string {
|
||||
return `<iframe src="${url}" title="Windmill app" width="100%" height="600"></iframe>`
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
{#if rulesetsLoaded && !canSetAnonymous && mode != 'anonymous'}
|
||||
<Alert type="warning" title="Restricted by a workspace protection rule" size="xs">
|
||||
Opening this app to anyone with the link is restricted to workspace admins and bypass users by
|
||||
a workspace protection rule
|
||||
</Alert>
|
||||
{/if}
|
||||
{#if rulesetsLoaded && !canSetGuest && mode != 'guest' && guestsAvailable}
|
||||
<Alert type="warning" title="Restricted by a workspace protection rule" size="xs">
|
||||
Opening this app to guests is restricted to workspace admins and bypass users by a workspace
|
||||
protection rule
|
||||
</Alert>
|
||||
{/if}
|
||||
<div class="flex flex-col gap-1">
|
||||
<div>
|
||||
{#key toggleKey}
|
||||
<ToggleButtonGroup
|
||||
selected={mode}
|
||||
{disabled}
|
||||
onSelected={(m) => {
|
||||
if (m && m !== mode) selectMode(m as AppAccessMode)
|
||||
}}
|
||||
>
|
||||
{#snippet children({ item })}
|
||||
<ToggleButton
|
||||
label="Members"
|
||||
value="publisher"
|
||||
tooltip="Workspace members with read access on this app."
|
||||
{item}
|
||||
/>
|
||||
<ToggleButton
|
||||
label="Guests"
|
||||
value="guest"
|
||||
disabled={mode != 'guest' && (!guestsAvailable || !canSetGuest)}
|
||||
tooltip={!guestsAvailable
|
||||
? 'Not available on Windmill Cloud. Guests require a self-hosted instance or a dedicated Windmill Cloud deployment.'
|
||||
: "Anyone your identity provider authenticates who has no Windmill account, plus workspace members. No membership, no seat up to the instance's allowance."}
|
||||
{item}
|
||||
/>
|
||||
<ToggleButton
|
||||
label="Public"
|
||||
value="anonymous"
|
||||
disabled={!canSetAnonymous && mode != 'anonymous'}
|
||||
tooltip="Anyone with the secret URL. No login."
|
||||
{item}
|
||||
/>
|
||||
{/snippet}
|
||||
</ToggleButtonGroup>
|
||||
{/key}
|
||||
</div>
|
||||
<div class="text-xs text-secondary">
|
||||
{#if mode == 'anonymous'}
|
||||
Anyone holding the secret URL can open this app without signing in.
|
||||
{:else if mode == 'guest'}
|
||||
{#if !guestsAvailable}
|
||||
Guests are not available on Windmill Cloud, so this app still admits members only. They
|
||||
require a self-hosted instance or a dedicated Windmill Cloud deployment.
|
||||
{:else}
|
||||
Anyone your identity provider authenticates can open this app without a Windmill account.
|
||||
They join no workspace. Members of this workspace can open it too.
|
||||
{#if guestUsage}
|
||||
{guestUsage.guest_count} of {guestUsage.free_allowance} free guests used across this instance
|
||||
in the last {guestUsage.window_days} days; beyond that,
|
||||
{guestUsage.metered
|
||||
? 'every four guests count as one seat'
|
||||
: 'new guests are refused until the count drops'}.
|
||||
{/if}
|
||||
{/if}
|
||||
{:else}
|
||||
The people with access above, signed in to Windmill.
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if deployed}
|
||||
<Label label={mode == 'publisher' ? 'Link' : 'Secret URL'}>
|
||||
{#snippet action()}
|
||||
{#if secretUrlHref && mode != 'publisher'}
|
||||
<Toggle
|
||||
size="xs"
|
||||
checked={embedMode}
|
||||
on:change={(e) => (embedMode = e.detail)}
|
||||
options={{ left: 'URL', right: 'Embed' }}
|
||||
/>
|
||||
{/if}
|
||||
{/snippet}
|
||||
{#if mode == 'publisher'}
|
||||
<ClipboardPanel content={appUrl} size="md" />
|
||||
{:else if secretUrlHref}
|
||||
<ClipboardPanel
|
||||
content={embedMode ? toEmbedSnippet(secretUrlHref) : secretUrlHref}
|
||||
size="md"
|
||||
/>
|
||||
<div class="text-2xs text-secondary">
|
||||
{#if embedMode}
|
||||
Paste this iframe snippet into another app.
|
||||
{#if rawApp}
|
||||
To embed it in a cross-origin isolated page, add <code>wm_coep=on</code>
|
||||
<Tooltip
|
||||
>Sets the cross-origin isolation headers (COEP) on the app, which such a page
|
||||
requires of its iframes. The app then only loads cross-origin resources that send
|
||||
CORS or a Cross-Origin-Resource-Policy header.</Tooltip
|
||||
> to the URL.
|
||||
{/if}
|
||||
(if requiring login, top-level domain of embedding app must be the same as the one of Windmill)
|
||||
{:else}
|
||||
An unguessable link. Switch to <b>Embed</b> for an iframe snippet. Only the latest deployed
|
||||
version is served.
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<Loader2 size={16} class="animate-spin" />
|
||||
{/if}
|
||||
</Label>
|
||||
|
||||
<Label
|
||||
label="Custom URL"
|
||||
for="customPath"
|
||||
eeOnly
|
||||
tooltip="Serve the app at a path you pick, on top of its link."
|
||||
>
|
||||
{#snippet action()}
|
||||
{#if !deployed.customPath && !editingCustomPath}
|
||||
<Button
|
||||
variant="default"
|
||||
unifiedSize="sm"
|
||||
startIcon={{ icon: Plus }}
|
||||
disabled={!mayEditCustomPath || disabled}
|
||||
onclick={editCustomPath}
|
||||
>
|
||||
Add custom URL
|
||||
</Button>
|
||||
{/if}
|
||||
{/snippet}
|
||||
{#if editingCustomPath}
|
||||
<div class="flex flex-row gap-2 items-start">
|
||||
<div class="grow min-w-0 flex flex-col gap-1">
|
||||
<TextInput
|
||||
inputProps={{
|
||||
id: 'customPath',
|
||||
autocomplete: 'off',
|
||||
placeholder: 'invoices',
|
||||
onkeydown: (e: KeyboardEvent) => {
|
||||
if (e.key === 'Enter' && canSaveCustomPath) saveCustomPath(customPathInput)
|
||||
}
|
||||
}}
|
||||
size="sm"
|
||||
bind:value={customPathInput}
|
||||
error={customPathErr}
|
||||
/>
|
||||
{#if customPathErr}
|
||||
<span class="text-2xs text-red-600 dark:text-red-400">{customPathErr}</span>
|
||||
{:else}
|
||||
<span class="text-2xs text-secondary truncate">
|
||||
{customUrlBase}{customPathInput || 'invoices'}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
<Button
|
||||
variant="default"
|
||||
unifiedSize="sm"
|
||||
disabled={!canSaveCustomPath}
|
||||
loading={savingCustomPath}
|
||||
onclick={() => saveCustomPath(customPathInput)}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="sm"
|
||||
disabled={savingCustomPath}
|
||||
onclick={() => (editingCustomPath = false)}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
</div>
|
||||
{:else if deployed.customPath}
|
||||
<div class="flex flex-row gap-1 items-center">
|
||||
<div class="grow min-w-0">
|
||||
<ClipboardPanel
|
||||
content={customUrlEmbed ? toEmbedSnippet(fullCustomUrl) : fullCustomUrl}
|
||||
size="md"
|
||||
/>
|
||||
</div>
|
||||
{#if mayEditCustomPath}
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="md"
|
||||
iconOnly
|
||||
startIcon={{ icon: Pen }}
|
||||
aria-label="Edit custom URL"
|
||||
disabled={disabled || savingCustomPath}
|
||||
onclick={editCustomPath}
|
||||
/>
|
||||
<Button
|
||||
variant="subtle"
|
||||
destructive
|
||||
unifiedSize="md"
|
||||
iconOnly
|
||||
startIcon={{ icon: Trash }}
|
||||
aria-label="Remove custom URL"
|
||||
{disabled}
|
||||
loading={savingCustomPath}
|
||||
onclick={() => saveCustomPath(null)}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{#if $enterpriseLicense && !isAdmin}
|
||||
<span class="text-2xs text-secondary">Only workspace admins can set a custom URL.</span>
|
||||
{/if}
|
||||
</Label>
|
||||
|
||||
{#if embedMode && mode == 'guest' && guestJwtBase && guestsAvailable}
|
||||
<Label label="Embed for your own authenticated users (guest JWT)">
|
||||
<div class="text-xs text-secondary">
|
||||
To open this app for a user your own product already authenticates, mint a short-lived JWT
|
||||
in your backend and append it to the app URL as <code>guest.<jwt></code>. Each token
|
||||
is its own seatless guest, confined to this app. Unlike the plain secret URL above, there
|
||||
is no shared secret and no Windmill account.
|
||||
</div>
|
||||
<div class="text-xs text-secondary">
|
||||
Windmill verifies the token against the workspace's guest JWT key (Workspace settings →
|
||||
Guests): a PEM public key or a JWKS URL{#if !isCloudHosted()}, or the instance's
|
||||
configured issuer (<code>JWT_EXT_JWKS_URL</code>) when no workspace key is set{/if}. Set
|
||||
the <b>public</b> half there; in your backend, sign each token with the matching
|
||||
<b>private</b> key using RS256/384/512, PS256/384/512 or ES256/384 (symmetric HS* is
|
||||
refused), carrying <code>email</code>, <code>workspace_id</code> =
|
||||
<code>{workspace}</code>,
|
||||
<code>app_path</code> = <code>{appPath}</code> and <code>exp</code> (at most 24h ahead).
|
||||
</div>
|
||||
<ClipboardPanel
|
||||
content={toEmbedSnippet(`${guestJwtBase}/guest.YOUR_GUEST_JWT`)}
|
||||
size="md"
|
||||
/>
|
||||
<div class="text-2xs text-secondary">
|
||||
Replace <code>YOUR_GUEST_JWT</code> with the token your backend signs per user. Past the instance's
|
||||
free guest allowance a new guest email is refused (see the count above); guests already seen
|
||||
in the window keep working.
|
||||
</div>
|
||||
</Label>
|
||||
{/if}
|
||||
|
||||
<Description
|
||||
link="https://www.windmill.dev/docs/advanced/external_auth_with_jwt#embed-public-apps-using-your-own-authentification"
|
||||
class="text-2xs text-hint"
|
||||
>
|
||||
You can embed this app in your own product, for your own users.
|
||||
</Description>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -1,10 +1,9 @@
|
||||
<script lang="ts">
|
||||
import ConfirmationModal from '$lib/components/common/confirmationModal/ConfirmationModal.svelte'
|
||||
import TextInput from '$lib/components/text_input/TextInput.svelte'
|
||||
import RunOnBehalfOfSetting from './RunOnBehalfOfSetting.svelte'
|
||||
import { appOnBehalfOfTooltip, deployedPermissionedAs } from './onBehalfOf'
|
||||
import DeployOnBehalfOfFields from './DeployOnBehalfOfFields.svelte'
|
||||
import { deployOnBehalfOfQuestion } from './onBehalfOf'
|
||||
import { useOperatingUser } from '$lib/components/operatingWorkspace.svelte'
|
||||
import { AlertTriangle } from 'lucide-svelte'
|
||||
|
||||
interface Props {
|
||||
open: boolean
|
||||
@@ -47,33 +46,23 @@
|
||||
}: Props = $props()
|
||||
|
||||
const operatingUser = useOperatingUser()
|
||||
const me = $derived(
|
||||
operatingUser.current?.username ? `u/${operatingUser.current.username}` : undefined
|
||||
const question = $derived(
|
||||
deployOnBehalfOfQuestion(kind, operatingUser.current, {
|
||||
email,
|
||||
permissionedAs,
|
||||
savedEmail,
|
||||
savedPermissionedAs,
|
||||
isNew,
|
||||
folderDefault
|
||||
})
|
||||
)
|
||||
const savedUser = $derived(savedPermissionedAs ?? savedEmail)
|
||||
// The backend gives a new item in a folder with a default user that user unless the deploy
|
||||
// names one, so only a flow or script outside that case can deploy with the setting off.
|
||||
const required = $derived(kind === 'app' || !!folderDefault)
|
||||
const on = $derived(required || !!email)
|
||||
// A flow or script whose deployed version ran on behalf of someone, turned off by this deploy.
|
||||
const stops = $derived(!on && !!savedUser)
|
||||
const runsAs = $derived(
|
||||
deployedPermissionedAs(operatingUser.current, permissionedAs, folderDefault)
|
||||
)
|
||||
const who = $derived(!runsAs ? 'you' : runsAs === me ? `${runsAs} (you)` : runsAs)
|
||||
const unchanged = $derived(!isNew && !!savedPermissionedAs && runsAs === savedPermissionedAs)
|
||||
const folderDefaultNotMe = $derived(!!folderDefault && runsAs === folderDefault && runsAs !== me)
|
||||
let pickerOpen = $state(false)
|
||||
</script>
|
||||
|
||||
<ConfirmationModal
|
||||
{open}
|
||||
type="info"
|
||||
title={on
|
||||
? `Run this ${kind} on behalf of ${who}?`
|
||||
: stops
|
||||
? `Stop running this ${kind} on behalf of ${savedUser}?`
|
||||
: `Deploy this ${kind}?`}
|
||||
title={question.title}
|
||||
confirmationText="Deploy"
|
||||
confirmDisabled={folderDefaultLoading}
|
||||
keyListen={!pickerOpen}
|
||||
@@ -85,59 +74,20 @@
|
||||
onCanceled={() => (open = false)}
|
||||
>
|
||||
<div class="flex flex-col gap-4">
|
||||
<p>
|
||||
{#if stops}
|
||||
Runs will use the access of whoever starts them, not <strong>{savedUser}</strong>.
|
||||
{:else if !on}
|
||||
Runs will use the access of whoever starts them.
|
||||
{:else if kind === 'app'}
|
||||
The app's runnables use the access of <strong>{runsAs ?? 'your user'}</strong> to resources
|
||||
and variables.
|
||||
{#if executionMode === 'anonymous'}
|
||||
Anyone with the secret URL can run them, and runs by visitors who aren't signed in are
|
||||
recorded as <code>anonymous</code>.
|
||||
{:else}
|
||||
Runs are still recorded under the viewer's name, and the code reads their email from
|
||||
<code>WM_END_USER_EMAIL</code>.
|
||||
{/if}
|
||||
{:else}
|
||||
Every run uses the access of <strong>{runsAs ?? 'your user'}</strong> to resources and
|
||||
variables. Who started it is still recorded, and the code reads their email from
|
||||
<code>WM_END_USER_EMAIL</code>.
|
||||
{/if}
|
||||
</p>
|
||||
<div class="flex flex-col gap-1">
|
||||
<RunOnBehalfOfSetting
|
||||
{kind}
|
||||
{required}
|
||||
tooltip={kind === 'app' ? appOnBehalfOfTooltip(rawApp) : undefined}
|
||||
bind:email
|
||||
bind:permissionedAs
|
||||
{savedEmail}
|
||||
{savedPermissionedAs}
|
||||
{targetWorkspace}
|
||||
{isNew}
|
||||
{folderDefault}
|
||||
aboveConfirmationModal
|
||||
onPickerOpenChange={(o) => (pickerOpen = o)}
|
||||
hideDescription
|
||||
/>
|
||||
{#if on && unchanged}
|
||||
<!-- pl-9 lines it up under the switch's label, as SettingToggle indents its contents. -->
|
||||
<div class={['text-2xs text-secondary', !required && 'pl-9']}>
|
||||
Same as the deployed version.
|
||||
</div>
|
||||
{/if}
|
||||
{#if folderDefaultNotMe}
|
||||
<div class="flex items-start gap-1.5 text-2xs text-yellow-600 dark:text-yellow-400">
|
||||
<AlertTriangle size={14} class="shrink-0 text-yellow-500" />
|
||||
<span>
|
||||
This folder's default user is <strong>{folderDefault}</strong>, so the {kind} won't run
|
||||
with your access. Pick yourself above to change that.
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<DeployOnBehalfOfFields
|
||||
{kind}
|
||||
bind:email
|
||||
bind:permissionedAs
|
||||
{savedEmail}
|
||||
{savedPermissionedAs}
|
||||
{isNew}
|
||||
{folderDefault}
|
||||
{targetWorkspace}
|
||||
{executionMode}
|
||||
{rawApp}
|
||||
aboveConfirmationModal
|
||||
onPickerOpenChange={(o) => (pickerOpen = o)}
|
||||
/>
|
||||
<TextInput bind:value={message} inputProps={{ placeholder: 'Deployment message' }} />
|
||||
</div>
|
||||
</ConfirmationModal>
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<script lang="ts">
|
||||
import RunOnBehalfOfSetting from './RunOnBehalfOfSetting.svelte'
|
||||
import { appOnBehalfOfTooltip, deployOnBehalfOfQuestion } from './onBehalfOf'
|
||||
import { useOperatingUser } from '$lib/components/operatingWorkspace.svelte'
|
||||
import { AlertTriangle } from 'lucide-svelte'
|
||||
|
||||
/** The body of a deploy's question about the user an item runs on behalf of, which the host
|
||||
* titles with `deployOnBehalfOfQuestion`. */
|
||||
interface Props {
|
||||
kind: 'flow' | 'script' | 'app'
|
||||
/** The item's run-as user, which the picker writes; unset runs as whoever starts each run. */
|
||||
email: string | undefined
|
||||
permissionedAs: string | undefined
|
||||
/** The deployed run-as user, unset before the first deploy or when it ran as its caller. */
|
||||
savedEmail: string | undefined
|
||||
savedPermissionedAs: string | undefined
|
||||
isNew: boolean
|
||||
/** The folder's default for a new item's path, which the deploy takes when no user is held. */
|
||||
folderDefault?: string
|
||||
targetWorkspace: string
|
||||
/** Apps: who can open the app, which decides whether viewers are recorded at all. */
|
||||
executionMode?: string
|
||||
rawApp?: boolean
|
||||
/** Inside a `ConfirmationModal`: see `OnBehalfOfSelector`. */
|
||||
aboveConfirmationModal?: boolean
|
||||
onPickerOpenChange?: (open: boolean) => void
|
||||
}
|
||||
|
||||
let {
|
||||
kind,
|
||||
email = $bindable(),
|
||||
permissionedAs = $bindable(),
|
||||
savedEmail,
|
||||
savedPermissionedAs,
|
||||
isNew,
|
||||
folderDefault,
|
||||
targetWorkspace,
|
||||
executionMode,
|
||||
rawApp = false,
|
||||
aboveConfirmationModal = false,
|
||||
onPickerOpenChange
|
||||
}: Props = $props()
|
||||
|
||||
const operatingUser = useOperatingUser()
|
||||
const question = $derived(
|
||||
deployOnBehalfOfQuestion(kind, operatingUser.current, {
|
||||
email,
|
||||
permissionedAs,
|
||||
savedEmail,
|
||||
savedPermissionedAs,
|
||||
isNew,
|
||||
folderDefault
|
||||
})
|
||||
)
|
||||
</script>
|
||||
|
||||
<p>
|
||||
{#if question.stops}
|
||||
Runs will use the access of whoever starts them, not <strong>{question.savedUser}</strong>.
|
||||
{:else if !question.on}
|
||||
Runs will use the access of whoever starts them.
|
||||
{:else if kind === 'app'}
|
||||
The app's runnables use the access of <strong>{question.runsAs ?? 'your user'}</strong> to
|
||||
resources and variables.
|
||||
{#if executionMode === 'anonymous'}
|
||||
Anyone with the secret URL can run them, and runs by visitors who aren't signed in are
|
||||
recorded as <code>anonymous</code>.
|
||||
{:else}
|
||||
Runs are still recorded under the viewer's name, and the code reads their email from
|
||||
<code>WM_END_USER_EMAIL</code>.
|
||||
{/if}
|
||||
{:else}
|
||||
Every run uses the access of <strong>{question.runsAs ?? 'your user'}</strong> to resources and
|
||||
variables. Who started it is still recorded, and the code reads their email from
|
||||
<code>WM_END_USER_EMAIL</code>.
|
||||
{/if}
|
||||
</p>
|
||||
<div class="flex flex-col gap-1">
|
||||
<RunOnBehalfOfSetting
|
||||
{kind}
|
||||
required={question.required}
|
||||
tooltip={kind === 'app' ? appOnBehalfOfTooltip(rawApp) : undefined}
|
||||
bind:email
|
||||
bind:permissionedAs
|
||||
{savedEmail}
|
||||
{savedPermissionedAs}
|
||||
{targetWorkspace}
|
||||
{isNew}
|
||||
{folderDefault}
|
||||
{aboveConfirmationModal}
|
||||
{onPickerOpenChange}
|
||||
hideDescription
|
||||
/>
|
||||
{#if question.on && question.unchanged}
|
||||
<!-- pl-9 lines it up under the switch's label, as SettingToggle indents its contents. -->
|
||||
<div class={['text-2xs text-secondary', !question.required && 'pl-9']}>
|
||||
Same as the deployed version.
|
||||
</div>
|
||||
{/if}
|
||||
{#if question.folderDefaultNotMe}
|
||||
<div class="flex items-start gap-1.5 text-2xs text-yellow-600 dark:text-yellow-400">
|
||||
<AlertTriangle size={14} class="shrink-0 text-yellow-500" />
|
||||
<span>
|
||||
This folder's default user is <strong>{folderDefault}</strong>, so the {kind} won't run with
|
||||
your access. Pick yourself above to change that.
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,308 @@
|
||||
<script lang="ts" module>
|
||||
import { GranularAclService } from '$lib/gen'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import type { AppAccessMode } from './appAccess'
|
||||
import type { ShareKind } from './ShareDialog.svelte'
|
||||
|
||||
export type FirstDeployChoice = {
|
||||
summary: string
|
||||
path: string
|
||||
/** Extra members to add once the item exists, owner → write. */
|
||||
members: Record<string, boolean>
|
||||
/** Apps only. */
|
||||
appMode?: AppAccessMode
|
||||
message: string
|
||||
/** The user the item runs on behalf of as the dialog leaves it, when the caller passed one
|
||||
* in: the second step can change it or turn it off, and the deploy asks nothing more. */
|
||||
runAs?: { email: string | undefined; permissionedAs: string | undefined }
|
||||
}
|
||||
/** Add the members chosen at the first deploy, once the item exists at `path`. */
|
||||
export async function applyFirstDeployMembers(
|
||||
workspace: string,
|
||||
kind: ShareKind,
|
||||
path: string,
|
||||
members: Record<string, boolean>
|
||||
): Promise<void> {
|
||||
for (const [owner, write] of Object.entries(members)) {
|
||||
try {
|
||||
await GranularAclService.addGranularAcls({
|
||||
workspace,
|
||||
path,
|
||||
kind,
|
||||
requestBody: { owner, write }
|
||||
})
|
||||
} catch (err) {
|
||||
sendUserToast(`Deployed, but could not share it with ${owner}: ${err}`, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/components/common'
|
||||
import Modal from '$lib/components/common/modal/Modal.svelte'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
import Path from '$lib/components/Path.svelte'
|
||||
import TextInput from '$lib/components/text_input/TextInput.svelte'
|
||||
import { isPlaceholderName } from '$lib/components/random_positive_adjetive'
|
||||
import {
|
||||
useOperatingUser,
|
||||
useOperatingWorkspace
|
||||
} from '$lib/components/operatingWorkspace.svelte'
|
||||
import { useFolderDefaultPermissionedAs } from '$lib/components/useFolderDefaultPermissionedAs.svelte'
|
||||
import ItemAccessList from './ItemAccessList.svelte'
|
||||
import AppAccessSection from './AppAccessSection.svelte'
|
||||
import DeployOnBehalfOfFields from './DeployOnBehalfOfFields.svelte'
|
||||
import { deployAsksOnBehalfOf, deployOnBehalfOfQuestion } from './onBehalfOf'
|
||||
import { logFirstDeploy } from './sharingTelemetry'
|
||||
|
||||
const operatingWorkspace = useOperatingWorkspace()
|
||||
const operatingUser = useOperatingUser()
|
||||
|
||||
let open = $state(false)
|
||||
let step = $state<'details' | 'runAs'>('details')
|
||||
let kind = $state<ShareKind>('flow')
|
||||
let summary = $state('')
|
||||
let path: string | undefined = $state()
|
||||
let pathError = $state('')
|
||||
let dirtyPath = $state(false)
|
||||
let members: Record<string, boolean> = $state({})
|
||||
let appMode = $state<AppAccessMode>('publisher')
|
||||
let message = $state('')
|
||||
/** Where the item's run-as user is looked up; unset when the caller asks nothing about it. */
|
||||
let runAsWorkspace: string | undefined = $state()
|
||||
let runAsEmail: string | undefined = $state()
|
||||
let runAsPermissionedAs: string | undefined = $state()
|
||||
let pathField: Path | undefined = $state()
|
||||
let resolve: ((choice: FirstDeployChoice | undefined) => void) | undefined
|
||||
|
||||
let noun = $derived(kind === 'raw_app' ? 'app' : kind)
|
||||
let isApp = $derived(kind === 'app' || kind === 'raw_app')
|
||||
let runAsKind = $derived<'flow' | 'script' | 'app'>(kind === 'raw_app' ? 'app' : kind)
|
||||
// A new item takes its folder's default user, so the second step follows the path chosen in
|
||||
// the first.
|
||||
const folderDefault = useFolderDefaultPermissionedAs(
|
||||
() => (open && runAsWorkspace !== undefined ? path : undefined),
|
||||
() => runAsWorkspace
|
||||
)
|
||||
let asksRunAs = $derived(
|
||||
runAsWorkspace !== undefined &&
|
||||
deployAsksOnBehalfOf(runAsKind, {
|
||||
user: operatingUser.current,
|
||||
email: runAsEmail,
|
||||
permissionedAs: runAsPermissionedAs,
|
||||
savedEmail: undefined,
|
||||
savedPermissionedAs: undefined,
|
||||
folderDefault: folderDefault.value
|
||||
})
|
||||
)
|
||||
let question = $derived(
|
||||
deployOnBehalfOfQuestion(runAsKind, operatingUser.current, {
|
||||
email: runAsEmail,
|
||||
permissionedAs: runAsPermissionedAs,
|
||||
savedEmail: undefined,
|
||||
savedPermissionedAs: undefined,
|
||||
isNew: true,
|
||||
folderDefault: folderDefault.value
|
||||
})
|
||||
)
|
||||
|
||||
function slug(s: string): string {
|
||||
return s
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9_]/g, '_')
|
||||
.replace(/_+/g, '_')
|
||||
.replace(/^_|_$/g, '')
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask where a never-deployed item goes and who reaches it, then, where a deploy asks it, who
|
||||
* it runs on behalf of. Resolves to the choice, or to undefined when the dialog is dismissed.
|
||||
* The name follows the summary while it is still the placeholder the editor generated.
|
||||
*/
|
||||
export function ask(opts: {
|
||||
kind: ShareKind
|
||||
summary: string
|
||||
path: string
|
||||
/** The caller picked the path, so it does not follow the summary. */
|
||||
pathChosen?: boolean
|
||||
appMode?: AppAccessMode
|
||||
/** The user the item holds to run on behalf of, which the second step confirms. */
|
||||
runAs?: {
|
||||
email: string | undefined
|
||||
permissionedAs: string | undefined
|
||||
targetWorkspace: string
|
||||
}
|
||||
}): Promise<FirstDeployChoice | undefined> {
|
||||
resolve?.(undefined)
|
||||
step = 'details'
|
||||
kind = opts.kind
|
||||
runAsWorkspace = opts.runAs?.targetWorkspace
|
||||
runAsEmail = opts.runAs?.email
|
||||
runAsPermissionedAs = opts.runAs?.permissionedAs
|
||||
summary = opts.summary
|
||||
pathError = ''
|
||||
// A new item is parked at `draft_<uuid>` or named `<adjective>_<kind>` until someone names it.
|
||||
const segments = opts.path.split('/')
|
||||
const generated =
|
||||
isPlaceholderName(opts.path) || /^draft_[0-9a-f_]+$/.test(segments.at(-1) ?? '')
|
||||
dirtyPath = !!opts.pathChosen || !generated
|
||||
const name = slug(opts.summary)
|
||||
// Named here rather than through Path once it is open: Path parses the path it is handed a
|
||||
// tick after mounting, and drops a name set before that.
|
||||
path = !dirtyPath && name ? [...segments.slice(0, -1), name].join('/') : opts.path
|
||||
members = {}
|
||||
appMode = opts.appMode ?? 'publisher'
|
||||
message = ''
|
||||
open = true
|
||||
return new Promise((r) => (resolve = r))
|
||||
}
|
||||
|
||||
function finish(choice: FirstDeployChoice | undefined) {
|
||||
// Modal writes `open` back on every close, an unchanged `false` included: only an `ask`
|
||||
// still waiting is answered.
|
||||
const r = resolve
|
||||
if (!r) return
|
||||
resolve = undefined
|
||||
logFirstDeploy(choice ? 'deployed' : 'cancelled')
|
||||
open = false
|
||||
r(choice)
|
||||
}
|
||||
|
||||
async function next() {
|
||||
if (!path || pathError) return
|
||||
// The folder default follows a path change a fetch later: read it for the path chosen.
|
||||
if (runAsWorkspace !== undefined) await folderDefault.refetch()
|
||||
if (asksRunAs) step = 'runAs'
|
||||
else deploy()
|
||||
}
|
||||
|
||||
function deploy() {
|
||||
if (!path || pathError) return
|
||||
finish({
|
||||
summary,
|
||||
path,
|
||||
members: $state.snapshot(members),
|
||||
appMode: isApp ? appMode : undefined,
|
||||
message,
|
||||
runAs:
|
||||
runAsWorkspace !== undefined
|
||||
? { email: runAsEmail, permissionedAs: runAsPermissionedAs }
|
||||
: undefined
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Closed by Escape at the first step, the backdrop or the close button: a dismissal. On the second
|
||||
step Escape goes back to the first. -->
|
||||
<Modal
|
||||
bind:open={() => open, (v) => (v ? (open = true) : finish(undefined))}
|
||||
title="Deploy this {noun}"
|
||||
trail={step === 'runAs'
|
||||
? [
|
||||
{ label: `Deploy this ${noun}`, onclick: () => (step = 'details') },
|
||||
{ label: question.title }
|
||||
]
|
||||
: undefined}
|
||||
description={step === 'details'
|
||||
? 'First deploy: choose its name and who can reach it. Share changes both later.'
|
||||
: undefined}
|
||||
kind="X"
|
||||
enterConfirms={false}
|
||||
fitHeight
|
||||
class="sm:max-w-xl"
|
||||
>
|
||||
{#if step === 'runAs'}
|
||||
<div class="flex flex-col gap-4">
|
||||
<DeployOnBehalfOfFields
|
||||
kind={runAsKind}
|
||||
bind:email={runAsEmail}
|
||||
bind:permissionedAs={runAsPermissionedAs}
|
||||
savedEmail={undefined}
|
||||
savedPermissionedAs={undefined}
|
||||
isNew
|
||||
folderDefault={folderDefault.value}
|
||||
targetWorkspace={runAsWorkspace ?? ''}
|
||||
executionMode={isApp ? appMode : undefined}
|
||||
rawApp={kind === 'raw_app'}
|
||||
/>
|
||||
<div class="flex flex-row justify-end gap-2">
|
||||
<Button variant="default" unifiedSize="md" onclick={() => (step = 'details')}>Back</Button>
|
||||
<Button variant="accent" unifiedSize="md" disabled={folderDefault.loading} onclick={deploy}
|
||||
>Deploy</Button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<!-- Kept mounted on the second step, so going back finds the path and the people as they
|
||||
were left. -->
|
||||
<div class="flex flex-col gap-6 h-full {step === 'details' ? '' : 'hidden'}">
|
||||
<Label label="Summary" for="first-deploy-summary">
|
||||
<TextInput
|
||||
inputProps={{
|
||||
id: 'first-deploy-summary',
|
||||
placeholder: 'Short summary to be displayed when listed',
|
||||
oninput: (e: Event) => {
|
||||
const typed = slug((e.currentTarget as HTMLInputElement).value)
|
||||
if (!dirtyPath && typed) pathField?.setName(typed)
|
||||
}
|
||||
}}
|
||||
bind:value={summary}
|
||||
/>
|
||||
</Label>
|
||||
|
||||
<Label label="Path">
|
||||
<Path
|
||||
bind:this={pathField}
|
||||
bind:path
|
||||
bind:error={pathError}
|
||||
bind:dirty={dirtyPath}
|
||||
initialPath=""
|
||||
kind={kind === 'raw_app' ? 'app' : kind}
|
||||
namePlaceholder={noun}
|
||||
autofocus={false}
|
||||
/>
|
||||
</Label>
|
||||
|
||||
{#if path}
|
||||
{#key path}
|
||||
<ItemAccessList {kind} {path} title="Who gets access" bind:pending={members} />
|
||||
{/key}
|
||||
{/if}
|
||||
|
||||
{#if isApp}
|
||||
<section class="flex flex-col gap-2">
|
||||
<h3 class="text-sm font-semibold text-emphasis">Who can open the app</h3>
|
||||
<AppAccessSection
|
||||
workspace={$operatingWorkspace!}
|
||||
appPath={path ?? ''}
|
||||
rawApp={kind === 'raw_app'}
|
||||
mode={appMode}
|
||||
onModeChange={(m) => {
|
||||
appMode = m
|
||||
}}
|
||||
/>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<Label label="Deployment message" for="first-deploy-message">
|
||||
<TextInput
|
||||
inputProps={{ id: 'first-deploy-message', placeholder: 'Optional' }}
|
||||
bind:value={message}
|
||||
/>
|
||||
</Label>
|
||||
|
||||
<div class="flex flex-row justify-end gap-2">
|
||||
<Button variant="default" unifiedSize="md" onclick={() => finish(undefined)}>Cancel</Button>
|
||||
<!-- Whether a second step asks who it runs on behalf of waits on the folder default. -->
|
||||
<Button
|
||||
variant="accent"
|
||||
unifiedSize="md"
|
||||
disabled={!path || !!pathError || folderDefault.loading}
|
||||
onclick={next}
|
||||
>
|
||||
{asksRunAs ? 'Next' : 'Deploy'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
@@ -0,0 +1,478 @@
|
||||
<script lang="ts">
|
||||
import { FolderService, GranularAclService, GroupService, UserService } from '$lib/gen'
|
||||
import type { Folder } from '$lib/gen'
|
||||
import { Button } from '$lib/components/common'
|
||||
import DropdownV2 from '$lib/components/DropdownV2.svelte'
|
||||
import Select from '$lib/components/select/Select.svelte'
|
||||
import { ChevronDown, Plus, Trash } from 'lucide-svelte'
|
||||
import GroupEditorDrawer from '$lib/components/GroupEditorDrawer.svelte'
|
||||
import FolderEditorDrawer from '$lib/components/FolderEditorDrawer.svelte'
|
||||
import { Cell, DataTable, Row } from '$lib/components/table'
|
||||
import Head from '$lib/components/table/Head.svelte'
|
||||
import AccessHelp from './AccessHelp.svelte'
|
||||
import { untrack } from 'svelte'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import { isOwner } from '$lib/utils'
|
||||
import { DEMO_RESTRICTION_HINT, isDemoWorkspaceRestricted } from '$lib/cloud'
|
||||
import { useScheduleLock, useTriggerLock } from '$lib/operatorWriteRights'
|
||||
import {
|
||||
useOperatingUser,
|
||||
useOperatingWorkspace,
|
||||
useReadOnlyWorkspace
|
||||
} from '$lib/components/operatingWorkspace.svelte'
|
||||
import { byName, folderOfPath, inheritedAccess } from './inheritedAccess'
|
||||
import TextInput from '$lib/components/text_input/TextInput.svelte'
|
||||
|
||||
interface Props {
|
||||
/** The granular ACL kind of the item, as GranularAclService names it. */
|
||||
kind: string
|
||||
path: string
|
||||
/** The list's heading. */
|
||||
title?: string
|
||||
/** Variables to give the same extra members, e.g. those a resource links to. */
|
||||
alsoApplyTo?: string[]
|
||||
/** When set, members are collected here instead of written, for an item not deployed yet. */
|
||||
pending?: Record<string, boolean>
|
||||
/** For an item whose name is not a path, such as a volume. */
|
||||
isOwnerOverride?: boolean
|
||||
onChange?: () => void
|
||||
}
|
||||
|
||||
let {
|
||||
kind,
|
||||
path,
|
||||
title = 'People with access',
|
||||
alsoApplyTo = [],
|
||||
pending = $bindable(),
|
||||
isOwnerOverride,
|
||||
onChange
|
||||
}: Props = $props()
|
||||
|
||||
const operatingWorkspace = useOperatingWorkspace()
|
||||
const operatingUser = useOperatingUser()
|
||||
const readOnly = useReadOnlyWorkspace()
|
||||
const scheduleLock = useScheduleLock()
|
||||
const triggerLock = useTriggerLock()
|
||||
|
||||
let restricted = $derived(
|
||||
isDemoWorkspaceRestricted(
|
||||
$operatingWorkspace,
|
||||
operatingUser.current?.is_admin,
|
||||
operatingUser.current?.is_super_admin
|
||||
)
|
||||
)
|
||||
// Sharing a schedule or trigger is a write operators can lose; reading stays open.
|
||||
let writeLock = $derived(
|
||||
kind === 'schedule' ? $scheduleLock : kind.endsWith('_trigger') ? $triggerLock : undefined
|
||||
)
|
||||
// Derived, not captured once: the operating user resolves after mount in a fork.
|
||||
let own = $derived(
|
||||
isOwnerOverride ??
|
||||
(!!operatingUser.current && isOwner(path, operatingUser.current, $operatingWorkspace))
|
||||
)
|
||||
// A session can switch to Use while the list is open, so read-only is read live.
|
||||
let inUseMode = $derived(readOnly($operatingWorkspace))
|
||||
let canEdit = $derived(own && !inUseMode && !restricted && !writeLock)
|
||||
|
||||
let folder: Folder | undefined = $state()
|
||||
let saved: Record<string, boolean> = $state({})
|
||||
// Every user and group of the workspace, for the Add people picker: loaded on its first use,
|
||||
// since it grows with the workspace and most opens of this list add no one.
|
||||
let principals: string[] | undefined = $state()
|
||||
let newMember: string | undefined = $state()
|
||||
let adding = $state(false)
|
||||
let groupDrawer: GroupEditorDrawer | undefined = $state()
|
||||
let folderDrawer: FolderEditorDrawer | undefined = $state()
|
||||
|
||||
let members = $derived(pending ?? saved)
|
||||
let inherited = $derived(inheritedAccess(path, folder))
|
||||
|
||||
type ListRow = {
|
||||
name: string
|
||||
write: boolean
|
||||
source: string
|
||||
editable: boolean
|
||||
/** The folder the access comes from. */
|
||||
folder?: string
|
||||
}
|
||||
let ownRows: ListRow[] = $derived(
|
||||
Object.entries(members)
|
||||
.map(([name, write]) => ({ name, write, source: 'Extra permission', editable: true }))
|
||||
.sort(byName)
|
||||
)
|
||||
let inheritedRows: ListRow[] = $derived(
|
||||
(inherited?.rows ?? []).map((r) => ({
|
||||
...r,
|
||||
source: inherited!.source,
|
||||
editable: false,
|
||||
folder: folder?.name
|
||||
}))
|
||||
)
|
||||
// The rows this list can change stay above a folder's members, who can run to hundreds; the
|
||||
// owner of a `u/` or `g/` path stays first.
|
||||
let rows = $derived(
|
||||
folderOfPath(path) !== undefined
|
||||
? [...ownRows, ...inheritedRows]
|
||||
: [...inheritedRows, ...ownRows]
|
||||
)
|
||||
|
||||
// From this many rows a search shows, and the list may shrink to its minimum height and scroll
|
||||
// when the dialog runs out of room. Both follow every row, not the matching ones, so typing
|
||||
// never hides the field.
|
||||
const MANY_ROWS = 8
|
||||
let many = $derived(rows.length >= MANY_ROWS)
|
||||
let search = $state('')
|
||||
let query = $derived(many ? search.trim().toLowerCase() : '')
|
||||
let shownRows = $derived(query ? rows.filter((r) => r.name.toLowerCase().includes(query)) : rows)
|
||||
// The list's height with every row shown, kept while a search narrows it: a dialog sized by
|
||||
// its content would otherwise shrink, and move, as matches drop out.
|
||||
let fullHeight = $state(0)
|
||||
|
||||
// Member counts of the groups the list shows, keyed `g/<name>`, one read per group. Called
|
||||
// wherever group rows can appear. A group that cannot be read gets no count and no button.
|
||||
let groupSizes: Record<string, number> = $state({})
|
||||
const requestedGroups = new Set<string>()
|
||||
function loadGroupSizes() {
|
||||
for (const { name } of rows) {
|
||||
if (!name.startsWith('g/') || requestedGroups.has(name)) continue
|
||||
requestedGroups.add(name)
|
||||
loadGroupSize(name)
|
||||
}
|
||||
}
|
||||
function loadGroupSize(name: string) {
|
||||
GroupService.getGroup({ workspace: $operatingWorkspace!, name: name.slice(2) })
|
||||
.then((g) => (groupSizes[name] = g.members?.length ?? 0))
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
async function loadFolder() {
|
||||
const name = folderOfPath(path)
|
||||
if (name === undefined) return
|
||||
try {
|
||||
folder = await FolderService.getFolder({ workspace: $operatingWorkspace!, name })
|
||||
loadGroupSizes()
|
||||
} catch {
|
||||
// A user outside the folder cannot read it; the list then shows only admins.
|
||||
}
|
||||
}
|
||||
|
||||
async function loadAcls() {
|
||||
if (pending !== undefined) return
|
||||
saved = await GranularAclService.getGranularAcls({
|
||||
workspace: $operatingWorkspace!,
|
||||
path,
|
||||
kind: kind as any
|
||||
})
|
||||
loadGroupSizes()
|
||||
}
|
||||
|
||||
async function loadPrincipals() {
|
||||
try {
|
||||
const [users, groups] = await Promise.all([
|
||||
UserService.listUsernames({ workspace: $operatingWorkspace! }),
|
||||
GroupService.listGroupNames({ workspace: $operatingWorkspace! })
|
||||
])
|
||||
principals = [...users.map((u) => `u/${u}`), ...groups.map((g) => `g/${g}`)]
|
||||
} catch (err) {
|
||||
sendUserToast(`Could not load users and groups: ${err}`, true)
|
||||
}
|
||||
}
|
||||
|
||||
function startAdding() {
|
||||
adding = true
|
||||
if (principals === undefined) loadPrincipals()
|
||||
}
|
||||
|
||||
// Once: a caller showing another item remounts this list.
|
||||
untrack(() => {
|
||||
if (!path) return
|
||||
// The owning group of a `g/` path is a row before anything loads.
|
||||
loadGroupSizes()
|
||||
loadFolder()
|
||||
loadAcls().catch((err) => sendUserToast(`Could not load who has access: ${err}`, true))
|
||||
})
|
||||
|
||||
async function forEachTarget(fn: (path: string, kind: string) => Promise<unknown>) {
|
||||
await fn(path, kind)
|
||||
for (const varPath of alsoApplyTo) {
|
||||
try {
|
||||
await fn(varPath, 'variable')
|
||||
} catch (err) {
|
||||
sendUserToast(`Failed to update variable ${varPath}: ${err}`, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function setMember(owner: string, write: boolean) {
|
||||
if (pending !== undefined) {
|
||||
pending = { ...pending, [owner]: write }
|
||||
loadGroupSizes()
|
||||
return
|
||||
}
|
||||
try {
|
||||
await forEachTarget((p, k) =>
|
||||
GranularAclService.addGranularAcls({
|
||||
workspace: $operatingWorkspace!,
|
||||
path: p,
|
||||
kind: k as any,
|
||||
requestBody: { owner, write }
|
||||
})
|
||||
)
|
||||
onChange?.()
|
||||
} catch (err) {
|
||||
sendUserToast(`Could not share with ${owner}: ${err}`, true)
|
||||
}
|
||||
await loadAcls()
|
||||
}
|
||||
|
||||
async function removeMember(owner: string) {
|
||||
if (pending !== undefined) {
|
||||
const { [owner]: _, ...rest } = pending
|
||||
pending = rest
|
||||
return
|
||||
}
|
||||
try {
|
||||
await forEachTarget((p, k) =>
|
||||
GranularAclService.removeGranularAcls({
|
||||
workspace: $operatingWorkspace!,
|
||||
path: p,
|
||||
kind: k as any,
|
||||
requestBody: { owner }
|
||||
})
|
||||
)
|
||||
onChange?.()
|
||||
} catch (err) {
|
||||
sendUserToast(`Could not remove ${owner}: ${err}`, true)
|
||||
}
|
||||
await loadAcls()
|
||||
}
|
||||
|
||||
let candidates = $derived(
|
||||
(principals ?? []).filter((p) => !(p in members)).map((p) => ({ label: p, value: p }))
|
||||
)
|
||||
</script>
|
||||
|
||||
<!-- As an item of a flex column with a definite height, a long list gives up height down to its
|
||||
minimum and scrolls under its sticky header, so the rest of the dialog keeps its place. -->
|
||||
<div
|
||||
class="flex flex-col gap-2 {many ? 'min-h-60' : ''}"
|
||||
style:height={query && fullHeight ? `${fullHeight}px` : undefined}
|
||||
bind:clientHeight={
|
||||
null,
|
||||
(h) => {
|
||||
if (!query) fullHeight = h ?? 0
|
||||
}
|
||||
}
|
||||
>
|
||||
<div class="flex items-center gap-2 h-7">
|
||||
<h3 class="grow shrink-0 flex items-center gap-1 text-sm font-semibold text-emphasis">
|
||||
{title}
|
||||
<AccessHelp />
|
||||
</h3>
|
||||
{#if many}
|
||||
<TextInput
|
||||
size="sm"
|
||||
class="w-56 min-w-0"
|
||||
bind:value={search}
|
||||
inputProps={{
|
||||
type: 'search',
|
||||
placeholder: `Search ${rows.length} users and groups`,
|
||||
'aria-label': 'Search people with access'
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
{#if canEdit && !adding}
|
||||
<Button variant="default" unifiedSize="sm" startIcon={{ icon: Plus }} onclick={startAdding}>
|
||||
Add people
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if canEdit && adding}
|
||||
<div class="flex flex-row gap-2 items-center">
|
||||
<Select
|
||||
items={candidates}
|
||||
loading={principals === undefined}
|
||||
bind:value={newMember}
|
||||
placeholder="A user or group"
|
||||
class="grow min-w-0"
|
||||
size="sm"
|
||||
autofocus
|
||||
/>
|
||||
<Button
|
||||
variant="default"
|
||||
unifiedSize="sm"
|
||||
disabled={!newMember}
|
||||
onclick={async () => {
|
||||
if (!newMember) return
|
||||
const member = newMember
|
||||
newMember = undefined
|
||||
adding = false
|
||||
await setMember(member, false)
|
||||
}}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="sm"
|
||||
onclick={() => {
|
||||
newMember = undefined
|
||||
adding = false
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Takes what the list's own height leaves (its default `h-full`), which needs that height to
|
||||
be definite for the table's box to scroll. Fixed column widths keep the columns still as
|
||||
the rows change. -->
|
||||
<DataTable size="sm" tableFixed>
|
||||
<Head>
|
||||
<tr>
|
||||
<Cell head first class="text-secondary">Name</Cell>
|
||||
<Cell head class="text-secondary w-36">Access from</Cell>
|
||||
<Cell head class="text-secondary w-28">Role</Cell>
|
||||
<Cell head last actions class="w-16"></Cell>
|
||||
</tr>
|
||||
</Head>
|
||||
<tbody class="divide-y">
|
||||
{#each shownRows as row (`${row.source}:${row.name}`)}
|
||||
{@const size = groupSizes[row.name]}
|
||||
<Row>
|
||||
<Cell first>
|
||||
<div class="flex items-center gap-1.5 min-w-0">
|
||||
<span class="truncate" title={row.name}>{row.name}</span>
|
||||
{#if size !== undefined}
|
||||
<span class="text-hint shrink-0" aria-hidden="true">·</span>
|
||||
<!-- The demo workspace hides who is in `all`, answering a single placeholder.
|
||||
`-ml-1` cancels the button's padding, so its label sits as far from the dot
|
||||
as the name does. -->
|
||||
<div class="-my-1 -ml-1 shrink-0">
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="2xs"
|
||||
btnClasses="text-secondary hover:text-primary"
|
||||
title="Members of {row.name}"
|
||||
onclick={() => groupDrawer?.initEdit(row.name.slice(2))}
|
||||
>
|
||||
{restricted ? 'Members' : `${size} ${size === 1 ? 'member' : 'members'}`}
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</Cell>
|
||||
<Cell class="text-secondary truncate" title={row.source}>
|
||||
{#if row.folder}
|
||||
{@const folderName = row.folder}
|
||||
<!-- `-ml-1` cancels the button's padding, so its label lines up with the
|
||||
sources of the other rows. -->
|
||||
<div class="flex min-w-0 -ml-1 -my-1">
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="2xs"
|
||||
wrapperClasses="min-w-0 shrink"
|
||||
btnClasses="min-w-0 text-secondary hover:text-primary"
|
||||
title="Members of folder {folderName}"
|
||||
onclick={() => folderDrawer?.initEdit(folderName)}
|
||||
>
|
||||
<span class="truncate">{row.source}</span>
|
||||
</Button>
|
||||
</div>
|
||||
{:else}
|
||||
{row.source}
|
||||
{/if}
|
||||
</Cell>
|
||||
<Cell>
|
||||
{#if row.editable && canEdit}
|
||||
<!-- Negative margins keep the row as tall as the plain ones and line the
|
||||
button's label up with their roles. -->
|
||||
<div class="-ml-3 -my-2">
|
||||
<DropdownV2
|
||||
items={[
|
||||
{
|
||||
displayName: 'Viewer',
|
||||
action: () => row.write && setMember(row.name, false)
|
||||
},
|
||||
{
|
||||
displayName: 'Writer',
|
||||
action: () => !row.write && setMember(row.name, true)
|
||||
}
|
||||
]}
|
||||
placement="bottom-start"
|
||||
>
|
||||
{#snippet buttonReplacement()}
|
||||
<Button
|
||||
nonCaptureEvent
|
||||
variant="subtle"
|
||||
unifiedSize="sm"
|
||||
endIcon={{ icon: ChevronDown }}
|
||||
aria-label="Role of {row.name}"
|
||||
>
|
||||
{row.write ? 'Writer' : 'Viewer'}
|
||||
</Button>
|
||||
{/snippet}
|
||||
</DropdownV2>
|
||||
</div>
|
||||
{:else}
|
||||
<span class="text-secondary">{row.write ? 'Writer' : 'Viewer'}</span>
|
||||
{/if}
|
||||
</Cell>
|
||||
<Cell last actions>
|
||||
{#if row.editable && canEdit}
|
||||
<div class="-my-2">
|
||||
<Button
|
||||
variant="subtle"
|
||||
destructive
|
||||
unifiedSize="sm"
|
||||
iconOnly
|
||||
startIcon={{ icon: Trash }}
|
||||
aria-label="Remove {row.name}"
|
||||
onclick={() => removeMember(row.name)}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
</Cell>
|
||||
</Row>
|
||||
{/each}
|
||||
{#if inherited?.note && !query}
|
||||
<Row>
|
||||
<Cell first class="text-secondary truncate" title={inherited.note}>
|
||||
{inherited.note}
|
||||
</Cell>
|
||||
<Cell class="text-secondary truncate" title={inherited.source}>
|
||||
{inherited.source}
|
||||
</Cell>
|
||||
<Cell></Cell>
|
||||
<Cell last actions></Cell>
|
||||
</Row>
|
||||
{:else if shownRows.length === 0}
|
||||
<Row>
|
||||
<Cell first last colspan={4} class="text-hint truncate">
|
||||
{query ? `No one matches “${search.trim()}”` : 'Only workspace admins'}
|
||||
</Cell>
|
||||
</Row>
|
||||
{/if}
|
||||
</tbody>
|
||||
</DataTable>
|
||||
|
||||
{#if inUseMode}
|
||||
<span class="text-2xs text-secondary">
|
||||
This session cannot change who has access while it is in Use mode.
|
||||
</span>
|
||||
{:else if !own && operatingUser.current}
|
||||
<span class="text-2xs text-secondary">
|
||||
Only its owner and workspace admins can change who has access.
|
||||
</span>
|
||||
{:else if own && (restricted || writeLock)}
|
||||
<span class="text-2xs text-secondary">{writeLock ?? DEMO_RESTRICTION_HINT}</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Show who a group or folder row stands for. Each editor decides whether this user may change
|
||||
it, and opens read-only otherwise; a change there reaches everything shared with the group
|
||||
or kept in the folder. -->
|
||||
<GroupEditorDrawer bind:this={groupDrawer} onSaved={(name) => loadGroupSize(`g/${name}`)} />
|
||||
<FolderEditorDrawer bind:this={folderDrawer} onSaved={loadFolder} />
|
||||
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import { Alert } from '$lib/components/common'
|
||||
import { movesToAnotherOwner, ownerLabel } from './inheritedAccess'
|
||||
|
||||
interface Props {
|
||||
kind: 'flow' | 'script' | 'app'
|
||||
/** Where the deployed item is. Undefined before its first deploy, which moves nothing. */
|
||||
deployedPath: string | undefined
|
||||
/** The path the next deploy gives it. */
|
||||
path: string
|
||||
}
|
||||
|
||||
let { kind, deployedPath, path }: Props = $props()
|
||||
</script>
|
||||
|
||||
{#if deployedPath && path && path !== deployedPath}
|
||||
{#if movesToAnotherOwner(deployedPath, path)}
|
||||
<Alert
|
||||
type="warning"
|
||||
size="xs"
|
||||
title="Moving it from {ownerLabel(deployedPath)} to {ownerLabel(path)} changes who has access"
|
||||
class="mt-2"
|
||||
>
|
||||
Deploying shows who loses access and asks you to confirm.
|
||||
</Alert>
|
||||
{:else}
|
||||
<Alert
|
||||
type="info"
|
||||
size="xs"
|
||||
title="Deploy the {kind} to make the path change effective."
|
||||
class="mt-2"
|
||||
/>
|
||||
{/if}
|
||||
{/if}
|
||||
@@ -0,0 +1,26 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/components/common'
|
||||
import { UserPlus } from 'lucide-svelte'
|
||||
|
||||
interface Props {
|
||||
/** Sharing needs a deployed item: its access lives on the deployed row. */
|
||||
deployed: boolean
|
||||
iconOnly?: boolean
|
||||
unifiedSize?: 'sm' | 'md'
|
||||
onclick: () => void
|
||||
}
|
||||
|
||||
let { deployed, iconOnly = false, unifiedSize = 'md', onclick }: Props = $props()
|
||||
</script>
|
||||
|
||||
<Button
|
||||
variant="default"
|
||||
{unifiedSize}
|
||||
startIcon={{ icon: UserPlus }}
|
||||
{iconOnly}
|
||||
disabled={!deployed}
|
||||
title={deployed ? 'Share' : 'Deploy once to share it'}
|
||||
{onclick}
|
||||
>
|
||||
Share
|
||||
</Button>
|
||||
@@ -0,0 +1,425 @@
|
||||
<script lang="ts" module>
|
||||
export type ShareKind = 'flow' | 'script' | 'app' | 'raw_app'
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { Alert, Button, Section } from '$lib/components/common'
|
||||
import Modal from '$lib/components/common/modal/Modal.svelte'
|
||||
import {
|
||||
AppService,
|
||||
FlowService,
|
||||
FolderService,
|
||||
GranularAclService,
|
||||
GroupService,
|
||||
ScriptService,
|
||||
type AppWithLastVersion,
|
||||
type Folder
|
||||
} from '$lib/gen'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import {
|
||||
useOperatingUser,
|
||||
useOperatingWorkspace
|
||||
} from '$lib/components/operatingWorkspace.svelte'
|
||||
import ItemAccessList from './ItemAccessList.svelte'
|
||||
import AppAccessSection from './AppAccessSection.svelte'
|
||||
import {
|
||||
accessModeOf,
|
||||
modeChangeRefusal,
|
||||
updateDeployedAppAccess,
|
||||
type AppAccessMode
|
||||
} from './appAccess'
|
||||
import { canPreserveOnBehalfOf } from './onBehalfOf'
|
||||
import {
|
||||
accessLostByMove,
|
||||
folderOfPath,
|
||||
inheritedAccess,
|
||||
movesToAnotherOwner,
|
||||
ownerLabel
|
||||
} from './inheritedAccess'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
import ClipboardPanel from '$lib/components/details/ClipboardPanel.svelte'
|
||||
import { logShareOpen, type ShareOpenSource } from './sharingTelemetry'
|
||||
import { useEditRights, useRoleCapabilities } from '$lib/operatorWriteRights'
|
||||
|
||||
interface Props {
|
||||
/** Called after a write to the app row, with the row as it now is. */
|
||||
onAppChanged?: (row: AppWithLastVersion) => void
|
||||
/** Called after any change, for a list to refresh. */
|
||||
onChange?: () => void
|
||||
}
|
||||
|
||||
let { onAppChanged, onChange }: Props = $props()
|
||||
|
||||
const operatingWorkspace = useOperatingWorkspace()
|
||||
const operatingUser = useOperatingUser()
|
||||
const editRights = useEditRights()
|
||||
const roleCaps = useRoleCapabilities()
|
||||
|
||||
let open = $state(false)
|
||||
let kind = $state<ShareKind>('flow')
|
||||
let path = $state('')
|
||||
/** Opened from an editor, whose other settings wait for the next deploy. */
|
||||
let fromEditor = $state(false)
|
||||
/** Where the editor's draft moves the item, when that is under another owner. */
|
||||
let moveTo: string | undefined = $state()
|
||||
/** Who that move takes access from, once read. */
|
||||
let moveLoss: { lost: string[]; demoted: string[] } | undefined = $state()
|
||||
let moveLossReads = 0
|
||||
/** The label of the button that goes on with a deploy waiting on this dialog. */
|
||||
let deployLabel: string | undefined = $state()
|
||||
let answerDeploy: ((deploy: boolean) => void) | undefined = undefined
|
||||
|
||||
let app: AppWithLastVersion | undefined = $state()
|
||||
let appBusy = $state(false)
|
||||
/** Who the deployed flow or script runs as, and whether the user may change it, once read. An
|
||||
* app's run-as user is in its policy. */
|
||||
let runnableIdentity: { runAs: string | undefined; canEdit: boolean } | undefined = $state()
|
||||
|
||||
let name = $derived(path.split('/').pop() ?? path)
|
||||
let noun = $derived(kind === 'raw_app' ? 'app' : kind)
|
||||
let isApp = $derived(kind === 'app' || kind === 'raw_app')
|
||||
let runAs = $derived(app?.policy.on_behalf_of ?? app?.policy.on_behalf_of_email)
|
||||
// Who can open the app is part of its policy, which only someone who can edit the app may
|
||||
// rewrite; the lists and detail pages open this dialog for readers too.
|
||||
let canWriteApp = $derived(
|
||||
!!app && editRights.canEditItem(app.raw_app ? 'raw_app' : 'app', app.path, app.extra_perms)
|
||||
)
|
||||
let modeRefusal = $derived(
|
||||
app &&
|
||||
modeChangeRefusal(app.policy, {
|
||||
username: operatingUser.current?.username,
|
||||
canPreserveRunAs: canPreserveOnBehalfOf(operatingUser.current),
|
||||
composeOnly: $roleCaps.apps === 'compose'
|
||||
})
|
||||
)
|
||||
let itemUrl = $derived(
|
||||
`${window.location.origin}/${kind === 'flow' ? 'flows' : 'scripts'}/get/${path}?workspace=${$operatingWorkspace}`
|
||||
)
|
||||
// What a run can reach. It changes only with a deploy, so Share explains it and says where.
|
||||
let permissions = $derived.by(() => {
|
||||
// A viewer-mode app runs its runnables as whoever opens it, whatever its run-as user.
|
||||
const identity = isApp
|
||||
? app && {
|
||||
runAs: app.policy.execution_mode === 'viewer' ? undefined : runAs,
|
||||
canEdit: canWriteApp
|
||||
}
|
||||
: runnableIdentity
|
||||
if (!identity) return undefined
|
||||
const who = identity.runAs
|
||||
return {
|
||||
summary: who
|
||||
? `Uses the access of ${who}`
|
||||
: `Uses the access of whoever ${isApp ? 'opens' : 'runs'} it`,
|
||||
body: !who
|
||||
? isApp
|
||||
? 'Its runnables can use only the resources and variables that the person who opens the app can access.'
|
||||
: 'A run can use only the resources and variables that the person who starts it can access.'
|
||||
: isApp
|
||||
? `Its runnables can use the resources and variables ${who} can access, for everyone who can open the app.`
|
||||
: `Every run can use the resources and variables ${who} can access, whoever starts it. Who started a run stays recorded, and the code can read their email from WM_END_USER_EMAIL.`,
|
||||
canEdit: identity.canEdit
|
||||
}
|
||||
})
|
||||
|
||||
/** `stagedPath` is the path the editor's draft deploys the item to. */
|
||||
export function openDialog(
|
||||
kind_l: ShareKind,
|
||||
path_l: string,
|
||||
opts: { source: ShareOpenSource; fromEditor?: boolean; stagedPath?: string }
|
||||
) {
|
||||
settleDeploy(false)
|
||||
logShareOpen(opts.source)
|
||||
kind = kind_l
|
||||
path = path_l
|
||||
fromEditor = opts.fromEditor ?? false
|
||||
moveTo =
|
||||
opts.stagedPath && movesToAnotherOwner(path_l, opts.stagedPath) ? opts.stagedPath : undefined
|
||||
moveLoss = undefined
|
||||
deployLabel = undefined
|
||||
app = undefined
|
||||
runnableIdentity = undefined
|
||||
open = true
|
||||
if (kind === 'app' || kind === 'raw_app') {
|
||||
void loadApp()
|
||||
} else {
|
||||
// Without it the section stays hidden: it only explains.
|
||||
void loadRunnableIdentity().catch(() => {})
|
||||
}
|
||||
if (moveTo) void loadMoveLoss()
|
||||
}
|
||||
|
||||
/** Opens the dialog before a deploy that moves the item to another owner, for the deployer to
|
||||
* see who loses access and give it back first. Resolves whether to go on with the deploy. */
|
||||
export function confirmMove(
|
||||
kind_l: ShareKind,
|
||||
path_l: string,
|
||||
stagedPath: string,
|
||||
label: string
|
||||
): Promise<boolean> {
|
||||
openDialog(kind_l, path_l, { source: 'deploy', fromEditor: true, stagedPath })
|
||||
deployLabel = label
|
||||
return new Promise((resolve) => (answerDeploy = resolve))
|
||||
}
|
||||
|
||||
function settleDeploy(deploy: boolean) {
|
||||
const answer = answerDeploy
|
||||
answerDeploy = undefined
|
||||
answer?.(deploy)
|
||||
}
|
||||
|
||||
function close(deploy = false) {
|
||||
settleDeploy(deploy)
|
||||
open = false
|
||||
}
|
||||
|
||||
async function loadApp() {
|
||||
const asked = path
|
||||
const row = await AppService.getAppLiteByPath({ workspace: $operatingWorkspace!, path })
|
||||
if (path === asked) app = row
|
||||
}
|
||||
|
||||
async function loadRunnableIdentity() {
|
||||
const asked = path
|
||||
const workspace = $operatingWorkspace!
|
||||
const row =
|
||||
kind === 'flow'
|
||||
? await FlowService.getFlowByPath({ workspace, path })
|
||||
: await ScriptService.getScriptByPath({ workspace, path })
|
||||
if (path !== asked) return
|
||||
runnableIdentity = {
|
||||
runAs: row.on_behalf_of ?? row.on_behalf_of_email ?? undefined,
|
||||
canEdit: editRights.canEditItem(kind, path, row.extra_perms)
|
||||
}
|
||||
}
|
||||
|
||||
async function readFolder(p: string): Promise<Folder | undefined> {
|
||||
const folder = folderOfPath(p)
|
||||
if (folder === undefined) return undefined
|
||||
// A user outside the folder cannot read it; the loss is then not listed.
|
||||
return FolderService.getFolder({ workspace: $operatingWorkspace!, name: folder }).catch(
|
||||
() => undefined
|
||||
)
|
||||
}
|
||||
|
||||
async function loadMoveLoss() {
|
||||
const read = ++moveLossReads
|
||||
const from = path
|
||||
const to = moveTo
|
||||
if (!to) return
|
||||
try {
|
||||
const [fromFolder, toFolder, members] = await Promise.all([
|
||||
readFolder(from),
|
||||
readFolder(to),
|
||||
GranularAclService.getGranularAcls({
|
||||
workspace: $operatingWorkspace!,
|
||||
path: from,
|
||||
kind: kind as any
|
||||
})
|
||||
])
|
||||
const after = inheritedAccess(to, toFolder)
|
||||
const groups = new Set(
|
||||
[...(after?.rows ?? []).map((r) => r.name), ...Object.keys(members)].filter((n) =>
|
||||
n.startsWith('g/')
|
||||
)
|
||||
)
|
||||
const groupMembers: Record<string, string[]> = Object.fromEntries(
|
||||
await Promise.all(
|
||||
[...groups].map(
|
||||
async (g): Promise<[string, string[]]> => [
|
||||
g,
|
||||
await GroupService.getGroup({ workspace: $operatingWorkspace!, name: g.slice(2) })
|
||||
.then((group) => group.members ?? [])
|
||||
.catch(() => [])
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
if (read !== moveLossReads) return
|
||||
moveLoss = accessLostByMove(inheritedAccess(from, fromFolder), after, members, groupMembers)
|
||||
} catch {
|
||||
if (read === moveLossReads) moveLoss = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function names(list: string[]): string {
|
||||
if (list.length <= 3) return list.join(', ').replace(/, ([^,]*)$/, ' and $1')
|
||||
return `${list.slice(0, 3).join(', ')} and ${list.length - 3} more`
|
||||
}
|
||||
|
||||
let moveWarning = $derived.by(() => {
|
||||
if (!moveTo) return undefined
|
||||
const from = ownerLabel(path)
|
||||
const gains = folderOfPath(moveTo) !== undefined || moveTo.startsWith('g/')
|
||||
const parts: string[] = []
|
||||
if (!moveLoss) {
|
||||
parts.push(`Members of ${from} lose the access they have through it.`)
|
||||
} else if (moveLoss.lost.length || moveLoss.demoted.length) {
|
||||
const lost = moveLoss.lost.length
|
||||
? `${names(moveLoss.lost)} ${moveLoss.lost.length === 1 ? 'loses' : 'lose'} the access ${moveLoss.lost.length === 1 ? 'it has' : 'they have'} through ${from}`
|
||||
: undefined
|
||||
const demoted = moveLoss.demoted.length
|
||||
? `${names(moveLoss.demoted)} can then only view it`
|
||||
: undefined
|
||||
parts.push(`${[lost, demoted].filter(Boolean).join(', and ')}. Add them here to keep it.`)
|
||||
} else {
|
||||
parts.push(`Everyone with access through ${from} keeps it.`)
|
||||
}
|
||||
if (gains) parts.push(`Members of ${ownerLabel(moveTo)} gain access.`)
|
||||
return {
|
||||
title: `Deploying moves this ${noun} from ${from} to ${ownerLabel(moveTo)}`,
|
||||
body: parts.join(' ')
|
||||
}
|
||||
})
|
||||
|
||||
const ACCESS_MODE_LABELS: Record<AppAccessMode, string> = {
|
||||
publisher: 'Members',
|
||||
guest: 'Guests',
|
||||
anonymous: 'Public'
|
||||
}
|
||||
|
||||
async function changeApp(
|
||||
change: { execution_mode: AppAccessMode } | { custom_path: string | null }
|
||||
) {
|
||||
appBusy = true
|
||||
try {
|
||||
app = await updateDeployedAppAccess($operatingWorkspace!, path, change)
|
||||
onAppChanged?.(app)
|
||||
onChange?.()
|
||||
sendUserToast(
|
||||
'execution_mode' in change
|
||||
? `Who can open ${name} changed to ${ACCESS_MODE_LABELS[change.execution_mode]}`
|
||||
: change.custom_path
|
||||
? `Custom URL of ${name} set to ${change.custom_path}`
|
||||
: `Custom URL of ${name} removed`
|
||||
)
|
||||
} catch (err) {
|
||||
sendUserToast(`Could not change the app's access: ${err?.body ?? err}`, true)
|
||||
// Re-read so the controls show what is deployed, not the choice that was refused.
|
||||
await loadApp()
|
||||
} finally {
|
||||
appBusy = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Closed by Escape, the backdrop, the close button or Cancel: a deploy waiting on it does not go
|
||||
on. -->
|
||||
<Modal
|
||||
bind:open={() => open, (v) => (v ? (open = true) : close())}
|
||||
title="Share {name}"
|
||||
kind="X"
|
||||
enterConfirms={false}
|
||||
fitHeight
|
||||
class="sm:max-w-xl"
|
||||
>
|
||||
<!-- A long access list gives up height when the sections below grow, and keeps the dialog
|
||||
inside the viewport. -->
|
||||
<div class="flex flex-col gap-6 h-full">
|
||||
{#if moveWarning}
|
||||
<Alert type="warning" size="xs" title={moveWarning.title}>
|
||||
{moveWarning.body} Changes here apply to the deployed {noun} right away.
|
||||
</Alert>
|
||||
{:else if fromEditor}
|
||||
<!-- From an editor, where every other change waits for Deploy, say which version this is. -->
|
||||
<Alert type="info" size="xs" title="Changes here apply to the deployed {noun} right away" />
|
||||
{/if}
|
||||
|
||||
{#key path}
|
||||
<ItemAccessList
|
||||
{kind}
|
||||
{path}
|
||||
onChange={() => {
|
||||
onChange?.()
|
||||
if (moveTo) void loadMoveLoss()
|
||||
}}
|
||||
/>
|
||||
{/key}
|
||||
|
||||
{#if isApp}
|
||||
<section class="flex flex-col gap-2">
|
||||
<h3 class="text-sm font-semibold text-emphasis">Who can open the app</h3>
|
||||
{#if app}
|
||||
{#if !canWriteApp}
|
||||
<span class="text-xs text-secondary">
|
||||
Only people who can edit this app can change who can open it.
|
||||
</span>
|
||||
{:else if modeRefusal}
|
||||
<span class="text-xs text-secondary">
|
||||
{#if modeRefusal === 'unsandboxed'}
|
||||
This app is not sandboxed yet. Deploy it so it is sandboxed, then change who can
|
||||
open it.
|
||||
{:else if modeRefusal === 'builder_run_as'}
|
||||
This app runs on behalf of {runAs}. Pick yourself in the editor's Settings ›
|
||||
Permissions and deploy it, then change who can open it. An admin can change it
|
||||
without taking the app over.
|
||||
{:else}
|
||||
This app runs on behalf of {runAs}. Deploy it so it runs on behalf of you, then
|
||||
change who can open it. An admin or a member of <code>wm_deployers</code> can change
|
||||
it without taking the app over.
|
||||
{/if}
|
||||
</span>
|
||||
{/if}
|
||||
{#key path}
|
||||
<AppAccessSection
|
||||
workspace={$operatingWorkspace!}
|
||||
appPath={path}
|
||||
rawApp={kind === 'raw_app' || app.raw_app}
|
||||
mode={accessModeOf(app.policy)}
|
||||
onModeChange={(m) => changeApp({ execution_mode: m })}
|
||||
deployed={{
|
||||
customPath: app.custom_path ?? undefined,
|
||||
onCustomPathChange: (p) => changeApp({ custom_path: p })
|
||||
}}
|
||||
disabled={appBusy || !canWriteApp || !!modeRefusal}
|
||||
/>
|
||||
{/key}
|
||||
{:else}
|
||||
<span class="text-xs text-secondary">Loading…</span>
|
||||
{/if}
|
||||
</section>
|
||||
{:else}
|
||||
<section class="flex flex-col gap-2">
|
||||
<h3 class="text-sm font-semibold text-emphasis">Who can open the {noun}</h3>
|
||||
<span class="text-xs text-secondary">
|
||||
The people with access above, signed in to Windmill.
|
||||
</span>
|
||||
<Label label="Link">
|
||||
<ClipboardPanel content={itemUrl} size="md" />
|
||||
</Label>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if permissions}
|
||||
<Section label="Permissions" collapsable>
|
||||
{#snippet badge()}
|
||||
<span class="text-xs text-secondary">{permissions.summary}</span>
|
||||
{/snippet}
|
||||
<div class="flex flex-col gap-1 text-xs text-secondary">
|
||||
<span class="font-medium text-emphasis">{permissions.summary}</span>
|
||||
<span>{permissions.body}</span>
|
||||
{#if permissions.canEdit}
|
||||
<span>
|
||||
{fromEditor
|
||||
? 'To change it, edit Settings › Permissions and deploy.'
|
||||
: `To change it, edit Settings › Permissions in the ${noun}'s editor and deploy.`}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
</Section>
|
||||
{/if}
|
||||
|
||||
<div class="flex flex-row items-center gap-2">
|
||||
<span class="grow text-xs text-secondary">
|
||||
{fromEditor ? '' : 'Changes apply right away.'}
|
||||
</span>
|
||||
{#if deployLabel}
|
||||
<Button variant="default" unifiedSize="md" onclick={() => close()}>Cancel</Button>
|
||||
<Button variant="accent" unifiedSize="md" onclick={() => close(true)}>
|
||||
{deployLabel}
|
||||
</Button>
|
||||
{:else}
|
||||
<Button variant="accent" unifiedSize="md" onclick={() => close()}>Done</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('$lib/gen', () => ({
|
||||
AppService: {
|
||||
updateApp: vi.fn(async () => ({})),
|
||||
getAppLiteByPath: vi.fn(async () => ({ policy: { execution_mode: 'anonymous' } }))
|
||||
}
|
||||
}))
|
||||
|
||||
import { AppService } from '$lib/gen'
|
||||
import { modeChangeRefusal, updateDeployedAppAccess } from './appAccess'
|
||||
|
||||
describe('updateDeployedAppAccess', () => {
|
||||
// A policy is written whole, so sending one would put back whatever a deploy wrote since it
|
||||
// was read. The mode alone is applied by the server under the deploy's row lock.
|
||||
it('sends the mode alone, never a policy', async () => {
|
||||
await updateDeployedAppAccess('w', 'f/ops/app', { execution_mode: 'anonymous' })
|
||||
expect(vi.mocked(AppService.updateApp).mock.calls[0][0].requestBody).toEqual({
|
||||
execution_mode: 'anonymous',
|
||||
skip_draft_deletion: true
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// The server's mode-only checks: a mismatch shows enabled buttons that answer with a 403.
|
||||
describe('modeChangeRefusal', () => {
|
||||
const bob = { on_behalf_of: 'u/bob', sandbox: true }
|
||||
const mine = { on_behalf_of: 'u/me', sandbox: true }
|
||||
const as = (o: { canPreserveRunAs?: boolean; composeOnly?: boolean }) => ({
|
||||
username: 'me',
|
||||
canPreserveRunAs: false,
|
||||
composeOnly: false,
|
||||
...o
|
||||
})
|
||||
|
||||
it('refuses an app run as someone else to a caller who may not keep that user', () => {
|
||||
expect(modeChangeRefusal(bob, as({}))).toBe('run_as')
|
||||
expect(modeChangeRefusal(bob, as({ canPreserveRunAs: true }))).toBeUndefined()
|
||||
expect(modeChangeRefusal(mine, as({}))).toBeUndefined()
|
||||
})
|
||||
|
||||
it('refuses a builder on an app run as someone else, or not sandboxed', () => {
|
||||
expect(modeChangeRefusal(bob, as({ composeOnly: true }))).toBe('run_as')
|
||||
// Their deploy keeps u/bob, so deploying alone does not lift this one.
|
||||
expect(modeChangeRefusal(bob, as({ composeOnly: true, canPreserveRunAs: true }))).toBe(
|
||||
'builder_run_as'
|
||||
)
|
||||
expect(modeChangeRefusal({ ...mine, sandbox: undefined }, as({ composeOnly: true }))).toBe(
|
||||
'unsandboxed'
|
||||
)
|
||||
expect(modeChangeRefusal(mine, as({ composeOnly: true }))).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,73 @@
|
||||
import { AppService, type AppWithLastVersion, type Policy } from '$lib/gen'
|
||||
|
||||
export type AppAccessMode = 'publisher' | 'guest' | 'anonymous'
|
||||
|
||||
export const CUSTOM_PATH_RE = /^[\w-]+(\/[\w-]+)*$/
|
||||
|
||||
/** The access a policy grants, on the three rungs the Share dialog offers. `viewer` runs the
|
||||
* app as its viewer, which a guest cannot be, so it shows as members-only. */
|
||||
export function accessModeOf(policy: Policy | undefined): AppAccessMode {
|
||||
const mode = policy?.execution_mode
|
||||
return mode === 'anonymous' ? 'anonymous' : mode === 'guest' ? 'guest' : 'publisher'
|
||||
}
|
||||
|
||||
/**
|
||||
* Why the server refuses to change who can open a deployed app, or undefined. Mirrors the
|
||||
* mode-only checks of `update_app_internal`: an app that runs as someone else is refused to a
|
||||
* caller who may not keep that run-as user and to a compose-only builder, who is also refused on
|
||||
* an app that is not sandboxed. A deploy by the caller lifts either refusal, except that a builder
|
||||
* who may keep the run-as user (`builder_run_as`) keeps it unless they pick themselves first.
|
||||
*/
|
||||
export function modeChangeRefusal(
|
||||
policy: Pick<Policy, 'on_behalf_of' | 'sandbox'>,
|
||||
opts: { username: string | undefined; canPreserveRunAs: boolean; composeOnly: boolean }
|
||||
): 'run_as' | 'builder_run_as' | 'unsandboxed' | undefined {
|
||||
const runsAsSomeoneElse = !!policy.on_behalf_of && policy.on_behalf_of !== `u/${opts.username}`
|
||||
if (runsAsSomeoneElse && opts.composeOnly && opts.canPreserveRunAs) return 'builder_run_as'
|
||||
if (runsAsSomeoneElse && (opts.composeOnly || !opts.canPreserveRunAs)) return 'run_as'
|
||||
if (opts.composeOnly && policy.sandbox !== true) return 'unsandboxed'
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** Why a custom path cannot be used, or undefined. `own` is the app's current custom path. */
|
||||
export async function customPathError(
|
||||
workspace: string,
|
||||
customPath: string,
|
||||
own: string | undefined
|
||||
): Promise<string | undefined> {
|
||||
if (!CUSTOM_PATH_RE.test(customPath)) return 'Use letters, digits, - and _, separated by /'
|
||||
if (customPath !== own && (await AppService.customPathExists({ workspace, customPath }))) {
|
||||
return 'Path already taken'
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Change who can open a deployed app, or its custom URL, without deploying it.
|
||||
*
|
||||
* The mode is sent alone, never in a policy: the server applies it to the deployed policy under
|
||||
* the lock a deploy takes, so neither overwrites the other, and keeps the run-as user. No `value`
|
||||
* is sent, so no new version is written, and `skip_draft_deletion` keeps every draft. Resolves to
|
||||
* the row as it is after the write.
|
||||
*/
|
||||
export async function updateDeployedAppAccess(
|
||||
workspace: string,
|
||||
path: string,
|
||||
change: { execution_mode: AppAccessMode } | { custom_path: string | null }
|
||||
): Promise<AppWithLastVersion> {
|
||||
if ('execution_mode' in change) {
|
||||
await AppService.updateApp({
|
||||
workspace,
|
||||
path,
|
||||
requestBody: { execution_mode: change.execution_mode, skip_draft_deletion: true }
|
||||
})
|
||||
} else {
|
||||
// The backend clears the custom path on an empty string and keeps it when absent.
|
||||
await AppService.updateApp({
|
||||
workspace,
|
||||
path,
|
||||
requestBody: { custom_path: change.custom_path ?? '', skip_draft_deletion: true }
|
||||
})
|
||||
}
|
||||
return AppService.getAppLiteByPath({ workspace, path })
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { Folder } from '$lib/gen'
|
||||
import { accessLostByMove, inheritedAccess, movesToAnotherOwner } from './inheritedAccess'
|
||||
|
||||
describe('inheritedAccess', () => {
|
||||
it('lists folder owners, then members that are not owners, each by name', () => {
|
||||
const folder = {
|
||||
name: 'finance',
|
||||
owners: ['g/finance'],
|
||||
extra_perms: { 'u/zoe': false, 'g/finance': true, 'u/marc': true }
|
||||
} as unknown as Folder
|
||||
expect(inheritedAccess('f/finance/sync', folder)).toEqual({
|
||||
source: 'Folder finance',
|
||||
rows: [
|
||||
{ name: 'g/finance', write: true },
|
||||
{ name: 'u/marc', write: true },
|
||||
{ name: 'u/zoe', write: false }
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
it('names the folder without listing it when it could not be read', () => {
|
||||
const other = { name: 'ops', owners: ['u/x'], extra_perms: {} } as unknown as Folder
|
||||
expect(inheritedAccess('f/finance/sync', other)).toEqual({
|
||||
source: 'Folder finance',
|
||||
rows: [],
|
||||
note: 'Members of folder finance'
|
||||
})
|
||||
})
|
||||
|
||||
it('names the owning user or group', () => {
|
||||
expect(inheritedAccess('u/alice/sync', undefined)).toEqual({
|
||||
source: 'Owner',
|
||||
rows: [{ name: 'u/alice', write: true }]
|
||||
})
|
||||
expect(inheritedAccess('g/ops/sync', undefined)?.source).toBe('Owning group')
|
||||
})
|
||||
})
|
||||
|
||||
describe('accessLostByMove', () => {
|
||||
const folder = (name: string, extra_perms: Record<string, boolean>) =>
|
||||
({ name, owners: [], extra_perms }) as unknown as Folder
|
||||
|
||||
it('takes access from whom neither the new folder nor the item itself covers', () => {
|
||||
const from = inheritedAccess(
|
||||
'f/sales/sync',
|
||||
folder('sales', { 'g/sales': true, 'u/bob': false, 'u/dan': true, 'u/eve': true })
|
||||
)
|
||||
const to = inheritedAccess('f/ops/sync', folder('ops', { 'u/dan': false, 'u/eve': true }))
|
||||
expect(accessLostByMove(from, to, { 'u/bob': false })).toEqual({
|
||||
lost: ['g/sales'],
|
||||
demoted: ['u/dan']
|
||||
})
|
||||
expect(movesToAnotherOwner('f/sales/sync', 'f/sales/sync_v2')).toBe(false)
|
||||
expect(movesToAnotherOwner('f/sales/sync', 'u/bob/sync')).toBe(true)
|
||||
})
|
||||
|
||||
it('keeps a user whom a group reaching the item after the move covers', () => {
|
||||
const from = inheritedAccess('f/sales/sync', folder('sales', { 'u/bob': true, 'u/eve': true }))
|
||||
const to = inheritedAccess('f/ops/sync', folder('ops', { 'g/ops': false }))
|
||||
expect(accessLostByMove(from, to, {}, { 'g/ops': ['bob'] })).toEqual({
|
||||
lost: ['u/eve'],
|
||||
demoted: ['u/bob']
|
||||
})
|
||||
})
|
||||
|
||||
it('says nothing when a folder could not be read', () => {
|
||||
const from = inheritedAccess('f/sales/sync', undefined)
|
||||
const to = inheritedAccess('u/bob/sync', undefined)
|
||||
expect(accessLostByMove(from, to, {})).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,105 @@
|
||||
import type { Folder } from '$lib/gen'
|
||||
|
||||
export type AccessRow = {
|
||||
/** `u/name` or `g/name`. */
|
||||
name: string
|
||||
write: boolean
|
||||
}
|
||||
|
||||
/** Who reaches an item through its path, and where that access comes from. */
|
||||
export type InheritedAccess = {
|
||||
/** Shown in the access list's "Access from" column. */
|
||||
source: string
|
||||
rows: AccessRow[]
|
||||
/** Shown in place of the rows when they cannot be listed. */
|
||||
note?: string
|
||||
}
|
||||
|
||||
export function byName(a: AccessRow, b: AccessRow): number {
|
||||
return a.name.localeCompare(b.name)
|
||||
}
|
||||
|
||||
/** The folder a path lives in, or undefined for a `u/` or `g/` path. */
|
||||
export function folderOfPath(path: string): string | undefined {
|
||||
const parts = path.split('/')
|
||||
return parts[0] === 'f' && parts.length >= 2 ? parts[1] : undefined
|
||||
}
|
||||
|
||||
/** The owner a path names, such as `u/alice` or `f/team`. */
|
||||
export function ownerOfPath(path: string): string {
|
||||
return path.split('/').slice(0, 2).join('/')
|
||||
}
|
||||
|
||||
/** Whether moving an item between these paths changes who reaches it through its path. */
|
||||
export function movesToAnotherOwner(from: string, to: string): boolean {
|
||||
return !!from && !!to && ownerOfPath(from) !== ownerOfPath(to)
|
||||
}
|
||||
|
||||
/** An owner as a sentence names it: "folder team", or the `u/` or `g/` name. */
|
||||
export function ownerLabel(path: string): string {
|
||||
const folder = folderOfPath(path)
|
||||
return folder !== undefined ? `folder ${folder}` : ownerOfPath(path)
|
||||
}
|
||||
|
||||
/** What moving an item to another owner takes away: the users and groups that reach it through
|
||||
* the old owner and through neither the new one nor the item's own members, and the writers left
|
||||
* with a viewer's role. `groupMembers` lists the usernames in each group that reaches the item
|
||||
* after the move, so that a user one of them covers keeps access; a group missing from it counts
|
||||
* as empty, which can only overstate the loss. Undefined when either owner's members could not be
|
||||
* read. */
|
||||
export function accessLostByMove(
|
||||
from: InheritedAccess | undefined,
|
||||
to: InheritedAccess | undefined,
|
||||
members: Record<string, boolean>,
|
||||
groupMembers: Record<string, string[]> = {}
|
||||
): { lost: string[]; demoted: string[] } | undefined {
|
||||
if (!from || !to || from.note !== undefined || to.note !== undefined) return undefined
|
||||
const after = new Map<string, boolean>(to.rows.map((r) => [r.name, r.write]))
|
||||
for (const [name, write] of Object.entries(members)) after.set(name, after.get(name) || write)
|
||||
for (const [name, write] of [...after]) {
|
||||
for (const username of groupMembers[name] ?? []) {
|
||||
after.set(`u/${username}`, after.get(`u/${username}`) || write)
|
||||
}
|
||||
}
|
||||
const lost: string[] = []
|
||||
const demoted: string[] = []
|
||||
for (const row of from.rows) {
|
||||
const write = after.get(row.name)
|
||||
if (write === undefined) lost.push(row.name)
|
||||
else if (row.write && !write) demoted.push(row.name)
|
||||
}
|
||||
return { lost, demoted }
|
||||
}
|
||||
|
||||
/** Who reaches an item through its path rather than through its own extra_perms: the folder's
|
||||
* owners and members for `f/`, the owning user or group for `u/` and `g/`. Workspace admins
|
||||
* reach everything and are not listed. `folder` is the item's folder, undefined when it could
|
||||
* not be read. Undefined for a name that is not a path, such as a volume's. */
|
||||
export function inheritedAccess(
|
||||
path: string,
|
||||
folder: Folder | undefined
|
||||
): InheritedAccess | undefined {
|
||||
const parts = path.split('/')
|
||||
const folderName = folderOfPath(path)
|
||||
if (folderName !== undefined) {
|
||||
const source = `Folder ${folderName}`
|
||||
if (folder?.name !== folderName) {
|
||||
return { source, rows: [], note: `Members of folder ${folderName}` }
|
||||
}
|
||||
// Sorted by name: the API returns members in jsonb key order, shortest name first, which
|
||||
// reads as no order at all in a folder shared with many people.
|
||||
const owners = folder.owners.map((owner) => ({ name: owner, write: true })).sort(byName)
|
||||
const members = Object.entries(folder.extra_perms ?? {})
|
||||
.filter(([member]) => !folder.owners.includes(member))
|
||||
.map(([member, write]) => ({ name: member, write: !!write }))
|
||||
.sort(byName)
|
||||
return { source, rows: [...owners, ...members] }
|
||||
}
|
||||
if ((parts[0] === 'u' || parts[0] === 'g') && parts.length >= 2) {
|
||||
return {
|
||||
source: parts[0] === 'u' ? 'Owner' : 'Owning group',
|
||||
rows: [{ name: `${parts[0]}/${parts[1]}`, write: true }]
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { deployAsksOnBehalfOf, deployedPermissionedAs } from './onBehalfOf'
|
||||
import {
|
||||
deployAsksOnBehalfOf,
|
||||
deployOnBehalfOfQuestion,
|
||||
deployedPermissionedAs
|
||||
} from './onBehalfOf'
|
||||
|
||||
// The deploy dialog names who the backend will leave the item running on behalf of, and asks only
|
||||
// when that differs from the deployed version.
|
||||
@@ -49,4 +53,42 @@ describe('onBehalfOf', () => {
|
||||
// The backend replaces the user with a deployer who may not preserve it.
|
||||
expect(deployAsksOnBehalfOf('flow', { user: member, ...bot, ...deployedAsBot })).toBe(true)
|
||||
})
|
||||
|
||||
it('asks to run on behalf of someone or to stop, and says when the user is the deployed one', () => {
|
||||
const held = {
|
||||
email: undefined,
|
||||
permissionedAs: undefined,
|
||||
savedEmail: undefined,
|
||||
savedPermissionedAs: undefined,
|
||||
isNew: true
|
||||
}
|
||||
expect(deployOnBehalfOfQuestion('app', admin, held)).toMatchObject({
|
||||
title: 'Run this app on behalf of u/admin (you)?',
|
||||
folderDefaultNotMe: false
|
||||
})
|
||||
expect(
|
||||
deployOnBehalfOfQuestion('app', admin, { ...held, folderDefault: 'u/folder' })
|
||||
).toMatchObject({ title: 'Run this app on behalf of u/folder?', folderDefaultNotMe: true })
|
||||
expect(
|
||||
deployOnBehalfOfQuestion('flow', admin, {
|
||||
...held,
|
||||
savedPermissionedAs: 'u/bot',
|
||||
isNew: false
|
||||
})
|
||||
).toMatchObject({ stops: true, title: 'Stop running this flow on behalf of u/bot?' })
|
||||
expect(
|
||||
deployOnBehalfOfQuestion('flow', admin, {
|
||||
...held,
|
||||
email: 'bot@x.dev',
|
||||
permissionedAs: 'u/bot',
|
||||
savedPermissionedAs: 'u/bot',
|
||||
isNew: false
|
||||
})
|
||||
).toMatchObject({ stops: false, runsAs: 'u/bot', unchanged: true })
|
||||
expect(deployOnBehalfOfQuestion('flow', admin, held)).toMatchObject({
|
||||
required: false,
|
||||
on: false,
|
||||
title: 'Deploy this flow?'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -58,6 +58,58 @@ export function deployAsksOnBehalfOf(
|
||||
)
|
||||
}
|
||||
|
||||
/** What a deploy asks about the user an item runs on behalf of: the question, whether the item
|
||||
* must run on behalf of someone, whether it does, whether the deploy stops a flow or script
|
||||
* running on behalf of the deployed user, and who it runs as otherwise. `email` and
|
||||
* `permissionedAs` are the user the item holds, `saved*` the deployed one. */
|
||||
export function deployOnBehalfOfQuestion(
|
||||
kind: 'flow' | 'script' | 'app',
|
||||
user: DeployingUser,
|
||||
held: {
|
||||
email: string | undefined
|
||||
permissionedAs: string | undefined
|
||||
savedEmail: string | undefined
|
||||
savedPermissionedAs: string | undefined
|
||||
isNew: boolean
|
||||
folderDefault?: string
|
||||
}
|
||||
): {
|
||||
title: string
|
||||
required: boolean
|
||||
on: boolean
|
||||
stops: boolean
|
||||
runsAs: string | undefined
|
||||
savedUser: string | undefined
|
||||
/** The deploy leaves the deployed user as it is. */
|
||||
unchanged: boolean
|
||||
/** The item takes its folder's default user, who is not the deployer. */
|
||||
folderDefaultNotMe: boolean
|
||||
} {
|
||||
const me = user?.username ? `u/${user.username}` : undefined
|
||||
const savedUser = held.savedPermissionedAs ?? held.savedEmail
|
||||
// The backend gives a new item in a folder with a default user that user unless the deploy
|
||||
// names one, so only a flow or script outside that case can deploy with the setting off.
|
||||
const required = kind === 'app' || !!held.folderDefault
|
||||
const on = required || !!held.email
|
||||
const stops = !on && !!savedUser
|
||||
const runsAs = deployedPermissionedAs(user, held.permissionedAs, held.folderDefault)
|
||||
const who = !runsAs ? 'you' : runsAs === me ? `${runsAs} (you)` : runsAs
|
||||
return {
|
||||
title: on
|
||||
? `Run this ${kind} on behalf of ${who}?`
|
||||
: stops
|
||||
? `Stop running this ${kind} on behalf of ${savedUser}?`
|
||||
: `Deploy this ${kind}?`,
|
||||
required,
|
||||
on,
|
||||
stops,
|
||||
runsAs,
|
||||
savedUser,
|
||||
unchanged: !held.isNew && !!held.savedPermissionedAs && runsAs === held.savedPermissionedAs,
|
||||
folderDefaultNotMe: !!held.folderDefault && runsAs === held.folderDefault && runsAs !== me
|
||||
}
|
||||
}
|
||||
|
||||
/** What keeps lending the publisher's access to an app's viewers safe. */
|
||||
export function appOnBehalfOfTooltip(rawApp: boolean): string {
|
||||
return `To keep this safe, the app can call only the runnables it was deployed with, and viewers can't override their static inputs.${rawApp ? " Inline runnables can instead be set to read data tables and object storage with the viewer's own access." : ''}`
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { logFeatureUsage } from '$lib/utils/featureUsage'
|
||||
|
||||
/** Where the Share dialog was opened from. `deploy` is a deploy that moves the item to another
|
||||
* owner, which opens it to confirm; `home` is a card in Home's favorites and recent items. */
|
||||
export type ShareOpenSource = 'editor_header' | 'list' | 'detail' | 'deploy' | 'home'
|
||||
|
||||
export function logShareOpen(source: ShareOpenSource) {
|
||||
logFeatureUsage('sharing', 'open', { key: source })
|
||||
}
|
||||
|
||||
/** How a first-deploy dialog ended. */
|
||||
export function logFirstDeploy(outcome: 'deployed' | 'cancelled') {
|
||||
logFeatureUsage('sharing', 'first_deploy', { key: outcome })
|
||||
}
|
||||
@@ -959,4 +959,11 @@ const adjectives = ["abundant",
|
||||
"youthful",
|
||||
"zippy"]
|
||||
|
||||
export function random_adj() { return adjectives[Math.floor(Math.random() * adjectives.length)] }
|
||||
export function random_adj() { return adjectives[Math.floor(Math.random() * adjectives.length)] }
|
||||
/** Whether a path's last segment is a placeholder name, `<adjective>_<kind>`, rather than one
|
||||
* someone chose. */
|
||||
export function isPlaceholderName(path: string): boolean {
|
||||
const name = path.split('/').pop() ?? ''
|
||||
const m = /^([a-z]+)_(flow|script|app)$/.exec(name)
|
||||
return !!m && adjectives.includes(m[1])
|
||||
}
|
||||
|
||||
@@ -34,8 +34,16 @@
|
||||
Redo,
|
||||
Settings,
|
||||
Undo,
|
||||
UserPlus,
|
||||
WandSparkles
|
||||
} from 'lucide-svelte'
|
||||
import ShareDialog from '$lib/components/itemSettings/ShareDialog.svelte'
|
||||
import FirstDeployDialog, {
|
||||
applyFirstDeployMembers
|
||||
} from '$lib/components/itemSettings/FirstDeployDialog.svelte'
|
||||
import ShareButton from '$lib/components/itemSettings/ShareButton.svelte'
|
||||
import { accessModeOf } from '$lib/components/itemSettings/appAccess'
|
||||
import { movesToAnotherOwner } from '$lib/components/itemSettings/inheritedAccess'
|
||||
import { onDestroy, untrack, type Snippet } from 'svelte'
|
||||
import { orderedJsonStringify, type Value, replaceFalseWithUndefined } from '../../utils'
|
||||
import { random_adj } from '$lib/components/random_positive_adjetive'
|
||||
@@ -61,7 +69,7 @@
|
||||
import DeployButton from '$lib/components/DeployButton.svelte'
|
||||
import type { Runnable } from './RawAppInlineScriptRunnable.svelte'
|
||||
import { updateRawAppPolicy } from './rawAppPolicy'
|
||||
import { policyForUpdate, publishAccessMode } from '$lib/components/apps/editor/publishAccessMode'
|
||||
import { withoutSharedPolicySettings } from '../apps/editor/appDraftSettings'
|
||||
import { saveRawAppFork } from './forkRawApp.svelte'
|
||||
import { aiChatManager } from '../copilot/chat/AIChatManager.svelte'
|
||||
import { getContext } from 'svelte'
|
||||
@@ -354,7 +362,6 @@
|
||||
|
||||
let settingsOpen = $state(false)
|
||||
let settingsDrawer: AppSettingsDrawer | undefined = $state()
|
||||
let deployRefused = $state(false)
|
||||
let historyBrowserDrawerOpen = $state(false)
|
||||
let recordDrawer = $state<Drawer | undefined>(undefined)
|
||||
let deploymentMsg: string | undefined = $state(undefined)
|
||||
@@ -402,25 +409,17 @@
|
||||
return updateRawAppPolicy(runnables, policy)
|
||||
}
|
||||
|
||||
async function setAccessMode(mode: NonNullable<Policy['execution_mode']>) {
|
||||
await publishAccessMode(opWorkspace!, appPath, mode)
|
||||
if (savedApp) savedApp.policy = { ...savedApp.policy, execution_mode: mode }
|
||||
sendUserToast(
|
||||
mode == 'anonymous'
|
||||
? 'App require no login to be accessed'
|
||||
: 'App require login and read-access'
|
||||
)
|
||||
}
|
||||
|
||||
async function createApp(path: string) {
|
||||
/** Resolves to whether the app was created. */
|
||||
async function createApp(path: string): Promise<boolean> {
|
||||
if (!app) {
|
||||
sendUserToast(`App hasn't been loaded yet`, true)
|
||||
return
|
||||
return false
|
||||
}
|
||||
if (!policy.execution_mode) {
|
||||
policy.execution_mode = 'publisher'
|
||||
}
|
||||
setDeployedOnBehalfOf(policy, actingUser, folderDefault.value)
|
||||
// Read for the path being created: the first-deploy dialog may have just chosen it.
|
||||
setDeployedOnBehalfOf(policy, actingUser, await folderDefault.refetch())
|
||||
try {
|
||||
const { js, css } = await getBundle()
|
||||
const deployedPolicy = await policyWithTriggerables()
|
||||
@@ -472,8 +471,10 @@
|
||||
}
|
||||
onSavedNewAppPath?.(path)
|
||||
onDeploy?.({ path })
|
||||
return true
|
||||
} catch (e) {
|
||||
sendUserToast(`Error creating app: ${e.body ?? e.message}`, true)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,9 +652,6 @@
|
||||
return
|
||||
}
|
||||
const { js, css } = await getBundle()
|
||||
if (!policy.execution_mode) {
|
||||
policy.execution_mode = 'publisher'
|
||||
}
|
||||
setDeployedOnBehalfOf(policy, actingUser)
|
||||
const deployedPolicy = await policyWithTriggerables()
|
||||
const deployed = await AppService.updateAppRaw({
|
||||
@@ -663,14 +661,14 @@
|
||||
app: {
|
||||
value: app!,
|
||||
summary: summary,
|
||||
policy: policyForUpdate(deployedPolicy),
|
||||
// Without the mode, which the Share dialog sets: the server keeps the deployed one,
|
||||
// read under the row lock a mode change also takes.
|
||||
policy: withoutSharedPolicySettings(deployedPolicy),
|
||||
path: npath,
|
||||
deployment_message: deploymentMsg,
|
||||
preserve_on_behalf_of: true,
|
||||
// custom_path requires admin so to accept update without it, we need to send as undefined when non-admin (when undefined, it will be ignored)
|
||||
// it also means that customPath needs to be set to '' instead of undefined to unset it (when admin)
|
||||
custom_path:
|
||||
actingUser?.is_admin || actingUser?.is_super_admin ? (customPath ?? '') : undefined,
|
||||
// Absent keeps the custom URL, which the Share dialog sets.
|
||||
custom_path: undefined,
|
||||
labels
|
||||
},
|
||||
js,
|
||||
@@ -724,18 +722,59 @@
|
||||
settingsDrawer?.openAt(setting)
|
||||
}
|
||||
|
||||
const neverDeployed = $derived(newApp || appPath == '' || savedApp?.no_deployed === true)
|
||||
let shareDialog: ShareDialog | undefined = $state()
|
||||
let firstDeployDialog: FirstDeployDialog | undefined = $state()
|
||||
|
||||
function openShare() {
|
||||
shareDialog?.openDialog('raw_app', appPath, {
|
||||
source: 'editor_header',
|
||||
fromEditor: true,
|
||||
stagedPath: newEditedPath
|
||||
})
|
||||
}
|
||||
|
||||
// Chosen in the first-deploy dialog, added once the run-as confirmation has created the app.
|
||||
let firstDeployMembers: Record<string, boolean> = {}
|
||||
|
||||
async function deploy(message?: string) {
|
||||
if (app == undefined) return
|
||||
if (pathError != '' || customPathError != '') {
|
||||
deployRefused = true
|
||||
openSettings(pathError != '' ? undefined : 'custom-url')
|
||||
if (pathError != '') {
|
||||
openSettings()
|
||||
return
|
||||
}
|
||||
deploymentMsg = message
|
||||
firstDeployMembers = {}
|
||||
if (isNewApp && ownsPageHeader) {
|
||||
// The dialog also asks who the app runs on behalf of, for the path it chose.
|
||||
const choice = await firstDeployDialog?.ask({
|
||||
kind: 'raw_app',
|
||||
summary,
|
||||
path: newEditedPath,
|
||||
appMode: accessModeOf(policy),
|
||||
runAs: {
|
||||
email: policy.on_behalf_of_email,
|
||||
permissionedAs: policy.on_behalf_of,
|
||||
targetWorkspace: opWorkspace ?? ''
|
||||
}
|
||||
})
|
||||
if (!choice) return
|
||||
summary = choice.summary
|
||||
newEditedPath = choice.path
|
||||
policy.execution_mode = choice.appMode
|
||||
if (choice.runAs) {
|
||||
policy.on_behalf_of_email = choice.runAs.email
|
||||
policy.on_behalf_of = choice.runAs.permissionedAs
|
||||
}
|
||||
deploymentMsg = choice.message
|
||||
firstDeployMembers = choice.members
|
||||
await deployNow()
|
||||
return
|
||||
}
|
||||
// Compares against the user deployed right now; a failed lookup asks rather than trusting
|
||||
// the loaded one.
|
||||
deployedRunAs = isNewApp ? undefined : await fetchDeployedRunAs(opWorkspace!, appPath)
|
||||
if (
|
||||
const asksRunAs =
|
||||
(!isNewApp && !deployedRunAs) ||
|
||||
// Asks while the folder default is loading: the backend would apply it unconfirmed.
|
||||
folderDefault.loading ||
|
||||
@@ -747,7 +786,19 @@
|
||||
savedPermissionedAs: deployedRunAs?.on_behalf_of,
|
||||
folderDefault: folderDefault.value
|
||||
})
|
||||
if (
|
||||
shareDialog &&
|
||||
movesToAnotherOwner(appPath, newEditedPath) &&
|
||||
!(await shareDialog.confirmMove(
|
||||
'raw_app',
|
||||
appPath,
|
||||
newEditedPath,
|
||||
asksRunAs ? 'Next' : 'Deploy'
|
||||
))
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (asksRunAs) {
|
||||
deployDialogOpen = true
|
||||
return
|
||||
}
|
||||
@@ -756,7 +807,11 @@
|
||||
|
||||
async function deployNow() {
|
||||
if (isNewApp) {
|
||||
await createApp(newEditedPath)
|
||||
const members = firstDeployMembers
|
||||
const workspace = opWorkspace!
|
||||
if (await createApp(newEditedPath)) {
|
||||
await applyFirstDeployMembers(workspace, 'raw_app', newEditedPath, members)
|
||||
}
|
||||
} else {
|
||||
await handleUpdateApp(newEditedPath)
|
||||
}
|
||||
@@ -848,10 +903,27 @@
|
||||
icon: Settings,
|
||||
action: () => openSettings()
|
||||
},
|
||||
...(ownsPageHeader
|
||||
? [
|
||||
{
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
disabled: neverDeployed,
|
||||
action: openShare
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
displayName: 'Public URL',
|
||||
icon: Globe,
|
||||
action: () => openSettings('access')
|
||||
disabled: neverDeployed,
|
||||
action: async () => {
|
||||
const secretUrl = await AppService.getPublicSecretOfApp({
|
||||
workspace: opWorkspace!,
|
||||
path: appPath
|
||||
})
|
||||
window.open(`${window.location.origin}/public/${opWorkspace}/${secretUrl}`, '_blank')
|
||||
}
|
||||
},
|
||||
{
|
||||
displayName: 'Export',
|
||||
@@ -875,11 +947,11 @@
|
||||
}
|
||||
])
|
||||
|
||||
let customPath = $state(savedApp?.custom_path)
|
||||
// Derived, so a draft synced in from another session reaches the header; an edit here overrides
|
||||
// the value until the next one arrives.
|
||||
let customPath = $state(savedApp?.custom_path)
|
||||
let customPathError = $state('')
|
||||
let labels = $derived(initialLabels)
|
||||
let settingsHaveErrors = $derived(pathError != '')
|
||||
|
||||
let jobsDrawerOpen = $state(false)
|
||||
|
||||
@@ -897,8 +969,6 @@
|
||||
labels
|
||||
})
|
||||
)
|
||||
|
||||
let settingsHaveErrors = $derived(pathError != '' || customPathError != '')
|
||||
</script>
|
||||
|
||||
<DeployOnBehalfOfDialog
|
||||
@@ -940,15 +1010,26 @@
|
||||
rawApp
|
||||
operatingWorkspace={opWorkspace}
|
||||
bind:summary
|
||||
bind:customPath
|
||||
bind:customPathError
|
||||
bind:pathError
|
||||
bind:newEditedPath
|
||||
bind:labels
|
||||
showErrors={deployRefused}
|
||||
{setAccessMode}
|
||||
/>
|
||||
|
||||
{#if ownsPageHeader}
|
||||
<ShareDialog
|
||||
bind:this={shareDialog}
|
||||
onAppChanged={(row) => {
|
||||
policy.execution_mode = row.policy.execution_mode
|
||||
customPath = row.custom_path ?? undefined
|
||||
if (savedApp) {
|
||||
savedApp.policy = { ...savedApp.policy, execution_mode: row.policy.execution_mode }
|
||||
savedApp.custom_path = row.custom_path ?? undefined
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<FirstDeployDialog bind:this={firstDeployDialog} />
|
||||
{/if}
|
||||
|
||||
<Drawer bind:open={historyBrowserDrawerOpen} size="1200px">
|
||||
<DrawerContent title="Deployment History" on:close={() => (historyBrowserDrawerOpen = false)}>
|
||||
<DeploymentHistory on:restore={(e) => onRestore?.(e.detail)} {appPath} />
|
||||
@@ -1235,7 +1316,7 @@
|
||||
<!-- Draws nothing in the bar: it is the export drawer, opened from the menu's Export entry
|
||||
through this instance. -->
|
||||
<AppExportButton bind:this={appExport} />
|
||||
<!-- Right before Deploy at every fold; only the opted-out docked-chat toggle gives way on a
|
||||
<!-- Right before Share and Deploy at every fold; only the opted-out docked-chat toggle gives way on a
|
||||
phone. -->
|
||||
<OpenInSessionButton source={sessionOpen}>
|
||||
{#snippet fallback()}
|
||||
@@ -1253,6 +1334,14 @@
|
||||
{/if}
|
||||
{/snippet}
|
||||
</OpenInSessionButton>
|
||||
{#if ownsPageHeader && !phoneTopbar}
|
||||
<ShareButton
|
||||
deployed={!neverDeployed}
|
||||
iconOnly={compactTopbar}
|
||||
unifiedSize={headerBtnSize}
|
||||
onclick={openShare}
|
||||
/>
|
||||
{/if}
|
||||
<DeployButton
|
||||
bind:this={deployButton}
|
||||
loadingSave={loading.save}
|
||||
|
||||
@@ -71,8 +71,8 @@
|
||||
RotateCw,
|
||||
Save,
|
||||
SearchX,
|
||||
Shield,
|
||||
Trash,
|
||||
UserPlus,
|
||||
Zap
|
||||
} from 'lucide-svelte'
|
||||
import { onMount, untrack } from 'svelte'
|
||||
@@ -1382,8 +1382,8 @@
|
||||
class="w-fit"
|
||||
items={[
|
||||
{
|
||||
displayName: 'Permissions',
|
||||
icon: Shield,
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
action: () => {
|
||||
shareModal?.openDrawer?.(path, 'resource')
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
Play,
|
||||
Plus,
|
||||
SearchX,
|
||||
Shield,
|
||||
Trash,
|
||||
TriangleAlert
|
||||
TriangleAlert,
|
||||
UserPlus
|
||||
} from 'lucide-svelte'
|
||||
import { goto } from '$lib/navigation'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
@@ -652,8 +652,8 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
displayName: 'Permissions',
|
||||
icon: Shield,
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
action: () => {
|
||||
shareModal?.openDrawer(path, 'schedule')
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
Pen,
|
||||
Plus,
|
||||
Route,
|
||||
Shield,
|
||||
Trash,
|
||||
Unplug
|
||||
Unplug,
|
||||
UserPlus
|
||||
} from 'lucide-svelte'
|
||||
import CenteredPage from '$lib/components/CenteredPage.svelte'
|
||||
import { Alert, Badge, Button, EmptyState, Skeleton } from '$lib/components/common'
|
||||
@@ -830,8 +830,8 @@
|
||||
href: `/audit_logs?resource=${path}`
|
||||
},
|
||||
{
|
||||
displayName: 'Permissions',
|
||||
icon: Shield,
|
||||
displayName: 'Share',
|
||||
icon: UserPlus,
|
||||
action: () => {
|
||||
shareModal?.openDrawer(path, config.shareKind as any)
|
||||
}
|
||||
|
||||
@@ -61,9 +61,12 @@ export function useFolderDefaultPermissionedAs(
|
||||
get loading() {
|
||||
const ws = workspace()
|
||||
return (
|
||||
folderResource.loading ||
|
||||
(!!ws && !!pathGetter()?.startsWith('f/') && !acting.resolved(ws))
|
||||
folderResource.loading || (!!ws && !!pathGetter()?.startsWith('f/') && !acting.resolved(ws))
|
||||
)
|
||||
},
|
||||
/** Reads the default for the path as it is now: `value` follows a path change a fetch later. */
|
||||
refetch() {
|
||||
return folderResource.refetch()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
Link,
|
||||
Pen,
|
||||
RefreshCw,
|
||||
Shield,
|
||||
UserPlus,
|
||||
Trash,
|
||||
Building,
|
||||
CalendarClock,
|
||||
@@ -647,11 +647,11 @@
|
||||
]
|
||||
: []),
|
||||
{
|
||||
displayName: 'Permissions',
|
||||
displayName: 'Share',
|
||||
action: () => {
|
||||
shareModal?.openDrawer(path, 'variable')
|
||||
},
|
||||
icon: Shield
|
||||
icon: UserPlus
|
||||
},
|
||||
...(account != undefined
|
||||
? [
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('$lib/gen', () => ({
|
||||
AppService: {
|
||||
getAppByPath: vi.fn(async () => ({
|
||||
policy: { execution_mode: 'anonymous' },
|
||||
draft: { files: {}, runnables: {}, policy: { execution_mode: 'anonymous' } }
|
||||
})),
|
||||
existsApp: vi.fn(async () => true),
|
||||
updateAppRaw: vi.fn(async () => {})
|
||||
}
|
||||
}))
|
||||
vi.mock('$lib/components/copilot/chat/global/rawAppBundlerBridge', () => ({
|
||||
bundleRawAppDraft: vi.fn(async () => ({ js: '', css: '' }))
|
||||
}))
|
||||
vi.mock('$lib/components/raw_apps/rawAppPolicy', () => ({
|
||||
updateRawAppPolicy: vi.fn(async (_runnables: unknown, policy: unknown) => ({ ...(policy as {}) }))
|
||||
}))
|
||||
|
||||
import { AppService } from '$lib/gen'
|
||||
import { deployRawAppDraft, deployRawAppValue } from './rawAppDeploy'
|
||||
|
||||
// Who can open a deployed app is set from the Share dialog. A deploy stating a mode would put back
|
||||
// the one it was given, so an update states none and the server keeps the deployed one.
|
||||
describe('raw app deploys', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(AppService.updateAppRaw).mockClear()
|
||||
})
|
||||
|
||||
const sentPolicy = () =>
|
||||
(vi.mocked(AppService.updateAppRaw).mock.calls[0][0].formData.app as any).policy
|
||||
|
||||
it('deploy a value without stating a mode', async () => {
|
||||
await deployRawAppValue({
|
||||
workspace: 'w',
|
||||
path: 'f/ops/app',
|
||||
value: { files: {}, runnables: {} },
|
||||
policy: { execution_mode: 'anonymous' } as any
|
||||
})
|
||||
expect(sentPolicy()).not.toHaveProperty('execution_mode')
|
||||
})
|
||||
|
||||
it('deploy a draft without stating a mode', async () => {
|
||||
await deployRawAppDraft('w', 'f/ops/app')
|
||||
expect(sentPolicy()).not.toHaveProperty('execution_mode')
|
||||
})
|
||||
})
|
||||
@@ -12,11 +12,10 @@
|
||||
*/
|
||||
import { AppService } from '$lib/gen'
|
||||
import type { Policy } from '$lib/gen'
|
||||
import { isAdminIn } from '$lib/user'
|
||||
import { bundleRawAppDraft } from '$lib/components/copilot/chat/global/rawAppBundlerBridge'
|
||||
import type { AppDraftValue } from '$lib/components/copilot/chat/global/workspaceItems'
|
||||
import { updateRawAppPolicy } from '$lib/components/raw_apps/rawAppPolicy'
|
||||
import { policyForUpdate } from '$lib/components/apps/editor/publishAccessMode'
|
||||
import { withoutSharedPolicySettings } from '$lib/components/apps/editor/appDraftSettings'
|
||||
import { DEFAULT_DATA as DEFAULT_RAW_APP_DATA } from '$lib/components/raw_apps/dataTableRefUtils'
|
||||
import {
|
||||
appSourceToDraftValue,
|
||||
@@ -34,7 +33,6 @@ export async function deployRawAppValue({
|
||||
value,
|
||||
summary,
|
||||
policy: currentPolicy,
|
||||
customPath,
|
||||
deploymentMessage,
|
||||
allowKindChange
|
||||
}: {
|
||||
@@ -43,7 +41,6 @@ export async function deployRawAppValue({
|
||||
value: any
|
||||
summary?: string
|
||||
policy?: Policy
|
||||
customPath?: string | null
|
||||
deploymentMessage?: string
|
||||
/** Let this deploy turn a low-code app into a raw one. Off for every ordinary
|
||||
* deploy — see the backend's `allow_kind_change`. */
|
||||
@@ -60,7 +57,6 @@ export async function deployRawAppValue({
|
||||
|
||||
const bundle = await bundleRawAppDraft({ workspace, files })
|
||||
|
||||
const isAdmin = await isAdminIn(workspace)
|
||||
await AppService.updateAppRaw({
|
||||
workspace,
|
||||
path,
|
||||
@@ -70,10 +66,12 @@ export async function deployRawAppValue({
|
||||
// version can still carry the pre-`data` datatable shapes.
|
||||
value: { files, runnables, data: normalizeRawAppData(plainValue) },
|
||||
summary: summary ?? '',
|
||||
policy: policyForUpdate(policy),
|
||||
// Without the mode, which the Share dialog sets: the server keeps the deployed one,
|
||||
// read under the row lock a mode change also takes.
|
||||
policy: withoutSharedPolicySettings(policy),
|
||||
deployment_message: deploymentMessage,
|
||||
// custom_path changes require admin (see deployRawAppDraft).
|
||||
custom_path: isAdmin ? (customPath ?? '') : undefined,
|
||||
// Absent keeps the custom URL, which the Share dialog sets.
|
||||
custom_path: undefined,
|
||||
preserve_on_behalf_of: policy.on_behalf_of ? true : undefined,
|
||||
allow_kind_change: allowKindChange || undefined
|
||||
},
|
||||
@@ -122,13 +120,8 @@ export async function deployRawAppDraft(
|
||||
const summary = value.summary ?? ''
|
||||
|
||||
if (await AppService.existsApp({ workspace, path })) {
|
||||
// custom_path changes require admin. Mirror RawAppEditorHeader's update path:
|
||||
// admins send the draft's value (`''` to clear), non-admins send undefined so
|
||||
// the backend ignores it and preserves the existing route — otherwise a
|
||||
// non-admin deploying a draft for an app that has a custom route would hit
|
||||
// RequireAdmin (the deployed custom_path is sent via the appSourceToDraftValue
|
||||
// fallback even when unchanged).
|
||||
const isAdmin = await isAdminIn(workspace)
|
||||
// Who can open the app and its custom URL are set from the Share dialog: the update states
|
||||
// neither, and the server keeps the deployed ones.
|
||||
await AppService.updateAppRaw({
|
||||
workspace,
|
||||
path,
|
||||
@@ -137,9 +130,9 @@ export async function deployRawAppDraft(
|
||||
path: targetPath,
|
||||
value: rawAppValue,
|
||||
summary,
|
||||
policy: policyForUpdate(policy),
|
||||
policy: withoutSharedPolicySettings(policy),
|
||||
deployment_message: deploymentMessage,
|
||||
custom_path: isAdmin ? (value.custom_path ?? '') : undefined,
|
||||
custom_path: undefined,
|
||||
labels: value.labels,
|
||||
// Preserve the policy's on_behalf_of: this draft-deploy path has no
|
||||
// on-behalf-of selector, so without the flag the backend resets it to
|
||||
|
||||
@@ -46,9 +46,9 @@ import {
|
||||
appDraftSettings,
|
||||
draftOrDeployedSettings,
|
||||
policySettings,
|
||||
withDraftPolicySettings
|
||||
withDraftPolicySettings,
|
||||
withoutSharedPolicySettings
|
||||
} from '$lib/components/apps/editor/appDraftSettings'
|
||||
import { policyForUpdate } from '$lib/components/apps/editor/publishAccessMode'
|
||||
import { invalidateWorkspaceDrafts } from '$lib/workspaceDrafts.svelte'
|
||||
import { invalidateWorkspaceComparison } from '$lib/workspaceComparison'
|
||||
import { setLocalDraftHint } from '$lib/localDraftHints.svelte'
|
||||
@@ -350,11 +350,14 @@ export async function getDraftDiffValues(
|
||||
// A staged rename (`draft_path`) changes where deploy lands the app —
|
||||
// compare it as `path` on both sides so a rename-only draft diffs.
|
||||
const rawDraftPath = (r.draft?.draft_path as string | undefined) ?? r.path
|
||||
// Who can open a deployed app is set from the Share dialog, never drafted.
|
||||
const shared = (v: Record<string, any>) =>
|
||||
draftOnly ? v : { ...v, policy: withoutSharedPolicySettings(v.policy) }
|
||||
return {
|
||||
deployed: draftOnly
|
||||
? canonicalRawAppDiffValue({})
|
||||
: { ...canonicalRawAppDiffValue(r), path: r.path },
|
||||
draft: { ...canonicalRawAppDiffValue(r.draft ?? r), path: rawDraftPath },
|
||||
: shared({ ...canonicalRawAppDiffValue(r), path: r.path }),
|
||||
draft: shared({ ...canonicalRawAppDiffValue(r.draft ?? r), path: rawDraftPath }),
|
||||
hasDraft: r.draft != null,
|
||||
noDeployed: r.no_deployed === true
|
||||
}
|
||||
@@ -613,18 +616,18 @@ export async function deployDraft(
|
||||
appValue,
|
||||
withDraftPolicySettings(deployedPolicy, settings.policy)
|
||||
)
|
||||
// custom_path requires admin on update; non-admins send undefined so the
|
||||
// backend preserves the existing route. The draft has no custom_path, so
|
||||
// admins fall back to the deployed route (`''` when none).
|
||||
const isAdmin = await isAdminIn(workspace)
|
||||
const requestBody = {
|
||||
value: appValue,
|
||||
summary: parts.summary ?? r.summary ?? '',
|
||||
policy: draftOnly ? policy : policyForUpdate(policy),
|
||||
// An update states no mode: the Share dialog sets it, and the server keeps the
|
||||
// deployed one.
|
||||
policy: draftOnly ? policy : withoutSharedPolicySettings(policy),
|
||||
// Honor the draft's intended path; `draft_path` holds the user-typed path
|
||||
// for a never-deployed app parked at a `u/{user}/draft_{uuid}` storage key.
|
||||
path: parts.draftPath ?? r.path ?? path,
|
||||
custom_path: isAdmin ? (r.custom_path ?? '') : undefined,
|
||||
// A deploy never writes the custom URL: the Share dialog sets it, and an update
|
||||
// without one keeps it.
|
||||
custom_path: undefined,
|
||||
labels: settings.labels,
|
||||
deployment_message: deploymentMessage,
|
||||
// Preserve the drafted on_behalf_of (the backend resets it to the deploying
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
} from '$lib/components/raw_apps/dataTableRefUtils'
|
||||
import { importStore } from '$lib/components/apps/store'
|
||||
import { UserDraft, draftValuesEqual } from '$lib/userDraft.svelte'
|
||||
import { withoutSharedPolicySettings } from '$lib/components/apps/editor/appDraftSettings'
|
||||
import { UserDraftDbSyncer } from '$lib/userDraftDbSyncer.svelte'
|
||||
import { usePageDraftSync } from '$lib/components/usePageDraftSync.svelte'
|
||||
import { OtherUserDraftLoad } from '$lib/components/otherUserDraftLoad.svelte'
|
||||
@@ -132,12 +133,15 @@
|
||||
void summary
|
||||
void pendingDraftPath
|
||||
void pendingDraftSettings
|
||||
// Who can open a deployed app is set from the Share dialog, not drafted; the custom URL is
|
||||
// the deployed one.
|
||||
const deployed = deployedBaseline !== undefined
|
||||
draftSync.draft = {
|
||||
files: currentFiles,
|
||||
runnables,
|
||||
data,
|
||||
summary,
|
||||
policy,
|
||||
policy: deployed ? withoutSharedPolicySettings(policy) : policy,
|
||||
custom_path: savedApp?.custom_path,
|
||||
labels: pendingDraftSettings ? pendingDraftSettings.labels : (labels ?? []),
|
||||
parent_version: parentVersion,
|
||||
@@ -373,7 +377,7 @@
|
||||
runnables: backendApp.value?.runnables ?? {},
|
||||
data: extractDataConfig(backendApp.value) ?? { ...DEFAULT_DATA },
|
||||
summary: backendApp.summary ?? '',
|
||||
policy: backendApp.policy,
|
||||
policy: withoutSharedPolicySettings(backendApp.policy),
|
||||
custom_path: backendApp.custom_path,
|
||||
labels: backendApp.labels ?? [],
|
||||
parent_version: parentVersion
|
||||
@@ -420,9 +424,13 @@
|
||||
data: savedRawAppDraft.data ?? backendApp.value?.data
|
||||
}
|
||||
if (savedRawAppDraft.summary !== undefined) backendApp.summary = savedRawAppDraft.summary
|
||||
if (savedRawAppDraft.policy !== undefined) backendApp.policy = savedRawAppDraft.policy
|
||||
if (savedRawAppDraft.custom_path !== undefined)
|
||||
backendApp.custom_path = savedRawAppDraft.custom_path
|
||||
// Who can open the app and its custom URL stay the deployed ones: a draft saved before
|
||||
// a Share change must not revert it.
|
||||
if (savedRawAppDraft.policy !== undefined)
|
||||
backendApp.policy = {
|
||||
...savedRawAppDraft.policy,
|
||||
execution_mode: backendApp.policy.execution_mode
|
||||
}
|
||||
if (savedRawAppDraft.labels !== undefined) backendApp.labels = savedRawAppDraft.labels
|
||||
}
|
||||
const backendApp_ = structuredClone(stateSnapshot(backendApp))
|
||||
@@ -431,7 +439,8 @@
|
||||
value: backendApp_.value as any,
|
||||
path: backendApp_.path,
|
||||
// The deployed policy, not the draft's swapped in above: the header and the settings
|
||||
// measure what a deploy changes against it.
|
||||
// measure what a deploy changes against it. A deployed app's custom path is never
|
||||
// swapped in, so the row's is the deployed one.
|
||||
policy: deployedBaseline
|
||||
? structuredClone(stateSnapshot(deployedBaseline.policy))
|
||||
: backendApp_.policy,
|
||||
@@ -482,7 +491,7 @@
|
||||
runnables,
|
||||
data,
|
||||
summary,
|
||||
policy,
|
||||
policy: deployedBaseline ? withoutSharedPolicySettings(policy) : policy,
|
||||
custom_path: savedApp?.custom_path,
|
||||
labels: labels ?? [],
|
||||
parent_version: parentVersion,
|
||||
|
||||
Reference in New Issue
Block a user