Skip to content

Commit

Permalink
hide namespaces via settings
Browse files Browse the repository at this point in the history
(cherry picked from commit 534a365efcf56aa7b3592b55e0885d021f97688c)

added translation; bumped up charts version;fixed lint

revert chart version bumpup

add hideAllNamespaces in externalSettings func
  • Loading branch information
avanish23 committed Oct 22, 2024
1 parent 4b66aa1 commit 0d5f653
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 1 deletion.
4 changes: 4 additions & 0 deletions charts/kubernetes-dashboard/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

apiVersion: v2
name: kubernetes-dashboard
<<<<<<< HEAD
version: 7.9.0
=======
version: 7.8.0
>>>>>>> 0ea61afd6 (revert chart version bumpup)
description: General-purpose web UI for Kubernetes clusters
keywords:
- kubernetes
Expand Down
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

0 comments on commit 0d5f653

Please sign in to comment.