forked from github-starred/komodo
isolate stacks / deployments with pending updates
This commit is contained in:
@@ -51,20 +51,15 @@ impl Resolve<ReadArgs> for ListDeployments {
|
||||
} else {
|
||||
get_all_tags(None).await?
|
||||
};
|
||||
let update_available_filter =
|
||||
self.query.specific.update_available;
|
||||
let only_update_available = self.query.specific.update_available;
|
||||
let deployments = resource::list_for_user::<Deployment>(
|
||||
self.query, user, &all_tags,
|
||||
)
|
||||
.await?;
|
||||
let deployments = if let Some(update_available_filter) =
|
||||
update_available_filter
|
||||
{
|
||||
let deployments = if only_update_available {
|
||||
deployments
|
||||
.into_iter()
|
||||
.filter(|deployment| {
|
||||
deployment.info.update_available == update_available_filter
|
||||
})
|
||||
.filter(|deployment| deployment.info.update_available)
|
||||
.collect()
|
||||
} else {
|
||||
deployments
|
||||
|
||||
@@ -194,14 +194,11 @@ impl Resolve<ReadArgs> for ListStacks {
|
||||
} else {
|
||||
get_all_tags(None).await?
|
||||
};
|
||||
let update_available_filter =
|
||||
self.query.specific.update_available;
|
||||
let only_update_available = self.query.specific.update_available;
|
||||
let stacks =
|
||||
resource::list_for_user::<Stack>(self.query, user, &all_tags)
|
||||
.await?;
|
||||
let stacks = if let Some(update_available_filter) =
|
||||
update_available_filter
|
||||
{
|
||||
let stacks = if only_update_available {
|
||||
stacks
|
||||
.into_iter()
|
||||
.filter(|stack| {
|
||||
@@ -210,7 +207,6 @@ impl Resolve<ReadArgs> for ListStacks {
|
||||
.services
|
||||
.iter()
|
||||
.any(|service| service.update_available)
|
||||
== update_available_filter
|
||||
})
|
||||
.collect()
|
||||
} else {
|
||||
|
||||
@@ -466,7 +466,8 @@ pub struct DeploymentQuerySpecifics {
|
||||
pub build_ids: Vec<String>,
|
||||
|
||||
/// Query only for Deployments with available image updates.
|
||||
pub update_available: Option<bool>,
|
||||
#[serde(default)]
|
||||
pub update_available: bool,
|
||||
}
|
||||
|
||||
impl super::resource::AddFilters for DeploymentQuerySpecifics {
|
||||
|
||||
@@ -613,7 +613,8 @@ pub struct StackQuerySpecifics {
|
||||
#[serde(default)]
|
||||
pub repos: Vec<String>,
|
||||
/// Query only for Stack with available image updates.
|
||||
pub update_available: Option<bool>,
|
||||
#[serde(default)]
|
||||
pub update_available: bool,
|
||||
}
|
||||
|
||||
impl super::resource::AddFilters for StackQuerySpecifics {
|
||||
|
||||
@@ -191,8 +191,12 @@ export const ResourceSyncConfig = ({
|
||||
};
|
||||
|
||||
const include_toggles: ConfigComponent<Types.ResourceSyncConfig> = {
|
||||
label: "Toggle",
|
||||
label: "Include",
|
||||
components: {
|
||||
include_resources: {
|
||||
label: "Sync Resources",
|
||||
description: "Include resources (servers, stacks, etc.) in the sync.",
|
||||
},
|
||||
include_variables: {
|
||||
label: "Sync Variables",
|
||||
description: "Include variables in the sync.",
|
||||
@@ -201,10 +205,6 @@ export const ResourceSyncConfig = ({
|
||||
label: "Sync User Groups",
|
||||
description: "Include user groups in the sync.",
|
||||
},
|
||||
include_resources: {
|
||||
label: "Sync Resources",
|
||||
description: "Include resources (servers, stacks, etc.) in the sync.",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -493,3 +493,12 @@ const selected_resources = atomFamily((_: UsableResource) =>
|
||||
);
|
||||
export const useSelectedResources = (type: UsableResource) =>
|
||||
useAtom(selected_resources(type));
|
||||
|
||||
const filter_by_update_available = atomWithStorage<boolean>(
|
||||
"update-available-filter-v1",
|
||||
false
|
||||
);
|
||||
export const useFilterByUpdateAvailable: () => [boolean, () => void] = () => {
|
||||
const [filter, set] = useAtom<boolean>(filter_by_update_available);
|
||||
return [filter, () => set(!filter)];
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Page } from "@components/layouts";
|
||||
import { ResourceComponents } from "@components/resources";
|
||||
import { TagsFilter } from "@components/tags";
|
||||
import {
|
||||
useFilterByUpdateAvailable,
|
||||
useFilterResources,
|
||||
useRead,
|
||||
useResourceParamType,
|
||||
@@ -14,6 +15,7 @@ import { Input } from "@ui/input";
|
||||
import { useState } from "react";
|
||||
import { Search } from "lucide-react";
|
||||
import { NotFound } from "@components/util";
|
||||
import { Switch } from "@ui/switch";
|
||||
|
||||
export const Resources = () => {
|
||||
const is_admin = useUser().data?.admin ?? false;
|
||||
@@ -28,7 +30,13 @@ export const Resources = () => {
|
||||
: type;
|
||||
useSetTitle(name + "s");
|
||||
const [search, set] = useState("");
|
||||
const resources = useRead(`List${type}s`, {}).data;
|
||||
const [filter_update_available, toggle_filter_update_available] =
|
||||
useFilterByUpdateAvailable();
|
||||
const resources = useRead(`List${type}s`, {
|
||||
query: {
|
||||
specific: { update_available: filter_update_available },
|
||||
},
|
||||
}).data;
|
||||
const filtered = useFilterResources(resources as any, search);
|
||||
|
||||
const Components = ResourceComponents[type];
|
||||
@@ -62,6 +70,15 @@ export const Resources = () => {
|
||||
<Components.GroupActions />
|
||||
</div>
|
||||
<div className="flex items-center gap-4 flex-wrap">
|
||||
{(type === "Stack" || type === "Deployment") && (
|
||||
<div
|
||||
className="flex gap-2 items-center cursor-pointer px-3 py-2 text-sm text-muted-foreground"
|
||||
onClick={() => toggle_filter_update_available()}
|
||||
>
|
||||
Pending Update
|
||||
<Switch checked={filter_update_available} />
|
||||
</div>
|
||||
)}
|
||||
<TagsFilter />
|
||||
<div className="relative">
|
||||
<Search className="w-4 absolute top-[50%] left-3 -translate-y-[50%] text-muted-foreground" />
|
||||
|
||||
Reference in New Issue
Block a user