diff --git a/app/edge/components/group-form/groupFormController.js b/app/edge/components/group-form/groupFormController.js
index 253c7ea66..7086570a7 100644
--- a/app/edge/components/group-form/groupFormController.js
+++ b/app/edge/components/group-form/groupFormController.js
@@ -37,6 +37,7 @@ export class EdgeGroupFormController {
this.onChangeDynamic = this.onChangeDynamic.bind(this);
this.onChangeModel = this.onChangeModel.bind(this);
this.onChangePartialMatch = this.onChangePartialMatch.bind(this);
+ this.handleSubmit = this.handleSubmit.bind(this);
$scope.$watch(
() => this.model,
@@ -118,6 +119,10 @@ export class EdgeGroupFormController {
});
}
+ handleSubmit() {
+ this.formAction(this.model);
+ }
+
$onInit() {
this.getTags();
}
diff --git a/app/edge/react/components/index.ts b/app/edge/react/components/index.ts
index 3eee3f259..fb877f251 100644
--- a/app/edge/react/components/index.ts
+++ b/app/edge/react/components/index.ts
@@ -12,7 +12,13 @@ export const componentsModule = angular
.module('portainer.edge.react.components', [])
.component(
'edgeGroupsSelector',
- r2a(EdgeGroupsSelector, ['items', 'onChange', 'value'])
+ r2a(withReactQuery(EdgeGroupsSelector), [
+ 'onChange',
+ 'value',
+ 'error',
+ 'horizontal',
+ 'isGroupVisible',
+ ])
)
.component(
'edgeScriptForm',
@@ -21,6 +27,7 @@ export const componentsModule = angular
'commands',
'isNomadTokenVisible',
'asyncMode',
+ 'showMetaFields',
])
)
.component(
diff --git a/app/edge/views/edge-groups/createEdgeGroupView/createEdgeGroupViewController.js b/app/edge/views/edge-groups/createEdgeGroupView/createEdgeGroupViewController.js
index a1172b836..c82a63f1d 100644
--- a/app/edge/views/edge-groups/createEdgeGroupView/createEdgeGroupViewController.js
+++ b/app/edge/views/edge-groups/createEdgeGroupView/createEdgeGroupViewController.js
@@ -21,7 +21,6 @@ export class CreateEdgeGroupController {
};
this.createGroup = this.createGroup.bind(this);
- this.createGroupAsync = this.createGroupAsync.bind(this);
}
async $onInit() {
@@ -31,20 +30,18 @@ export class CreateEdgeGroupController {
this.state.loaded = true;
}
- createGroup() {
- return this.$async(this.createGroupAsync);
- }
-
- async createGroupAsync() {
- this.state.actionInProgress = true;
- try {
- await this.EdgeGroupService.create(this.model);
- this.Notifications.success('Success', 'Edge group successfully created');
- this.$state.go('edge.groups');
- } catch (err) {
- this.Notifications.error('Failure', err, 'Unable to create edge group');
- } finally {
- this.state.actionInProgress = false;
- }
+ async createGroup(model) {
+ return this.$async(async () => {
+ this.state.actionInProgress = true;
+ try {
+ await this.EdgeGroupService.create(model);
+ this.Notifications.success('Success', 'Edge group successfully created');
+ this.$state.go('edge.groups');
+ } catch (err) {
+ this.Notifications.error('Failure', err, 'Unable to create edge group');
+ } finally {
+ this.state.actionInProgress = false;
+ }
+ });
}
}
diff --git a/app/edge/views/edge-groups/editEdgeGroupView/editEdgeGroupViewController.js b/app/edge/views/edge-groups/editEdgeGroupView/editEdgeGroupViewController.js
index feb06b2c2..3838206ca 100644
--- a/app/edge/views/edge-groups/editEdgeGroupView/editEdgeGroupViewController.js
+++ b/app/edge/views/edge-groups/editEdgeGroupView/editEdgeGroupViewController.js
@@ -13,7 +13,6 @@ export class EditEdgeGroupController {
};
this.updateGroup = this.updateGroup.bind(this);
- this.updateGroupAsync = this.updateGroupAsync.bind(this);
}
async $onInit() {
@@ -28,20 +27,18 @@ export class EditEdgeGroupController {
this.state.loaded = true;
}
- updateGroup() {
- return this.$async(this.updateGroupAsync);
- }
-
- async updateGroupAsync() {
- this.state.actionInProgress = true;
- try {
- await this.EdgeGroupService.update(this.model);
- this.Notifications.success('Success', 'Edge group successfully updated');
- this.$state.go('edge.groups');
- } catch (err) {
- this.Notifications.error('Failure', err, 'Unable to update edge group');
- } finally {
- this.state.actionInProgress = false;
- }
+ updateGroup(group) {
+ return this.$async(async () => {
+ this.state.actionInProgress = true;
+ try {
+ await this.EdgeGroupService.update(group);
+ this.Notifications.success('Success', 'Edge group successfully updated');
+ this.$state.go('edge.groups');
+ } catch (err) {
+ this.Notifications.error('Failure', err, 'Unable to update edge group');
+ } finally {
+ this.state.actionInProgress = false;
+ }
+ });
}
}
diff --git a/app/edge/views/edge-stacks/createEdgeStackView/create-edge-stack-view.html b/app/edge/views/edge-stacks/createEdgeStackView/create-edge-stack-view.html
index ecfa4dc84..7f1b730bb 100644
--- a/app/edge/views/edge-stacks/createEdgeStackView/create-edge-stack-view.html
+++ b/app/edge/views/edge-stacks/createEdgeStackView/create-edge-stack-view.html
@@ -39,19 +39,7 @@
-
Edge Groups
-
+
[...tagKeys.all, id] as const,
};
-export function useTags(select?: (tags: Tag[]) => T[]) {
- const { data, isLoading } = useQuery(tagKeys.all, () => getTags(), {
+export function useTags({
+ select,
+}: { select?: (tags: Tag[]) => T } = {}) {
+ return useQuery(tagKeys.all, () => getTags(), {
staleTime: 50,
select,
...withError('Failed to retrieve tags'),
});
-
- return { tags: data, isLoading };
}
export function useCreateTagMutation() {
diff --git a/app/react/components/TagSelector/TagSelector.tsx b/app/react/components/TagSelector/TagSelector.tsx
index 79ee52fca..2c48e2908 100644
--- a/app/react/components/TagSelector/TagSelector.tsx
+++ b/app/react/components/TagSelector/TagSelector.tsx
@@ -22,17 +22,17 @@ interface Option {
export function TagSelector({ value, allowCreate = false, onChange }: Props) {
// change the struct because react-select has a bug with Creatable (https://github.com/JedWatson/react-select/issues/3417#issuecomment-461868989)
- const tagsQuery = useTags((tags) =>
- tags.map((opt) => ({ label: opt.Name, value: opt.ID }))
- );
+ const tagsQuery = useTags({
+ select: (tags) => tags?.map((opt) => ({ label: opt.Name, value: opt.ID })),
+ });
const createTagMutation = useCreateTagMutation();
- if (!tagsQuery.tags) {
+ if (!tagsQuery.data) {
return null;
}
- const { tags } = tagsQuery;
+ const { data: tags } = tagsQuery;
const selectedTags = _.compact(
value.map((id) => tags.find((tag) => tag.value === id))
diff --git a/app/react/components/form-components/PortainerSelect.tsx b/app/react/components/form-components/PortainerSelect.tsx
index fc02a700c..fa4e1128c 100644
--- a/app/react/components/form-components/PortainerSelect.tsx
+++ b/app/react/components/form-components/PortainerSelect.tsx
@@ -1,4 +1,8 @@
-import { OptionsOrGroups } from 'react-select';
+import {
+ GroupBase,
+ OptionsOrGroups,
+ SelectComponentsConfig,
+} from 'react-select';
import _ from 'lodash';
import { AutomationTestingProps } from '@/types';
@@ -10,9 +14,10 @@ export interface Option {
label: string;
}
-type Group = { label: string; options: Option[] };
-
-type Options = OptionsOrGroups