-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show in the edit-menu the mini-widgets that are out of the top/bottom bar #1559
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => { | |
const elementToShowOnDrawer = ref<CustomWidgetElement>() | ||
const widgetToEdit = ref<Widget>() | ||
const miniWidgetLastValues = useBlueOsStorage<Record<string, any>>('cockpit-mini-widget-last-values', {}) | ||
const floatingWidgetContainers = ref<MiniWidgetContainer[]>([]) | ||
|
||
const editWidgetByHash = (hash: string): Widget | undefined => { | ||
widgetToEdit.value = currentProfile.value.views | ||
|
@@ -272,11 +273,11 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => { | |
const miniWidgetContainersInCurrentView = computed(() => { | ||
const fixedBarContainers = currentMiniWidgetsProfile.value.containers | ||
const viewBarContainers = currentView.value.miniWidgetContainers | ||
const floatingWidgetContainers = currentView.value.widgets | ||
floatingWidgetContainers.value = currentView.value.widgets | ||
.filter((w) => w.component === WidgetType.MiniWidgetsBar) | ||
.filter((w) => w.options && w.options.miniWidgetsContainer) | ||
.map((w) => w.options.miniWidgetsContainer) | ||
return [...fixedBarContainers, ...viewBarContainers, ...floatingWidgetContainers] | ||
return [...fixedBarContainers, ...viewBarContainers, ...floatingWidgetContainers.value] | ||
Comment on lines
-275
to
+280
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those line changes do not seen to have any effect in the code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. floatingWidgetContainers variable declaration was moved outside the This was changed so it will be possible to access the value from floatingWidgetContainers outside the scope of this function. |
||
}) | ||
|
||
/** | ||
|
@@ -608,18 +609,34 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => { | |
const container: MiniWidgetContainer | undefined = miniWidgetContainersInCurrentView.value.find((cont) => { | ||
return cont.widgets.includes(miniWidget) | ||
}) | ||
if (container === undefined) { | ||
showDialog({ variant: 'error', message: 'Mini-widget container not found.' }) | ||
const customWidgetContainer = getElementByHash(miniWidget.hash) | ||
if (container) { | ||
const index = container.widgets.indexOf(miniWidget) | ||
container.widgets.splice(index, 1) | ||
// Remove miniWidget variable from the list of currently logged variables | ||
CurrentlyLoggedVariables.removeVariable(miniWidget.options.displayName) | ||
return | ||
} | ||
if (customWidgetContainer) { | ||
removeElementFromCustomWidget(miniWidget.hash) | ||
CurrentlyLoggedVariables.removeVariable(miniWidget.options.displayName) | ||
return | ||
} | ||
|
||
const index = container.widgets.indexOf(miniWidget) | ||
container.widgets.splice(index, 1) | ||
|
||
// Remove miniWidget variable from the list of currently logged variables | ||
CurrentlyLoggedVariables.removeVariable(miniWidget.options.displayName) | ||
showDialog({ variant: 'error', message: 'Mini-widget container not found.' }) | ||
} | ||
|
||
const customWidgetContainers = computed<MiniWidgetContainer[]>(() => | ||
currentProfile.value.views | ||
.flatMap((view) => view.widgets) | ||
.filter((widget) => widget.component === WidgetType.CustomWidgetBase) | ||
.flatMap((widget) => widget.options.elementContainers) | ||
.map((container) => ({ | ||
name: '', | ||
widgets: container.elements as unknown as MiniWidget[], | ||
})) | ||
) | ||
|
||
/** | ||
* States whether the given mini-widget is a real mini-widget | ||
* Fake mini-widgets are those used as placeholders, in the edit-menu, for example | ||
|
@@ -630,6 +647,8 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => { | |
const allContainers = [ | ||
...savedProfiles.value.flatMap((profile) => profile.views.flatMap((view) => view.miniWidgetContainers)), | ||
...currentMiniWidgetsProfile.value.containers, | ||
...floatingWidgetContainers.value, | ||
...customWidgetContainers.value, | ||
] | ||
|
||
return allContainers.some((container) => container.widgets.some((widget) => widget.hash === miniWidgetHash)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forgot the new enable/disable cog logic here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done