Skip to content
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

feat: allow hiding "All namespaces" in namespaces dropdown list #9547

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions charts/kubernetes-dashboard/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ app:
# resourceAutoRefreshTimeInterval: 10
# # Hide all access denied warnings in the notification panel
# disableAccessDeniedNotifications: false
# # Hide all namespaces option in namespace selection dropdown to avoid accidental selection in large clusters thus preventing OOM errors
# hideAllNamespaces: false
# # Namespace that should be selected by default after logging in.
# defaultNamespace: default
# # List of namespaces that should be presented to user without namespace list privileges.
Expand Down
8 changes: 8 additions & 0 deletions modules/web/i18n/de/messages.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,14 @@
<source> Owner </source>
<target state="new"> Owner </target>
</trans-unit>
<trans-unit id="5883804203832913220" datatype="html">
<source>Hide All Namespaces option</source>
<target state="new">Hide All Namespaces option</target>
</trans-unit>
<trans-unit id="8967487471439603323" datatype="html">
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 8 additions & 0 deletions modules/web/i18n/es/messages.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,14 @@
<source> Owner </source>
<target state="new"> Owner </target>
</trans-unit>
<trans-unit id="5883804203832913220" datatype="html">
<source>Hide All Namespaces option</source>
<target state="new">Hide All Namespaces option</target>
</trans-unit>
<trans-unit id="8967487471439603323" datatype="html">
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 8 additions & 0 deletions modules/web/i18n/fr/messages.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2660,6 +2660,14 @@
<source> Owner </source>
<target state="new"> Owner </target>
</trans-unit>
<trans-unit id="5883804203832913220" datatype="html">
<source>Hide All Namespaces option</source>
<target state="new">Hide All Namespaces option</target>
</trans-unit>
<trans-unit id="8967487471439603323" datatype="html">
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 8 additions & 0 deletions modules/web/i18n/ja/messages.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,14 @@
<source> Owner </source>
<target state="new"> Owner </target>
</trans-unit>
<trans-unit id="5883804203832913220" datatype="html">
<source>Hide All Namespaces option</source>
<target state="new">Hide All Namespaces option</target>
</trans-unit>
<trans-unit id="8967487471439603323" datatype="html">
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 8 additions & 0 deletions modules/web/i18n/ko/messages.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,14 @@
<source> Owner </source>
<target state="new"> Owner </target>
</trans-unit>
<trans-unit id="5883804203832913220" datatype="html">
<source>Hide All Namespaces option</source>
<target state="new">Hide All Namespaces option</target>
</trans-unit>
<trans-unit id="8967487471439603323" datatype="html">
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
</body>
</file>
</xliff>
6 changes: 6 additions & 0 deletions modules/web/i18n/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,12 @@
<trans-unit id="9193001935256028830" datatype="html">
<source> Owner </source>
</trans-unit>
<trans-unit id="5883804203832913220" datatype="html">
<source>Hide All Namespaces option</source>
</trans-unit>
<trans-unit id="8967487471439603323" datatype="html">
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 8 additions & 0 deletions modules/web/i18n/zh-Hans/messages.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,14 @@
<source> Owner </source>
<target state="new"> Owner </target>
</trans-unit>
<trans-unit id="5883804203832913220" datatype="html">
<source>Hide All Namespaces option</source>
<target state="new">Hide All Namespaces option</target>
</trans-unit>
<trans-unit id="8967487471439603323" datatype="html">
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 8 additions & 0 deletions modules/web/i18n/zh-Hant-HK/messages.zh-Hant-HK.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,14 @@
<source> Owner </source>
<target state="new"> Owner </target>
</trans-unit>
<trans-unit id="5883804203832913220" datatype="html">
<source>Hide All Namespaces option</source>
<target state="new">Hide All Namespaces option</target>
</trans-unit>
<trans-unit id="8967487471439603323" datatype="html">
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 8 additions & 0 deletions modules/web/i18n/zh-Hant/messages.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,14 @@
<source> Owner </source>
<target state="new"> Owner </target>
</trans-unit>
<trans-unit id="5883804203832913220" datatype="html">
<source>Hide All Namespaces option</source>
<target state="new">Hide All Namespaces option</target>
</trans-unit>
<trans-unit id="8967487471439603323" datatype="html">
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
</body>
</file>
</xliff>
2 changes: 2 additions & 0 deletions modules/web/pkg/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var defaultSettings = Settings{
LogsAutoRefreshTimeInterval: lo.ToPtr(5),
ResourceAutoRefreshTimeInterval: lo.ToPtr(10),
DisableAccessDeniedNotifications: lo.ToPtr(false),
HideAllNamespaces: lo.ToPtr(false),
DefaultNamespace: lo.ToPtr("default"),
NamespaceFallbackList: []string{"default"},
}
Expand All @@ -39,6 +40,7 @@ type Settings struct {
LogsAutoRefreshTimeInterval *int `json:"logsAutoRefreshTimeInterval,omitempty"`
ResourceAutoRefreshTimeInterval *int `json:"resourceAutoRefreshTimeInterval,omitempty"`
DisableAccessDeniedNotifications *bool `json:"disableAccessDeniedNotifications,omitempty"`
HideAllNamespaces *bool `json:"hideAllNamespaces,omitempty"`
DefaultNamespace *string `json:"defaultNamespace,omitempty"`
NamespaceFallbackList []string `json:"namespaceFallbackList,omitempty"`
}
Expand Down
4 changes: 4 additions & 0 deletions modules/web/src/common/components/namespace/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ export class NamespaceSelectorComponent implements OnInit {
this.loadNamespaces_();
}

showAllNamespaces(): boolean {
return !this.settingsService_.getHideAllNamespaces();
}

selectNamespace(): void {
if (this.selectNamespaceInput.length === 0) {
return;
Expand Down
2 changes: 1 addition & 1 deletion modules/web/src/common/components/namespace/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/>
</div>
<mat-option
*ngIf="namespaces.length && !usingFallbackNamespaces"
*ngIf="showAllNamespaces() && namespaces.length && !usingFallbackNamespaces"
[value]="allNamespacesKey"
i18n
>All namespaces</mat-option
Expand Down
5 changes: 5 additions & 0 deletions modules/web/src/common/services/global/globalsettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const DEFAULT_SETTINGS: GlobalSettings = {
logsAutoRefreshTimeInterval: 5,
resourceAutoRefreshTimeInterval: 5,
disableAccessDeniedNotifications: false,
hideAllNamespaces: false,
defaultNamespace: 'default',
namespaceFallbackList: ['default'],
};
Expand Down Expand Up @@ -130,6 +131,10 @@ export class GlobalSettingsService {
return this.settings_.disableAccessDeniedNotifications;
}

getHideAllNamespaces(): boolean {
return this.settings_.hideAllNamespaces;
}

getDefaultNamespace(): string {
return this.settings_.defaultNamespace;
}
Expand Down
5 changes: 5 additions & 0 deletions modules/web/src/settings/global/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum Controls {
ResourceAutorefreshInterval = 'resourceAutorefreshInterval',
DisableAccessDeniedNotification = 'disableAccessDeniedNotification',
NamespaceSettings = 'namespaceSettings',
HideAllNamespaces = 'hideAllNamespaces',
}

@Component({
Expand Down Expand Up @@ -76,6 +77,7 @@ export class GlobalSettingsComponent implements OnInit {
settings.logsAutoRefreshTimeInterval = this.settingsService_.getLogsAutoRefreshTimeInterval();
settings.resourceAutoRefreshTimeInterval = this.settingsService_.getResourceAutoRefreshTimeInterval();
settings.disableAccessDeniedNotifications = this.settingsService_.getDisableAccessDeniedNotifications();
settings.hideAllNamespaces = this.settingsService_.getHideAllNamespaces();
settings.defaultNamespace = this.settingsService_.getDefaultNamespace();
settings.namespaceFallbackList = this.settingsService_.getNamespaceFallbackList();

Expand All @@ -90,6 +92,7 @@ export class GlobalSettingsComponent implements OnInit {
[Controls.LogsAutorefreshInterval]: this.builder_.control(0),
[Controls.ResourceAutorefreshInterval]: this.builder_.control(0),
[Controls.DisableAccessDeniedNotification]: this.builder_.control(false),
[Controls.HideAllNamespaces]: this.builder_.control(false),
[Controls.NamespaceSettings]: this.builder_.control(''),
});

Expand Down Expand Up @@ -180,6 +183,7 @@ export class GlobalSettingsComponent implements OnInit {
this.form
.get(Controls.DisableAccessDeniedNotification)
.setValue(this.settings.disableAccessDeniedNotifications, {emitEvent: false});
this.form.get(Controls.HideAllNamespaces).setValue(this.settings.hideAllNamespaces, {emitEvent: false});
}

private onLoadError_(): void {
Expand All @@ -191,6 +195,7 @@ export class GlobalSettingsComponent implements OnInit {
itemsPerPage: this.form.get(Controls.ItemsPerPage).value,
clusterName: this.form.get(Controls.ClusterName).value,
disableAccessDeniedNotifications: this.form.get(Controls.DisableAccessDeniedNotification).value,
hideAllNamespaces: this.form.get(Controls.HideAllNamespaces).value,
labelsLimit: this.form.get(Controls.LabelsLimit).value,
logsAutoRefreshTimeInterval: this.form.get(Controls.LogsAutorefreshInterval).value,
resourceAutoRefreshTimeInterval: this.form.get(Controls.ResourceAutorefreshInterval).value,
Expand Down
18 changes: 18 additions & 0 deletions modules/web/src/settings/global/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@
</mat-slide-toggle>
</div>
</kd-settings-entry>
<kd-settings-entry
key="Hide All Namespaces option"
i18n-key
desc="Hides all-namespaces option from the namespaces dropdown list in UI."
i18n-desc
>
<div
fxFlex
fxLayoutAlign=" center"
>
<mat-slide-toggle
color="primary"
name="hideAllNamespaces"
[formControlName]="Controls.HideAllNamespaces"
>
</mat-slide-toggle>
</div>
</kd-settings-entry>
<br /><br />
<button
[disabled]="!canSave()"
Expand Down
1 change: 1 addition & 0 deletions modules/web/src/typings/root.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,7 @@ export interface GlobalSettings {
logsAutoRefreshTimeInterval: number;
resourceAutoRefreshTimeInterval: number;
disableAccessDeniedNotifications: boolean;
hideAllNamespaces: boolean;
defaultNamespace: string;
namespaceFallbackList: string[];
}
Expand Down
Loading