Skip to content

Commit

Permalink
fix: improve workspace specific tags behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfiszel committed Jan 21, 2025
1 parent e81c2c9 commit 7398e6c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
12 changes: 7 additions & 5 deletions backend/windmill-api/src/workers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* LICENSE-AGPL for a copy of the license.
*/

use std::fmt::format;

use axum::{
extract::{Extension, Query},
routing::get,
Expand Down Expand Up @@ -148,9 +150,10 @@ async fn get_custom_tags(Query(query): Query<CustomTagQuery>) -> JsonResult<Vec<
let tags_o = CUSTOM_TAGS_PER_WORKSPACE.read().await;
let workspace_tags = tags_o
.1
.get(&workspace)
.map(|x| x.clone())
.unwrap_or_default();
.iter()
.filter(|(_, workspaces)| workspaces.contains(&workspace))
.map(|(tag, _)| tag.clone())
.collect::<Vec<String>>();
let all_tags = tags_o.0.clone();
return Ok(Json(
all_tags
Expand All @@ -163,8 +166,7 @@ async fn get_custom_tags(Query(query): Query<CustomTagQuery>) -> JsonResult<Vec<
let workspace_tags = tags_o
.1
.iter()
.map(|(workspace, tags)| tags.iter().map(move |tag| format!("{tag}({workspace})")))
.flatten()
.map(|(tag, workspaces)| format!("{}({})", tag, workspaces.join("+")))
.collect::<Vec<String>>();
let all_tags = tags_o.0.clone();
return Ok(Json(
Expand Down
7 changes: 1 addition & 6 deletions backend/windmill-common/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,7 @@ pub async fn reload_custom_tags_setting(db: &DB) -> error::Result<()> {
let mut l = ALL_TAGS.write().await;
*l = [
custom_tags.0.clone(),
custom_tags
.1
.values()
.flatten()
.map(|x| x.to_string())
.collect_vec(),
custom_tags.1.keys().map(|x| x.to_string()).collect_vec(),
]
.concat();
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/components/RunFormAdvancedPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import CloseButton from './common/CloseButton.svelte'
import Toggle from './Toggle.svelte'
import Tooltip from './Tooltip.svelte'
import { userStore, workerTags } from '$lib/stores'
import { userStore, workerTags, workspaceStore } from '$lib/stores'
import { Button } from './common'
import { WorkerService } from '$lib/gen'
import DateTimeInput from './DateTimeInput.svelte'
Expand All @@ -31,7 +31,7 @@
async function loadWorkerGroups() {
if (!$workerTags) {
$workerTags = await WorkerService.getCustomTags()
$workerTags = await WorkerService.getCustomTags({ workspace: $workspaceStore })
}
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/components/WorkerTagPicker.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { Button } from '$lib/components/common'
import { ExternalLink, RotateCw, Loader2 } from 'lucide-svelte'
import { workerTags } from '$lib/stores'
import { workerTags, workspaceStore } from '$lib/stores'
import AssignableTags from './AssignableTags.svelte'
import { WorkerService } from '$lib/gen'
import WorkerTagSelect from './WorkerTagSelect.svelte'
Expand All @@ -13,7 +13,7 @@
loadWorkerGroups()
async function loadWorkerGroups() {
if (!$workerTags) {
$workerTags = await WorkerService.getCustomTags()
$workerTags = await WorkerService.getCustomTags({ workspace: $workspaceStore })
}
}
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { getContext } from 'svelte'
import type { FlowEditorContext } from '../types'
import { workerTags } from '$lib/stores'
import { workerTags, workspaceStore } from '$lib/stores'
import { WorkerService } from '$lib/gen'
import WorkerTagSelect from '$lib/components/WorkerTagSelect.svelte'
Expand All @@ -14,7 +14,7 @@
async function loadWorkerGroups() {
if (!$workerTags) {
$workerTags = await WorkerService.getCustomTags()
$workerTags = await WorkerService.getCustomTags({ workspace: $workspaceStore })
}
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const version = JSON.parse(json)
const config = {
server: {
https: false,
port: 3000,
port: 3006,
proxy: {
'^/api/.*': {
target: process.env.REMOTE ?? 'https://app.windmill.dev/',
Expand Down

0 comments on commit 7398e6c

Please sign in to comment.