1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

preferences page -- part 2

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-07-23 16:01:32 +03:00
parent 24f754697b
commit 6fd9b7cf76
14 changed files with 452 additions and 535 deletions

View File

@ -112,6 +112,22 @@ msgstr "Add cluster"
msgid "Add field" msgid "Add field"
msgstr "Add field" msgstr "Add field"
#: src/renderer/components/+preferences/preferences.tsx:123
#~ msgid "Added repos"
#~ msgstr "Added repos"
#: src/renderer/components/+preferences/preferences.tsx:149
msgid "Added repos:"
msgstr "Added repos:"
#: src/renderer/components/+preferences/preferences.tsx:108
msgid "Adding helm branch <0>{0}</0> has failed: {1}"
msgstr "Adding helm branch <0>{0}</0> has failed: {1}"
#: src/renderer/components/+preferences/preferences.tsx:108
#~ msgid "Adding repo <0>{0}</0> has failed: {1}"
#~ msgstr "Adding repo <0>{0}</0> has failed: {1}"
#: src/renderer/components/+custom-resources/crd-details.tsx:78 #: src/renderer/components/+custom-resources/crd-details.tsx:78
msgid "Additional Printer Columns" msgid "Additional Printer Columns"
msgstr "Additional Printer Columns" msgstr "Additional Printer Columns"
@ -186,11 +202,11 @@ msgstr "Allocatable"
msgid "Allow Privilege Escalation" msgid "Allow Privilege Escalation"
msgstr "Allow Privilege Escalation" msgstr "Allow Privilege Escalation"
#: src/renderer/components/+preferences/preferences.tsx:76 #: src/renderer/components/+preferences/preferences.tsx:177
msgid "Allow telemetry & usage tracking" msgid "Allow telemetry & usage tracking"
msgstr "Allow telemetry & usage tracking" msgstr "Allow telemetry & usage tracking"
#: src/renderer/components/+preferences/preferences.tsx:68 #: src/renderer/components/+preferences/preferences.tsx:169
msgid "Allow untrusted Certificate Authorities" msgid "Allow untrusted Certificate Authorities"
msgstr "Allow untrusted Certificate Authorities" msgstr "Allow untrusted Certificate Authorities"
@ -385,7 +401,7 @@ msgstr "Cancel"
msgid "Capacity" msgid "Capacity"
msgstr "Capacity" msgstr "Capacity"
#: src/renderer/components/+preferences/preferences.tsx:67 #: src/renderer/components/+preferences/preferences.tsx:168
msgid "Certificate Trust" msgid "Certificate Trust"
msgstr "Certificate Trust" msgstr "Certificate Trust"
@ -452,7 +468,7 @@ msgstr "Cluster IP"
msgid "Cluster Issuers" msgid "Cluster Issuers"
msgstr "Cluster Issuers" msgstr "Cluster Issuers"
#: src/renderer/components/+preferences/preferences.tsx:50 #: src/renderer/components/+preferences/preferences.tsx:139
msgid "Color Theme" msgid "Color Theme"
msgstr "Color Theme" msgstr "Color Theme"
@ -701,7 +717,7 @@ msgstr "Daemon Sets"
msgid "DaemonSets" msgid "DaemonSets"
msgstr "DaemonSets" msgstr "DaemonSets"
#: src/renderer/components/+preferences/preferences.tsx:22 #: src/renderer/components/+preferences/preferences.tsx:40
msgid "Dark" msgid "Dark"
msgstr "Dark" msgstr "Dark"
@ -764,7 +780,7 @@ msgstr "Disk"
msgid "Disk:" msgid "Disk:"
msgstr "Disk:" msgstr "Disk:"
#: src/renderer/components/+preferences/preferences.tsx:72 #: src/renderer/components/+preferences/preferences.tsx:173
msgid "Does not affect cluster communications!" msgid "Does not affect cluster communications!"
msgstr "Does not affect cluster communications!" msgstr "Does not affect cluster communications!"
@ -772,7 +788,7 @@ msgstr "Does not affect cluster communications!"
msgid "Domains" msgid "Domains"
msgstr "Domains" msgstr "Domains"
#: src/renderer/components/+preferences/preferences.tsx:53 #: src/renderer/components/+preferences/preferences.tsx:142
msgid "Download Mirror" msgid "Download Mirror"
msgstr "Download Mirror" msgstr "Download Mirror"
@ -780,7 +796,7 @@ msgstr "Download Mirror"
msgid "Download file" msgid "Download file"
msgstr "Download file" msgstr "Download file"
#: src/renderer/components/+preferences/preferences.tsx:54 #: src/renderer/components/+preferences/preferences.tsx:143
msgid "Download mirror for kubectl" msgid "Download mirror for kubectl"
msgstr "Download mirror for kubectl" msgstr "Download mirror for kubectl"
@ -951,7 +967,7 @@ msgstr "Groups"
msgid "HPA" msgid "HPA"
msgstr "HPA" msgstr "HPA"
#: src/renderer/components/+preferences/preferences.tsx:61 #: src/renderer/components/+preferences/preferences.tsx:162
msgid "HTTP Proxy" msgid "HTTP Proxy"
msgstr "HTTP Proxy" msgstr "HTTP Proxy"
@ -959,7 +975,7 @@ msgstr "HTTP Proxy"
msgid "HTTP Proxy server. Used for communicating with Kubernetes API." msgid "HTTP Proxy server. Used for communicating with Kubernetes API."
msgstr "HTTP Proxy server. Used for communicating with Kubernetes API." msgstr "HTTP Proxy server. Used for communicating with Kubernetes API."
#: src/renderer/components/+preferences/preferences.tsx:56 #: src/renderer/components/+preferences/preferences.tsx:145
msgid "Helm" msgid "Helm"
msgstr "Helm" msgstr "Helm"
@ -971,10 +987,18 @@ msgstr "Helm Chart Install"
msgid "Helm Install: {repo}/{name}" msgid "Helm Install: {repo}/{name}"
msgstr "Helm Install: {repo}/{name}" msgstr "Helm Install: {repo}/{name}"
#: src/renderer/components/+preferences/preferences.tsx:61
#~ msgid "Helm Repository <0>{0}</0> already in use."
#~ msgstr "Helm Repository <0>{0}</0> already in use."
#: src/renderer/components/dock/upgrade-chart.store.ts:114 #: src/renderer/components/dock/upgrade-chart.store.ts:114
msgid "Helm Upgrade: {0}" msgid "Helm Upgrade: {0}"
msgstr "Helm Upgrade: {0}" msgstr "Helm Upgrade: {0}"
#: src/renderer/components/+preferences/preferences.tsx:61
msgid "Helm branch <0>{0}</0> already in use"
msgstr "Helm branch <0>{0}</0> already in use"
#: src/renderer/components/+config-secrets/secret-details.tsx:93 #: src/renderer/components/+config-secrets/secret-details.tsx:93
#: src/renderer/components/+workloads-pods/pod-logs-dialog.tsx:215 #: src/renderer/components/+workloads-pods/pod-logs-dialog.tsx:215
#: src/renderer/components/drawer/drawer-param-toggler.tsx:19 #: src/renderer/components/drawer/drawer-param-toggler.tsx:19
@ -1185,7 +1209,7 @@ msgstr "Last seen"
msgid "Last transition time: {lastTransitionTime}" msgid "Last transition time: {lastTransitionTime}"
msgstr "Last transition time: {lastTransitionTime}" msgstr "Last transition time: {lastTransitionTime}"
#: src/renderer/components/+preferences/preferences.tsx:42 #: src/renderer/components/+preferences/preferences.tsx:131
msgid "Lens Global Settings" msgid "Lens Global Settings"
msgstr "Lens Global Settings" msgstr "Lens Global Settings"
@ -1193,7 +1217,7 @@ msgstr "Lens Global Settings"
msgid "Level" msgid "Level"
msgstr "Level" msgstr "Level"
#: src/renderer/components/+preferences/preferences.tsx:23 #: src/renderer/components/+preferences/preferences.tsx:41
msgid "Light" msgid "Light"
msgstr "Light" msgstr "Light"
@ -1461,7 +1485,7 @@ msgstr "Namespaces"
msgid "Namespaces: {0}" msgid "Namespaces: {0}"
msgstr "Namespaces: {0}" msgstr "Namespaces: {0}"
#: src/renderer/components/+preferences/preferences.tsx:71 #: src/renderer/components/+preferences/preferences.tsx:172
msgid "Needed with some corporate proxies that do certificate re-writing." msgid "Needed with some corporate proxies that do certificate re-writing."
msgstr "Needed with some corporate proxies that do certificate re-writing." msgstr "Needed with some corporate proxies that do certificate re-writing."
@ -1731,7 +1755,7 @@ msgstr "Port"
msgid "Ports" msgid "Ports"
msgstr "Ports" msgstr "Ports"
#: src/renderer/components/+preferences/preferences.tsx:37 #: src/renderer/components/+preferences/preferences.tsx:126
msgid "Preferences" msgid "Preferences"
msgstr "Preferences" msgstr "Preferences"
@ -1753,7 +1777,7 @@ msgstr "Privileged"
msgid "Provisioner" msgid "Provisioner"
msgstr "Provisioner" msgstr "Provisioner"
#: src/renderer/components/+preferences/preferences.tsx:64 #: src/renderer/components/+preferences/preferences.tsx:165
msgid "Proxy is used only for non-cluster communication." msgid "Proxy is used only for non-cluster communication."
msgstr "Proxy is used only for non-cluster communication." msgstr "Proxy is used only for non-cluster communication."
@ -1837,6 +1861,7 @@ msgstr "Release: {0}"
msgid "Releases" msgid "Releases"
msgstr "Releases" msgstr "Releases"
#: src/renderer/components/+preferences/preferences.tsx:156
#: src/renderer/components/+user-management-roles-bindings/role-binding-details.tsx:60 #: src/renderer/components/+user-management-roles-bindings/role-binding-details.tsx:60
#: src/renderer/components/cluster-manager/clusters-menu.tsx:60 #: src/renderer/components/cluster-manager/clusters-menu.tsx:60
#: src/renderer/components/cluster-manager/clusters-menu.tsx:64 #: src/renderer/components/cluster-manager/clusters-menu.tsx:64
@ -1878,6 +1903,14 @@ msgstr "Remove selected items ({0})"
msgid "Remove {resourceKind} <0>{resourceName}</0>?" msgid "Remove {resourceKind} <0>{resourceName}</0>?"
msgstr "Remove {resourceKind} <0>{resourceName}</0>?" msgstr "Remove {resourceKind} <0>{resourceName}</0>?"
#: src/renderer/components/+preferences/preferences.tsx:119
msgid "Removing helm branch <0>{0}</0> has failed: {1}"
msgstr "Removing helm branch <0>{0}</0> has failed: {1}"
#: src/renderer/components/+preferences/preferences.tsx:119
#~ msgid "Removing repo <0>{0}</0> has failed: {1}"
#~ msgstr "Removing repo <0>{0}</0> has failed: {1}"
#: src/renderer/components/+custom-resources/certmanager.k8s.io/certificate-details.tsx:62 #: src/renderer/components/+custom-resources/certmanager.k8s.io/certificate-details.tsx:62
msgid "Renew Before" msgid "Renew Before"
msgstr "Renew Before" msgstr "Renew Before"
@ -1894,6 +1927,10 @@ msgstr "Replicas"
msgid "Repo/Name" msgid "Repo/Name"
msgstr "Repo/Name" msgstr "Repo/Name"
#: src/renderer/components/+preferences/preferences.tsx:146
msgid "Repositories"
msgstr "Repositories"
#: src/renderer/components/+apps-helm-charts/helm-charts.tsx:68 #: src/renderer/components/+apps-helm-charts/helm-charts.tsx:68
msgid "Repository" msgid "Repository"
msgstr "Repository" msgstr "Repository"
@ -2136,6 +2173,10 @@ msgstr "Select a quota.."
msgid "Select kubeconfig" msgid "Select kubeconfig"
msgstr "Select kubeconfig" msgstr "Select kubeconfig"
#: src/renderer/components/+preferences/preferences.tsx:88
#~ msgid "Select repository"
#~ msgstr "Select repository"
#: src/renderer/components/+user-management-roles-bindings/add-role-binding-dialog.tsx:188 #: src/renderer/components/+user-management-roles-bindings/add-role-binding-dialog.tsx:188
msgid "Select role.." msgid "Select role.."
msgstr "Select role.." msgstr "Select role.."
@ -2337,11 +2378,11 @@ msgstr "TLS"
msgid "Taints" msgid "Taints"
msgstr "Taints" msgstr "Taints"
#: src/renderer/components/+preferences/preferences.tsx:75 #: src/renderer/components/+preferences/preferences.tsx:176
msgid "Telemetry & Usage Tracking" msgid "Telemetry & Usage Tracking"
msgstr "Telemetry & Usage Tracking" msgstr "Telemetry & Usage Tracking"
#: src/renderer/components/+preferences/preferences.tsx:78 #: src/renderer/components/+preferences/preferences.tsx:179
msgid "Telemetry & usage data is collected to continuously improve the Lens experience." msgid "Telemetry & usage data is collected to continuously improve the Lens experience."
msgstr "Telemetry & usage data is collected to continuously improve the Lens experience." msgstr "Telemetry & usage data is collected to continuously improve the Lens experience."
@ -2373,7 +2414,7 @@ msgstr "This field must contain only lowercase latin characters, numbers and das
msgid "This is the quick launch menu." msgid "This is the quick launch menu."
msgstr "This is the quick launch menu." msgstr "This is the quick launch menu."
#: src/renderer/components/+preferences/preferences.tsx:70 #: src/renderer/components/+preferences/preferences.tsx:171
msgid "This will make Lens to trust ANY certificate authority without any validations." msgid "This will make Lens to trust ANY certificate authority without any validations."
msgstr "This will make Lens to trust ANY certificate authority without any validations." msgstr "This will make Lens to trust ANY certificate authority without any validations."
@ -2416,7 +2457,7 @@ msgstr "Transmit"
msgid "Type" msgid "Type"
msgstr "Type" msgstr "Type"
#: src/renderer/components/+preferences/preferences.tsx:62 #: src/renderer/components/+preferences/preferences.tsx:163
msgid "Type HTTP proxy url (example: http://proxy.acme.org:8080)" msgid "Type HTTP proxy url (example: http://proxy.acme.org:8080)"
msgstr "Type HTTP proxy url (example: http://proxy.acme.org:8080)" msgstr "Type HTTP proxy url (example: http://proxy.acme.org:8080)"
@ -2609,7 +2650,7 @@ msgstr "ago"
msgid "and <0>{tailCount}</0> more" msgid "and <0>{tailCount}</0> more"
msgstr "and <0>{tailCount}</0> more" msgstr "and <0>{tailCount}</0> more"
#: src/renderer/components/+preferences/preferences.tsx:42 #: src/renderer/components/+preferences/preferences.tsx:131
msgid "applicable to all clusters" msgid "applicable to all clusters"
msgstr "applicable to all clusters" msgstr "applicable to all clusters"

View File

@ -112,6 +112,22 @@ msgstr ""
msgid "Add field" msgid "Add field"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:123
#~ msgid "Added repos"
#~ msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:149
msgid "Added repos:"
msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:108
msgid "Adding helm branch <0>{0}</0> has failed: {1}"
msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:108
#~ msgid "Adding repo <0>{0}</0> has failed: {1}"
#~ msgstr ""
#: src/renderer/components/+custom-resources/crd-details.tsx:78 #: src/renderer/components/+custom-resources/crd-details.tsx:78
msgid "Additional Printer Columns" msgid "Additional Printer Columns"
msgstr "" msgstr ""
@ -186,11 +202,11 @@ msgstr ""
msgid "Allow Privilege Escalation" msgid "Allow Privilege Escalation"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:76 #: src/renderer/components/+preferences/preferences.tsx:177
msgid "Allow telemetry & usage tracking" msgid "Allow telemetry & usage tracking"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:68 #: src/renderer/components/+preferences/preferences.tsx:169
msgid "Allow untrusted Certificate Authorities" msgid "Allow untrusted Certificate Authorities"
msgstr "" msgstr ""
@ -385,7 +401,7 @@ msgstr ""
msgid "Capacity" msgid "Capacity"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:67 #: src/renderer/components/+preferences/preferences.tsx:168
msgid "Certificate Trust" msgid "Certificate Trust"
msgstr "" msgstr ""
@ -448,7 +464,7 @@ msgstr ""
msgid "Cluster Issuers" msgid "Cluster Issuers"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:50 #: src/renderer/components/+preferences/preferences.tsx:139
msgid "Color Theme" msgid "Color Theme"
msgstr "" msgstr ""
@ -697,7 +713,7 @@ msgstr ""
msgid "DaemonSets" msgid "DaemonSets"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:22 #: src/renderer/components/+preferences/preferences.tsx:40
msgid "Dark" msgid "Dark"
msgstr "" msgstr ""
@ -760,7 +776,7 @@ msgstr ""
msgid "Disk:" msgid "Disk:"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:72 #: src/renderer/components/+preferences/preferences.tsx:173
msgid "Does not affect cluster communications!" msgid "Does not affect cluster communications!"
msgstr "" msgstr ""
@ -768,7 +784,7 @@ msgstr ""
msgid "Domains" msgid "Domains"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:53 #: src/renderer/components/+preferences/preferences.tsx:142
msgid "Download Mirror" msgid "Download Mirror"
msgstr "" msgstr ""
@ -776,7 +792,7 @@ msgstr ""
msgid "Download file" msgid "Download file"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:54 #: src/renderer/components/+preferences/preferences.tsx:143
msgid "Download mirror for kubectl" msgid "Download mirror for kubectl"
msgstr "" msgstr ""
@ -942,7 +958,7 @@ msgstr ""
msgid "HPA" msgid "HPA"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:61 #: src/renderer/components/+preferences/preferences.tsx:162
msgid "HTTP Proxy" msgid "HTTP Proxy"
msgstr "" msgstr ""
@ -950,7 +966,7 @@ msgstr ""
msgid "HTTP Proxy server. Used for communicating with Kubernetes API." msgid "HTTP Proxy server. Used for communicating with Kubernetes API."
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:56 #: src/renderer/components/+preferences/preferences.tsx:145
msgid "Helm" msgid "Helm"
msgstr "" msgstr ""
@ -962,10 +978,18 @@ msgstr ""
msgid "Helm Install: {repo}/{name}" msgid "Helm Install: {repo}/{name}"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:61
#~ msgid "Helm Repository <0>{0}</0> already in use."
#~ msgstr ""
#: src/renderer/components/dock/upgrade-chart.store.ts:114 #: src/renderer/components/dock/upgrade-chart.store.ts:114
msgid "Helm Upgrade: {0}" msgid "Helm Upgrade: {0}"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:61
msgid "Helm branch <0>{0}</0> already in use"
msgstr ""
#: src/renderer/components/+config-secrets/secret-details.tsx:93 #: src/renderer/components/+config-secrets/secret-details.tsx:93
#: src/renderer/components/+workloads-pods/pod-logs-dialog.tsx:215 #: src/renderer/components/+workloads-pods/pod-logs-dialog.tsx:215
#: src/renderer/components/drawer/drawer-param-toggler.tsx:19 #: src/renderer/components/drawer/drawer-param-toggler.tsx:19
@ -1176,7 +1200,7 @@ msgstr ""
msgid "Last transition time: {lastTransitionTime}" msgid "Last transition time: {lastTransitionTime}"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:42 #: src/renderer/components/+preferences/preferences.tsx:131
msgid "Lens Global Settings" msgid "Lens Global Settings"
msgstr "" msgstr ""
@ -1184,7 +1208,7 @@ msgstr ""
msgid "Level" msgid "Level"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:23 #: src/renderer/components/+preferences/preferences.tsx:41
msgid "Light" msgid "Light"
msgstr "" msgstr ""
@ -1452,7 +1476,7 @@ msgstr ""
msgid "Namespaces: {0}" msgid "Namespaces: {0}"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:71 #: src/renderer/components/+preferences/preferences.tsx:172
msgid "Needed with some corporate proxies that do certificate re-writing." msgid "Needed with some corporate proxies that do certificate re-writing."
msgstr "" msgstr ""
@ -1714,7 +1738,7 @@ msgstr ""
msgid "Ports" msgid "Ports"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:37 #: src/renderer/components/+preferences/preferences.tsx:126
msgid "Preferences" msgid "Preferences"
msgstr "" msgstr ""
@ -1736,7 +1760,7 @@ msgstr ""
msgid "Provisioner" msgid "Provisioner"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:64 #: src/renderer/components/+preferences/preferences.tsx:165
msgid "Proxy is used only for non-cluster communication." msgid "Proxy is used only for non-cluster communication."
msgstr "" msgstr ""
@ -1820,6 +1844,7 @@ msgstr ""
msgid "Releases" msgid "Releases"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:156
#: src/renderer/components/+user-management-roles-bindings/role-binding-details.tsx:60 #: src/renderer/components/+user-management-roles-bindings/role-binding-details.tsx:60
#: src/renderer/components/cluster-manager/clusters-menu.tsx:60 #: src/renderer/components/cluster-manager/clusters-menu.tsx:60
#: src/renderer/components/cluster-manager/clusters-menu.tsx:64 #: src/renderer/components/cluster-manager/clusters-menu.tsx:64
@ -1861,6 +1886,14 @@ msgstr ""
msgid "Remove {resourceKind} <0>{resourceName}</0>?" msgid "Remove {resourceKind} <0>{resourceName}</0>?"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:119
msgid "Removing helm branch <0>{0}</0> has failed: {1}"
msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:119
#~ msgid "Removing repo <0>{0}</0> has failed: {1}"
#~ msgstr ""
#: src/renderer/components/+custom-resources/certmanager.k8s.io/certificate-details.tsx:62 #: src/renderer/components/+custom-resources/certmanager.k8s.io/certificate-details.tsx:62
msgid "Renew Before" msgid "Renew Before"
msgstr "" msgstr ""
@ -1877,6 +1910,10 @@ msgstr ""
msgid "Repo/Name" msgid "Repo/Name"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:146
msgid "Repositories"
msgstr ""
#: src/renderer/components/+apps-helm-charts/helm-charts.tsx:68 #: src/renderer/components/+apps-helm-charts/helm-charts.tsx:68
msgid "Repository" msgid "Repository"
msgstr "" msgstr ""
@ -2119,6 +2156,10 @@ msgstr ""
msgid "Select kubeconfig" msgid "Select kubeconfig"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:88
#~ msgid "Select repository"
#~ msgstr ""
#: src/renderer/components/+user-management-roles-bindings/add-role-binding-dialog.tsx:188 #: src/renderer/components/+user-management-roles-bindings/add-role-binding-dialog.tsx:188
msgid "Select role.." msgid "Select role.."
msgstr "" msgstr ""
@ -2320,11 +2361,11 @@ msgstr ""
msgid "Taints" msgid "Taints"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:75 #: src/renderer/components/+preferences/preferences.tsx:176
msgid "Telemetry & Usage Tracking" msgid "Telemetry & Usage Tracking"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:78 #: src/renderer/components/+preferences/preferences.tsx:179
msgid "Telemetry & usage data is collected to continuously improve the Lens experience." msgid "Telemetry & usage data is collected to continuously improve the Lens experience."
msgstr "" msgstr ""
@ -2356,7 +2397,7 @@ msgstr ""
msgid "This is the quick launch menu." msgid "This is the quick launch menu."
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:70 #: src/renderer/components/+preferences/preferences.tsx:171
msgid "This will make Lens to trust ANY certificate authority without any validations." msgid "This will make Lens to trust ANY certificate authority without any validations."
msgstr "" msgstr ""
@ -2399,7 +2440,7 @@ msgstr ""
msgid "Type" msgid "Type"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:62 #: src/renderer/components/+preferences/preferences.tsx:163
msgid "Type HTTP proxy url (example: http://proxy.acme.org:8080)" msgid "Type HTTP proxy url (example: http://proxy.acme.org:8080)"
msgstr "" msgstr ""
@ -2592,7 +2633,7 @@ msgstr ""
msgid "and <0>{tailCount}</0> more" msgid "and <0>{tailCount}</0> more"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:42 #: src/renderer/components/+preferences/preferences.tsx:131
msgid "applicable to all clusters" msgid "applicable to all clusters"
msgstr "" msgstr ""

View File

@ -113,6 +113,22 @@ msgstr ""
msgid "Add field" msgid "Add field"
msgstr "Добавить поле" msgstr "Добавить поле"
#: src/renderer/components/+preferences/preferences.tsx:123
#~ msgid "Added repos"
#~ msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:149
msgid "Added repos:"
msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:108
msgid "Adding helm branch <0>{0}</0> has failed: {1}"
msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:108
#~ msgid "Adding repo <0>{0}</0> has failed: {1}"
#~ msgstr ""
#: src/renderer/components/+custom-resources/crd-details.tsx:78 #: src/renderer/components/+custom-resources/crd-details.tsx:78
msgid "Additional Printer Columns" msgid "Additional Printer Columns"
msgstr "" msgstr ""
@ -187,11 +203,11 @@ msgstr ""
msgid "Allow Privilege Escalation" msgid "Allow Privilege Escalation"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:76 #: src/renderer/components/+preferences/preferences.tsx:177
msgid "Allow telemetry & usage tracking" msgid "Allow telemetry & usage tracking"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:68 #: src/renderer/components/+preferences/preferences.tsx:169
msgid "Allow untrusted Certificate Authorities" msgid "Allow untrusted Certificate Authorities"
msgstr "" msgstr ""
@ -386,7 +402,7 @@ msgstr "Отмена"
msgid "Capacity" msgid "Capacity"
msgstr "Емкость" msgstr "Емкость"
#: src/renderer/components/+preferences/preferences.tsx:67 #: src/renderer/components/+preferences/preferences.tsx:168
msgid "Certificate Trust" msgid "Certificate Trust"
msgstr "" msgstr ""
@ -453,7 +469,7 @@ msgstr "IP-адрес кластера"
msgid "Cluster Issuers" msgid "Cluster Issuers"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:50 #: src/renderer/components/+preferences/preferences.tsx:139
msgid "Color Theme" msgid "Color Theme"
msgstr "" msgstr ""
@ -702,7 +718,7 @@ msgstr ""
msgid "DaemonSets" msgid "DaemonSets"
msgstr "DaemonSets" msgstr "DaemonSets"
#: src/renderer/components/+preferences/preferences.tsx:22 #: src/renderer/components/+preferences/preferences.tsx:40
msgid "Dark" msgid "Dark"
msgstr "" msgstr ""
@ -765,7 +781,7 @@ msgstr "Диск"
msgid "Disk:" msgid "Disk:"
msgstr "Диск:" msgstr "Диск:"
#: src/renderer/components/+preferences/preferences.tsx:72 #: src/renderer/components/+preferences/preferences.tsx:173
msgid "Does not affect cluster communications!" msgid "Does not affect cluster communications!"
msgstr "" msgstr ""
@ -773,7 +789,7 @@ msgstr ""
msgid "Domains" msgid "Domains"
msgstr "Домены" msgstr "Домены"
#: src/renderer/components/+preferences/preferences.tsx:53 #: src/renderer/components/+preferences/preferences.tsx:142
msgid "Download Mirror" msgid "Download Mirror"
msgstr "" msgstr ""
@ -781,7 +797,7 @@ msgstr ""
msgid "Download file" msgid "Download file"
msgstr "Скачать файл" msgstr "Скачать файл"
#: src/renderer/components/+preferences/preferences.tsx:54 #: src/renderer/components/+preferences/preferences.tsx:143
msgid "Download mirror for kubectl" msgid "Download mirror for kubectl"
msgstr "" msgstr ""
@ -952,7 +968,7 @@ msgstr "Группы"
msgid "HPA" msgid "HPA"
msgstr "HPA" msgstr "HPA"
#: src/renderer/components/+preferences/preferences.tsx:61 #: src/renderer/components/+preferences/preferences.tsx:162
msgid "HTTP Proxy" msgid "HTTP Proxy"
msgstr "" msgstr ""
@ -960,7 +976,7 @@ msgstr ""
msgid "HTTP Proxy server. Used for communicating with Kubernetes API." msgid "HTTP Proxy server. Used for communicating with Kubernetes API."
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:56 #: src/renderer/components/+preferences/preferences.tsx:145
msgid "Helm" msgid "Helm"
msgstr "" msgstr ""
@ -972,10 +988,18 @@ msgstr "Установка Helm чарта"
msgid "Helm Install: {repo}/{name}" msgid "Helm Install: {repo}/{name}"
msgstr "Helm установка: {repo}/{name}" msgstr "Helm установка: {repo}/{name}"
#: src/renderer/components/+preferences/preferences.tsx:61
#~ msgid "Helm Repository <0>{0}</0> already in use."
#~ msgstr ""
#: src/renderer/components/dock/upgrade-chart.store.ts:114 #: src/renderer/components/dock/upgrade-chart.store.ts:114
msgid "Helm Upgrade: {0}" msgid "Helm Upgrade: {0}"
msgstr "Helm обновление: {0}" msgstr "Helm обновление: {0}"
#: src/renderer/components/+preferences/preferences.tsx:61
msgid "Helm branch <0>{0}</0> already in use"
msgstr ""
#: src/renderer/components/+config-secrets/secret-details.tsx:93 #: src/renderer/components/+config-secrets/secret-details.tsx:93
#: src/renderer/components/+workloads-pods/pod-logs-dialog.tsx:215 #: src/renderer/components/+workloads-pods/pod-logs-dialog.tsx:215
#: src/renderer/components/drawer/drawer-param-toggler.tsx:19 #: src/renderer/components/drawer/drawer-param-toggler.tsx:19
@ -1186,7 +1210,7 @@ msgstr "Увиденно в последний раз"
msgid "Last transition time: {lastTransitionTime}" msgid "Last transition time: {lastTransitionTime}"
msgstr "Последнее изменение: {lastTransitionTime}" msgstr "Последнее изменение: {lastTransitionTime}"
#: src/renderer/components/+preferences/preferences.tsx:42 #: src/renderer/components/+preferences/preferences.tsx:131
msgid "Lens Global Settings" msgid "Lens Global Settings"
msgstr "" msgstr ""
@ -1194,7 +1218,7 @@ msgstr ""
msgid "Level" msgid "Level"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:23 #: src/renderer/components/+preferences/preferences.tsx:41
msgid "Light" msgid "Light"
msgstr "" msgstr ""
@ -1462,7 +1486,7 @@ msgstr "Namespaces"
msgid "Namespaces: {0}" msgid "Namespaces: {0}"
msgstr "Namespaces: {0}" msgstr "Namespaces: {0}"
#: src/renderer/components/+preferences/preferences.tsx:71 #: src/renderer/components/+preferences/preferences.tsx:172
msgid "Needed with some corporate proxies that do certificate re-writing." msgid "Needed with some corporate proxies that do certificate re-writing."
msgstr "" msgstr ""
@ -1732,7 +1756,7 @@ msgstr ""
msgid "Ports" msgid "Ports"
msgstr "Порты" msgstr "Порты"
#: src/renderer/components/+preferences/preferences.tsx:37 #: src/renderer/components/+preferences/preferences.tsx:126
msgid "Preferences" msgid "Preferences"
msgstr "" msgstr ""
@ -1754,7 +1778,7 @@ msgstr ""
msgid "Provisioner" msgid "Provisioner"
msgstr "Комиссия" msgstr "Комиссия"
#: src/renderer/components/+preferences/preferences.tsx:64 #: src/renderer/components/+preferences/preferences.tsx:165
msgid "Proxy is used only for non-cluster communication." msgid "Proxy is used only for non-cluster communication."
msgstr "" msgstr ""
@ -1838,6 +1862,7 @@ msgstr "Установка: {0}"
msgid "Releases" msgid "Releases"
msgstr "Релизы" msgstr "Релизы"
#: src/renderer/components/+preferences/preferences.tsx:156
#: src/renderer/components/+user-management-roles-bindings/role-binding-details.tsx:60 #: src/renderer/components/+user-management-roles-bindings/role-binding-details.tsx:60
#: src/renderer/components/cluster-manager/clusters-menu.tsx:60 #: src/renderer/components/cluster-manager/clusters-menu.tsx:60
#: src/renderer/components/cluster-manager/clusters-menu.tsx:64 #: src/renderer/components/cluster-manager/clusters-menu.tsx:64
@ -1879,6 +1904,14 @@ msgstr "Удалить выбранные элементы ({0})"
msgid "Remove {resourceKind} <0>{resourceName}</0>?" msgid "Remove {resourceKind} <0>{resourceName}</0>?"
msgstr "Удалить {resourceKind} <0>{resourceName}</0>?" msgstr "Удалить {resourceKind} <0>{resourceName}</0>?"
#: src/renderer/components/+preferences/preferences.tsx:119
msgid "Removing helm branch <0>{0}</0> has failed: {1}"
msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:119
#~ msgid "Removing repo <0>{0}</0> has failed: {1}"
#~ msgstr ""
#: src/renderer/components/+custom-resources/certmanager.k8s.io/certificate-details.tsx:62 #: src/renderer/components/+custom-resources/certmanager.k8s.io/certificate-details.tsx:62
msgid "Renew Before" msgid "Renew Before"
msgstr "Обновить до" msgstr "Обновить до"
@ -1895,6 +1928,10 @@ msgstr "Реплики"
msgid "Repo/Name" msgid "Repo/Name"
msgstr "Репозиторий/Имя" msgstr "Репозиторий/Имя"
#: src/renderer/components/+preferences/preferences.tsx:146
msgid "Repositories"
msgstr ""
#: src/renderer/components/+apps-helm-charts/helm-charts.tsx:68 #: src/renderer/components/+apps-helm-charts/helm-charts.tsx:68
msgid "Repository" msgid "Repository"
msgstr "Репозиторий" msgstr "Репозиторий"
@ -2137,6 +2174,10 @@ msgstr "Выберите квоту..."
msgid "Select kubeconfig" msgid "Select kubeconfig"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:88
#~ msgid "Select repository"
#~ msgstr ""
#: src/renderer/components/+user-management-roles-bindings/add-role-binding-dialog.tsx:188 #: src/renderer/components/+user-management-roles-bindings/add-role-binding-dialog.tsx:188
msgid "Select role.." msgid "Select role.."
msgstr "Выбрать роль.." msgstr "Выбрать роль.."
@ -2338,11 +2379,11 @@ msgstr "TLS"
msgid "Taints" msgid "Taints"
msgstr "Метки блокировки" msgstr "Метки блокировки"
#: src/renderer/components/+preferences/preferences.tsx:75 #: src/renderer/components/+preferences/preferences.tsx:176
msgid "Telemetry & Usage Tracking" msgid "Telemetry & Usage Tracking"
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:78 #: src/renderer/components/+preferences/preferences.tsx:179
msgid "Telemetry & usage data is collected to continuously improve the Lens experience." msgid "Telemetry & usage data is collected to continuously improve the Lens experience."
msgstr "" msgstr ""
@ -2374,7 +2415,7 @@ msgstr "Это поле может содержать только латинс
msgid "This is the quick launch menu." msgid "This is the quick launch menu."
msgstr "" msgstr ""
#: src/renderer/components/+preferences/preferences.tsx:70 #: src/renderer/components/+preferences/preferences.tsx:171
msgid "This will make Lens to trust ANY certificate authority without any validations." msgid "This will make Lens to trust ANY certificate authority without any validations."
msgstr "" msgstr ""
@ -2417,7 +2458,7 @@ msgstr "Транзит"
msgid "Type" msgid "Type"
msgstr "Тип" msgstr "Тип"
#: src/renderer/components/+preferences/preferences.tsx:62 #: src/renderer/components/+preferences/preferences.tsx:163
msgid "Type HTTP proxy url (example: http://proxy.acme.org:8080)" msgid "Type HTTP proxy url (example: http://proxy.acme.org:8080)"
msgstr "" msgstr ""
@ -2610,7 +2651,7 @@ msgstr "тому назад"
msgid "and <0>{tailCount}</0> more" msgid "and <0>{tailCount}</0> more"
msgstr "и <0>{tailCount}</0> ещё" msgstr "и <0>{tailCount}</0> ещё"
#: src/renderer/components/+preferences/preferences.tsx:42 #: src/renderer/components/+preferences/preferences.tsx:131
msgid "applicable to all clusters" msgid "applicable to all clusters"
msgstr "" msgstr ""

View File

@ -1,11 +1,28 @@
import request from "request" import request from "request"
import requestPromise from "request-promise-native"
import { userStore } from "./user-store" import { userStore } from "./user-store"
export function globalRequestOpts(requestOpts: request.Options) { // todo: get rid of "request" (deprecated)
// https://github.com/lensapp/lens/issues/459
function getDefaultRequestOpts(): Partial<request.Options> {
const { httpsProxy, allowUntrustedCAs } = userStore.preferences const { httpsProxy, allowUntrustedCAs } = userStore.preferences
if (httpsProxy) { return {
requestOpts.proxy = httpsProxy proxy: httpsProxy || undefined,
rejectUnauthorized: !allowUntrustedCAs,
} }
requestOpts.rejectUnauthorized = !allowUntrustedCAs; }
return requestOpts
/**
* @deprecated
*/
export function customRequest(opts: request.Options) {
return request.defaults(getDefaultRequestOpts())(opts)
}
/**
* @deprecated
*/
export function customRequestPromise(opts: requestPromise.Options) {
return requestPromise.defaults(getDefaultRequestOpts())(opts)
} }

View File

@ -13,6 +13,12 @@ export enum ThemeType {
DARK = "dark", DARK = "dark",
} }
export interface Theme {
name: string;
type: ThemeType;
colors?: Record<string, string>;
}
export interface UserStoreModel { export interface UserStoreModel {
lastSeenAppVersion: string; lastSeenAppVersion: string;
seenContexts: string[]; seenContexts: string[];

View File

@ -6,12 +6,13 @@ import { promiseExec } from "../promise-exec"
import { helmCli } from "./helm-cli" import { helmCli } from "./helm-cli"
type CachedYaml = { type CachedYaml = {
entries: any; entries: any; // todo: types
} }
export class HelmChartManager { export class HelmChartManager {
protected cache: any protected cache: any = {}
protected repo: HelmRepo protected repo: HelmRepo
constructor(repo: HelmRepo){ constructor(repo: HelmRepo){
this.cache = HelmRepoManager.cache this.cache = HelmRepoManager.cache
this.repo = repo this.repo = repo

View File

@ -1,28 +1,51 @@
import fs from "fs"; import yaml from "js-yaml";
import logger from "../logger"; import { readFile } from "fs-extra";
import * as yaml from "js-yaml";
import { promiseExec } from "../promise-exec"; import { promiseExec } from "../promise-exec";
import { helmCli } from "./helm-cli"; import { helmCli } from "./helm-cli";
import { Singleton } from "../../common/utils/singleton"; import { Singleton } from "../../common/utils/singleton";
import { customRequestPromise } from "../../common/request";
import orderBy from "lodash/orderBy";
import logger from "../logger";
export type HelmEnv = Record<string, string> & { export type HelmEnv = Record<string, string> & {
HELM_REPOSITORY_CACHE?: string; HELM_REPOSITORY_CACHE?: string;
HELM_REPOSITORY_CONFIG?: string; HELM_REPOSITORY_CONFIG?: string;
} }
export type HelmRepo = { export interface HelmRepoConfig {
repositories: HelmRepo[]
}
export interface HelmRepo {
name: string; name: string;
url: string; url: string;
cacheFilePath?: string; cacheFilePath?: string
caFile?: string,
certFile?: string,
insecure_skip_tls_verify?: boolean,
keyFile?: string,
username?: string,
password?: string,
} }
export class HelmRepoManager extends Singleton { export class HelmRepoManager extends Singleton {
static cache = {} static cache = {} // todo: remove implicit updates in helm-chart-manager.ts
protected repos: HelmRepo[];
protected helmEnv: HelmEnv protected helmEnv: HelmEnv
protected initialized: boolean protected initialized: boolean
public async init() { async loadAvailableRepos(): Promise<HelmRepo[]> {
const res = await customRequestPromise({
uri: "https://hub.helm.sh/assets/js/repos.json",
json: true,
resolveWithFullResponse: true,
timeout: 10000,
});
return orderBy<HelmRepo>(res.body.data, repo => repo.name);
}
async init() {
await helmCli.ensureBinary(); await helmCli.ensureBinary();
if (!this.initialized) { if (!this.initialized) {
this.helmEnv = await this.parseHelmEnv() this.helmEnv = await this.parseHelmEnv()
@ -47,60 +70,57 @@ export class HelmRepoManager extends Singleton {
return env return env
} }
public async repositories(): Promise<Array<HelmRepo>> { public async repositories(): Promise<HelmRepo[]> {
if (!this.initialized) { if (!this.initialized) {
await this.init() await this.init()
} }
const repositoryFilePath = this.helmEnv.HELM_REPOSITORY_CONFIG
const repoFile = await fs.promises.readFile(repositoryFilePath, 'utf8').catch(async (error) => {
return null
})
if (!repoFile) {
await this.addRepo({ name: "stable", url: "https://kubernetes-charts.storage.googleapis.com/" })
return await this.repositories()
}
try { try {
const repositories = yaml.safeLoad(repoFile) const repoConfigFile = this.helmEnv.HELM_REPOSITORY_CONFIG;
const result = repositories['repositories'].map((repository: HelmRepo) => { const { repositories }: HelmRepoConfig = await readFile(repoConfigFile, 'utf8')
return { .then((yamlContent: string) => yaml.safeLoad(yamlContent))
name: repository.name, .catch(() => ({
url: repository.url, repositories: []
cacheFilePath: `${this.helmEnv.HELM_REPOSITORY_CACHE}/${repository['name']}-index.yaml` }));
} if (!repositories.length) {
}); await this.addRepo({ name: "stable", url: "https://kubernetes-charts.storage.googleapis.com/" });
if (result.length == 0) { return await this.repositories();
await this.addRepo({ name: "stable", url: "https://kubernetes-charts.storage.googleapis.com/" })
return await this.repositories()
} }
return result return repositories.map(repo => ({
...repo,
cacheFilePath: `${this.helmEnv.HELM_REPOSITORY_CACHE}/${repo.name}-index.yaml`
}));
} catch (error) { } catch (error) {
logger.debug(error) logger.error(`[HELM]: repositories listing error "${error}"`)
return [] return []
} }
} }
public async repository(name: string) { public async repository(name: string) {
const repositories = await this.repositories() const repositories = await this.repositories()
return repositories.find((repo: HelmRepo) => { return repositories.find(repo => repo.name == name);
return repo.name == name
})
} }
public async update() { public async update() {
const helm = await helmCli.binaryPath() const helm = await helmCli.binaryPath()
logger.debug(`${helm} repo update`)
const { stdout } = await promiseExec(`"${helm}" repo update`).catch((error) => { const { stdout } = await promiseExec(`"${helm}" repo update`).catch((error) => {
return { stdout: error.stdout } return { stdout: error.stdout }
}) })
return stdout return stdout
} }
public async addRepo(repository: HelmRepo) { public async addRepo({ name, url }: HelmRepo) {
logger.info(`[HELM]: adding repo "${name}" from ${url}`);
const helm = await helmCli.binaryPath() const helm = await helmCli.binaryPath()
logger.debug(`${helm} repo add ${repository.name} ${repository.url}`) const { stdout } = await promiseExec(`"${helm}" repo add ${name} ${url}`).catch((error) => {
throw(error.stderr)
})
return stdout
}
const { stdout } = await promiseExec(`"${helm}" repo add ${repository.name} ${repository.url}`).catch((error) => { public async removeRepo({ name, url }: HelmRepo): Promise<string> {
logger.info(`[HELM]: removing repo "${name}" from ${url}`);
const helm = await helmCli.binaryPath()
const { stdout, stderr } = await promiseExec(`"${helm}" repo remove ${name}`).catch((error) => {
throw(error.stderr) throw(error.stderr)
}) })
return stdout return stdout

View File

@ -1,15 +1,15 @@
import { app, remote } from "electron" import { app, remote } from "electron"
import path from "path" import path from "path"
import fs from "fs" import fs from "fs"
import request from "request" import { promiseExec } from "./promise-exec"
import { promiseExec} from "./promise-exec"
import logger from "./logger" import logger from "./logger"
import { ensureDir, pathExists } from "fs-extra" import { ensureDir, pathExists } from "fs-extra"
import { globalRequestOpts } from "../common/request"
import * as lockFile from "proper-lockfile" import * as lockFile from "proper-lockfile"
import { helmCli } from "./helm/helm-cli" import { helmCli } from "./helm/helm-cli"
import { userStore } from "../common/user-store" import { userStore } from "../common/user-store"
import { getBundledKubectlVersion} from "../common/utils/app-version" import { customRequest } from "../common/request";
import { getBundledKubectlVersion } from "../common/utils/app-version"
import { isDevelopment, isWindows } from "../common/vars";
const bundledVersion = getBundledKubectlVersion() const bundledVersion = getBundledKubectlVersion()
const kubectlMap: Map<string, string> = new Map([ const kubectlMap: Map<string, string> = new Map([
@ -32,18 +32,18 @@ const packageMirrors: Map<string, string> = new Map([
["china", "https://mirror.azure.cn/kubernetes/kubectl"] ["china", "https://mirror.azure.cn/kubernetes/kubectl"]
]) ])
let bundledPath: string
const initScriptVersionString = "# lens-initscript v3\n" const initScriptVersionString = "# lens-initscript v3\n"
const isDevelopment = process.env.NODE_ENV !== "production" if (isDevelopment) {
let bundledPath: string = null
if(isDevelopment) {
bundledPath = path.join(process.cwd(), "binaries", "client", process.platform, process.arch, "kubectl") bundledPath = path.join(process.cwd(), "binaries", "client", process.platform, process.arch, "kubectl")
} else { } else {
bundledPath = path.join(process.resourcesPath, process.arch, "kubectl") bundledPath = path.join(process.resourcesPath, process.arch, "kubectl")
} }
if(process.platform === "win32") bundledPath = `${bundledPath}.exe` if (isWindows) {
bundledPath = `${bundledPath}.exe`
}
export class Kubectl { export class Kubectl {
public kubectlVersion: string public kubectlVersion: string
@ -52,7 +52,7 @@ export class Kubectl {
protected path: string protected path: string
protected dirname: string protected dirname: string
static get kubectlDir(){ static get kubectlDir() {
return path.join((app || remote.app).getPath("userData"), "binaries", "kubectl") return path.join((app || remote.app).getPath("userData"), "binaries", "kubectl")
} }
@ -62,7 +62,7 @@ export class Kubectl {
// Returns the single bundled Kubectl instance // Returns the single bundled Kubectl instance
public static bundled() { public static bundled() {
if(!Kubectl.bundledInstance) Kubectl.bundledInstance = new Kubectl(Kubectl.bundledKubectlVersion) if (!Kubectl.bundledInstance) Kubectl.bundledInstance = new Kubectl(Kubectl.bundledKubectlVersion)
return Kubectl.bundledInstance return Kubectl.bundledInstance
} }
@ -71,7 +71,7 @@ export class Kubectl {
const minorVersion = versionParts[1] const minorVersion = versionParts[1]
/* minorVersion is the first two digits of kube server version /* minorVersion is the first two digits of kube server version
if the version map includes that, use that version, if not, fallback to the exact x.y.z of kube version */ if the version map includes that, use that version, if not, fallback to the exact x.y.z of kube version */
if(kubectlMap.has(minorVersion)) { if (kubectlMap.has(minorVersion)) {
this.kubectlVersion = kubectlMap.get(minorVersion) this.kubectlVersion = kubectlMap.get(minorVersion)
logger.debug("Set kubectl version " + this.kubectlVersion + " for cluster version " + clusterVersion + " using version map") logger.debug("Set kubectl version " + this.kubectlVersion + " for cluster version " + clusterVersion + " using version map")
} else { } else {
@ -81,16 +81,16 @@ export class Kubectl {
let arch = null let arch = null
if(process.arch == "x64") { if (process.arch == "x64") {
arch = "amd64" arch = "amd64"
} else if(process.arch == "x86" || process.arch == "ia32") { } else if (process.arch == "x86" || process.arch == "ia32") {
arch = "386" arch = "386"
} else { } else {
arch = process.arch arch = process.arch
} }
const platformName = process.platform === "win32" ? "windows" : process.platform const platformName = isWindows ? "windows" : process.platform
const binaryName = process.platform === "win32" ? "kubectl.exe" : "kubectl" const binaryName = isWindows ? "kubectl.exe" : "kubectl"
this.url = `${this.getDownloadMirror()}/v${this.kubectlVersion}/bin/${platformName}/${arch}/${binaryName}` this.url = `${this.getDownloadMirror()}/v${this.kubectlVersion}/bin/${platformName}/${arch}/${binaryName}`
@ -102,7 +102,7 @@ export class Kubectl {
try { try {
await this.ensureKubectl() await this.ensureKubectl()
return this.path return this.path
} catch(err) { } catch (err) {
logger.error("Failed to ensure kubectl, fallback to the bundled version") logger.error("Failed to ensure kubectl, fallback to the bundled version")
logger.error(err) logger.error(err)
return Kubectl.bundledKubectlPath return Kubectl.bundledKubectlPath
@ -113,7 +113,7 @@ export class Kubectl {
try { try {
await this.ensureKubectl() await this.ensureKubectl()
return this.dirname return this.dirname
} catch(err) { } catch (err) {
logger.error(err) logger.error(err)
return "" return ""
} }
@ -138,8 +138,7 @@ export class Kubectl {
return true return true
} }
logger.error(`Local kubectl is version ${version}, expected ${this.kubectlVersion}, unlinking`) logger.error(`Local kubectl is version ${version}, expected ${this.kubectlVersion}, unlinking`)
} } catch (err) {
catch(err) {
logger.error(`Local kubectl failed to run properly (${err.message}), unlinking`) logger.error(`Local kubectl failed to run properly (${err.message}), unlinking`)
} }
await fs.promises.unlink(this.path) await fs.promises.unlink(this.path)
@ -148,7 +147,7 @@ export class Kubectl {
} }
protected async checkBundled(): Promise<boolean> { protected async checkBundled(): Promise<boolean> {
if(this.kubectlVersion === Kubectl.bundledKubectlVersion) { if (this.kubectlVersion === Kubectl.bundledKubectlVersion) {
try { try {
const exist = await pathExists(this.path) const exist = await pathExists(this.path)
if (!exist) { if (!exist) {
@ -156,7 +155,7 @@ export class Kubectl {
await fs.promises.chmod(this.path, 0o755) await fs.promises.chmod(this.path, 0o755)
} }
return true return true
} catch(err) { } catch (err) {
logger.error("Could not copy the bundled kubectl to app-data: " + err) logger.error("Could not copy the bundled kubectl to app-data: " + err)
return false return false
} }
@ -171,10 +170,15 @@ export class Kubectl {
logger.debug(`Acquired a lock for ${this.kubectlVersion}`) logger.debug(`Acquired a lock for ${this.kubectlVersion}`)
const bundled = await this.checkBundled() const bundled = await this.checkBundled()
const isValid = await this.checkBinary(!bundled) const isValid = await this.checkBinary(!bundled)
if(!isValid) { if (!isValid) {
await this.downloadKubectl().catch((error) => { logger.error(error) }); await this.downloadKubectl().catch((error) => {
logger.error(error)
});
} }
await this.writeInitScripts().catch((error) => { logger.error("Failed to write init scripts"); logger.error(error) }) await this.writeInitScripts().catch((error) => {
logger.error("Failed to write init scripts");
logger.error(error)
})
logger.debug(`Releasing lock for ${this.kubectlVersion}`) logger.debug(`Releasing lock for ${this.kubectlVersion}`)
release() release()
return true return true
@ -190,10 +194,10 @@ export class Kubectl {
logger.info(`Downloading kubectl ${this.kubectlVersion} from ${this.url} to ${this.path}`) logger.info(`Downloading kubectl ${this.kubectlVersion} from ${this.url} to ${this.path}`)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const stream = request({ const stream = customRequest({
url: this.url,
gzip: true, gzip: true,
...this.getRequestOpts() });
})
const file = fs.createWriteStream(this.path) const file = fs.createWriteStream(this.path)
stream.on("complete", () => { stream.on("complete", () => {
logger.debug("kubectl binary download finished") logger.debug("kubectl binary download finished")
@ -215,7 +219,7 @@ export class Kubectl {
protected async scriptIsLatest(scriptPath: string) { protected async scriptIsLatest(scriptPath: string) {
const scriptExists = await pathExists(scriptPath) const scriptExists = await pathExists(scriptPath)
if(!scriptExists) return false if (!scriptExists) return false
try { try {
const filehandle = await fs.promises.open(scriptPath, 'r') const filehandle = await fs.promises.open(scriptPath, 'r')
@ -234,7 +238,7 @@ export class Kubectl {
const fsPromises = fs.promises; const fsPromises = fs.promises;
const bashScriptPath = path.join(this.dirname, '.bash_set_path') const bashScriptPath = path.join(this.dirname, '.bash_set_path')
const bashScriptIsLatest = await this.scriptIsLatest(bashScriptPath) const bashScriptIsLatest = await this.scriptIsLatest(bashScriptPath)
if(!bashScriptIsLatest) { if (!bashScriptIsLatest) {
let bashScript = "" + initScriptVersionString let bashScript = "" + initScriptVersionString
bashScript += "tempkubeconfig=\"$KUBECONFIG\"\n" bashScript += "tempkubeconfig=\"$KUBECONFIG\"\n"
bashScript += "test -f \"/etc/profile\" && . \"/etc/profile\"\n" bashScript += "test -f \"/etc/profile\" && . \"/etc/profile\"\n"
@ -253,7 +257,7 @@ export class Kubectl {
const zshScriptPath = path.join(this.dirname, '.zlogin') const zshScriptPath = path.join(this.dirname, '.zlogin')
const zshScriptIsLatest = await this.scriptIsLatest(zshScriptPath) const zshScriptIsLatest = await this.scriptIsLatest(zshScriptPath)
if(!zshScriptIsLatest) { if (!zshScriptIsLatest) {
let zshScript = "" + initScriptVersionString let zshScript = "" + initScriptVersionString
zshScript += "tempkubeconfig=\"$KUBECONFIG\"\n" zshScript += "tempkubeconfig=\"$KUBECONFIG\"\n"
@ -280,12 +284,6 @@ export class Kubectl {
} }
} }
protected getRequestOpts() {
return globalRequestOpts({
url: this.url
})
}
protected getDownloadMirror() { protected getDownloadMirror() {
const mirror = packageMirrors.get(userStore.preferences.downloadMirror) const mirror = packageMirrors.get(userStore.preferences.downloadMirror)
if (mirror) { if (mirror) {

View File

@ -1,259 +0,0 @@
<template>
<div class="content">
<ClosePageButton />
<div class="container-fluid lens-preferences">
<div class="header sticky-top">
<h2>Preferences</h2>
</div>
<div class="row">
<div class="col-3" />
<div ref="content" class="global-settings col-6">
<h2>Color Theme</h2>
<b-form-group
label="Cluster Color theme:"
label-for="input-color-theme"
>
<b-form-select
id="input-color-theme"
v-model="preferences.colorTheme"
@change="onSave"
:options="colorThemeOptions"
/>
</b-form-group>
</div>
<div class="col-3" />
</div>
<div class="row">
<div class="col-3" />
<div ref="content" class="global-settings col-6">
<h2>Download Mirror</h2>
<b-form-group
label="Download mirror for kubectl:"
label-for="input-download-mirror"
>
<b-form-select
id="input-download-mirror"
v-model="preferences.downloadMirror"
@change="onSave"
:options="downloadMirrorOptions"
/>
</b-form-group>
</div>
<div class="col-3" />
</div>
<div class="row">
<div class="col-3" />
<div ref="content" class="global-settings col-6">
<h2>Helm</h2>
<b-form-group
label="Repositories:"
label-for="textarea-helm-repositories"
>
<b-input-group>
<b-form-select
:options="hubRepositories"
v-model="selectedHubRepo"
>
<template v-slot:first>
<option value="">
Select Helm repository
</option>
</template>
</b-form-select>
<b-input-group-append>
<b-button :disabled="!selectedHubRepo" @click="addHubRepo" variant="primary">
Add <b-spinner small v-if="isHelmProcessing" label="Small Spinner" />
</b-button>
</b-input-group-append>
</b-input-group>
</b-form-group>
<b-list-group>
<b-list-group-item v-for="repo in helmRepos" :key="repo.name">
<span v-b-tooltip.hover v-b-tooltip.right :title="repo.url">{{ repo.name }}</span>
<button @click="removeRepo(repo)" :data-repo="repo.name" class="close">
<i class="material-icons">delete</i>
</button>
</b-list-group-item>
</b-list-group>
</div>
<div class="col-3" />
</div>
<div class="row">
<div class="col-3" />
<div ref="content" class="global-settings col-6">
<h2>HTTP Proxy</h2>
<b-form-group
label="Proxy URL:"
label-for="input-https-proxy"
description="Proxy is used only for non-cluster communication."
>
<b-form-input
id="input-https-proxy"
v-model="preferences.httpsProxy"
trim
@blur="onSave"
placeholder="Type HTTP proxy url (example: http://proxy.acme.org:8080)"
/>
</b-form-group>
<h2>Certificate Trust</h2>
<b-form-group
label-for="checkbox-allow-untrusted-cas"
description="This will make Lens to trust ANY certificate authority without any validations. Needed with some corporate proxies that do certificate re-writing. Does not affect cluster communications!"
>
<b-form-checkbox
id="checkbox-allow-untrusted-cas"
switch
v-model="preferences.allowUntrustedCAs"
@input="onSave"
>
Allow untrusted Certificate Authorities
</b-form-checkbox>
</b-form-group>
<h2>Telemetry & Usage Tracking</h2>
<b-form-group
label-for="checkbox-allow-telemetry"
description="Telemetry & usage data is collected to continuously improve the Lens experience."
>
<b-form-checkbox
id="checkbox-allow-telemetry"
switch
v-model="preferences.allowTelemetry"
@input="onSave"
>
Allow telemetry & usage tracking
</b-form-checkbox>
</b-form-group>
</div>
<div class="col-3" />
</div>
</div>
</div>
</template>
<script>
import request from 'request-promise-native'
import { globalRequestOpts } from "../../../common/request"
import ClosePageButton from "@/_vue/components/common/ClosePageButton";
export default {
name: 'PreferencesPage',
components: {
ClosePageButton
},
data(){
return {
hubRepositories: [],
selectedHubRepo: "",
colorThemeOptions: [
{ value: "dark", text: "Dark" },
{ value: "light", text: "Light" },
],
downloadMirrorOptions: [
{ value: "default", text: "Default (Google)" },
{ value: "china", text: "China (Azure)" },
],
isHelmProcessing: null,
}
},
computed: {
helmRepos: function() {
return this.$store.getters.repos;
},
preferences: function() {
return this.$store.getters.preferences;
},
},
methods: {
onSave: function() {
this.$store.commit("savePreferences", this.preferences);
},
request: async function(opts) {
const o = Object.assign({
timeout: 10000,
headers: {},
resolveWithFullResponse: true,
json: true
}, globalRequestOpts(opts))
return await request(o)
},
repoCompare: function( a, b ) {
if ( a.name < b.name ){
return -1;
}
if ( a.name > b.name ){
return 1;
}
return 0;
},
addHubRepo: async function() {
if(!this.selectedHubRepo || this.selectedHubRepo === "") {
return
}
this.isHelmProcessing = true
const [name, url ] = this.selectedHubRepo.split("|")
await this.$store.dispatch('addHelmRepo', { name, url })
this.selectedHubRepo = ""
this.isHelmProcessing = false
},
removeRepo: async function(repo) {
await this.$store.dispatch('removeHelmRepo', repo)
},
loadHubRepositories: async function() {
const res = await this.request({ uri: "https://hub.helm.sh/assets/js/repos.json"}).catch((error) => { this.hubRepositories = [] })
this.hubRepositories = res.body.data.sort(this.repoCompare).map((repo) => {
return {
text: repo.name,
value: repo.name+"|"+repo.url
}
})
}
},
created() {
this.$store.dispatch('refreshHelmRepos')
},
mounted: async function() {
this.$store.commit("hideMenu");
this.loadHubRepositories()
},
destroyed: function() {
this.$store.commit("showMenu");
}
}
</script>
<style lang="scss" scoped>
#app > .main-view > .content {
left: 70px;
}
.lens-preferences {
height: 100%;
overflow-y: scroll;
& input {
background-color: #252729 !important;
border: 0px !important;
color: #87909c !important;
}
.header {
padding-top: 15px;
}
.close {
text-shadow: none;
}
.list-group-item {
background-color: #252729 !important;
color: #87909c !important;
}
& i {
color: #87909c !important;
}
}
.global-settings {
padding-top: 0.75em;
}
</style>

View File

@ -1,9 +1,23 @@
.Preferences { .Preferences {
--flex-gap: #{$padding};
h2 { h2 {
&:not(:first-child) { &:not(:first-child) {
margin-top: $padding * 3; margin-top: $padding * 3;
} }
} }
.info-block {
--flex-gap: #{$padding};
}
.repos {
--flex-gap: #{$padding};
> .title {
font-style: italic;
}
.Badge {
margin: $padding / 2;
}
}
} }

View File

@ -1,45 +1,121 @@
import "./preferences.scss" import "./preferences.scss"
import React, { Fragment } from "react"; import React, { Fragment } from "react";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { action, computed, observable } from "mobx";
import { t, Trans } from "@lingui/macro"; import { t, Trans } from "@lingui/macro";
import { _i18n } from "../../i18n"; import { _i18n } from "../../i18n";
import { WizardLayout } from "../layout/wizard-layout"; import { WizardLayout } from "../layout/wizard-layout";
import { Icon } from "../icon"; import { Icon } from "../icon";
import { Select, SelectOption } from "../select"; import { Select, SelectOption } from "../select";
import { ThemeType, userStore } from "../../../common/user-store"; import { userStore } from "../../../common/user-store";
import { HelmRepo, repoManager } from "../../../main/helm/helm-repo-manager";
import { Input } from "../input"; import { Input } from "../input";
import { Checkbox } from "../checkbox"; import { Checkbox } from "../checkbox";
import { Notifications } from "../notifications";
type ThemeSelectOption = SelectOption & { type: ThemeType } import { Badge } from "../badge";
import { Spinner } from "../spinner";
@observer @observer
export class Preferences extends React.Component { export class Preferences extends React.Component {
themeOptions: ThemeSelectOption[] = [ @observable helmLoading = false;
{ value: "kontena-dark", label: <Trans>Dark</Trans>, type: ThemeType.DARK }, @observable helmUpdating = false;
{ value: "kontena-light", label: <Trans>Light</Trans>, type: ThemeType.LIGHT }, @observable helmRepos: HelmRepo[] = [];
@observable helmAddedRepos = observable.map<string, HelmRepo>();
@observable themeOptions: SelectOption<string>[] = [
{ value: "kontena-dark", label: <Trans>Dark</Trans> },
{ value: "kontena-light", label: <Trans>Light</Trans> },
] ]
downloadMirrorOptions: SelectOption[] = [ @observable downloadMirrorOptions: SelectOption<string>[] = [
{ value: "default", label: "Default (Google)" }, { value: "default", label: "Default (Google)" },
{ value: "china", label: "China (Azure)" }, { value: "china", label: "China (Azure)" },
] ]
onThemeChange = ({ value }: ThemeSelectOption) => { @computed get helmOptions(): SelectOption<HelmRepo>[] {
return this.helmRepos.map(repo => ({
value: repo,
label: repo.name,
}))
}
async componentDidMount() {
await this.loadHelmRepos();
}
@action
async loadHelmRepos() {
this.helmLoading = true;
try {
if (!this.helmRepos.length) {
this.helmRepos = await repoManager.loadAvailableRepos(); // via https://helm.sh
}
const repos = await repoManager.repositories(); // via helm-cli
this.helmAddedRepos.clear();
repos.forEach(repo => this.helmAddedRepos.set(repo.name, repo));
} catch (err) {
Notifications.error(err);
}
this.helmLoading = false;
}
async addRepo(repo: HelmRepo) {
try {
await repoManager.addRepo(repo);
this.helmAddedRepos.set(repo.name, repo);
} catch (err) {
Notifications.error(<Trans>Adding helm branch <b>{repo.name}</b> has failed: {String(err)}</Trans>)
}
}
async removeRepo(repo: HelmRepo) {
try {
await repoManager.removeRepo(repo);
this.helmAddedRepos.delete(repo.name);
} catch (err) {
Notifications.error(
<Trans>Removing helm branch <b>{repo.name}</b> has failed: {String(err)}</Trans>
)
}
}
onThemeChange = ({ value }: SelectOption<string>) => {
// themeStore.setTheme(value); // fixme: apply theme on the fly for current view // themeStore.setTheme(value); // fixme: apply theme on the fly for current view
userStore.preferences.colorTheme = value; userStore.preferences.colorTheme = value;
} }
onRepoSelect = async ({ value: repo }: SelectOption<HelmRepo>) => {
const isAdded = this.helmAddedRepos.has(repo.name);
if (isAdded) {
Notifications.ok(<Trans>Helm branch <b>{repo.name}</b> already in use</Trans>)
return;
}
this.helmUpdating = false;
await this.addRepo(repo);
this.helmUpdating = false;
}
formatHelmOptionLabel = ({ value: repo }: SelectOption<HelmRepo>) => {
const isAdded = this.helmAddedRepos.has(repo.name);
return (
<div className="flex gaps">
<span>{repo.name}</span>
{isAdded && <Icon small material="check" className="box right"/>}
</div>
)
}
renderInfo() { renderInfo() {
return ( return (
<Fragment> <Fragment>
<h2> <h2>
<Trans>Preferences</Trans> <Trans>Preferences</Trans>
</h2> </h2>
<div className="info-block flex gaps align-center"> <div className="info-block flex gaps align-flex-start">
<Icon small material="info"/> <Icon small material="info"/>
<small> <p>
<Trans>Lens Global Settings</Trans> (<Trans>applicable to all clusters</Trans>) <Trans>Lens Global Settings</Trans> (<Trans>applicable to all clusters</Trans>)
</small> </p>
</div> </div>
</Fragment> </Fragment>
) )
@ -58,15 +134,41 @@ export class Preferences extends React.Component {
<h2><Trans>Download Mirror</Trans></h2> <h2><Trans>Download Mirror</Trans></h2>
<Select <Select
placeholder={_i18n._(t`Download mirror for kubectl`)} placeholder={<Trans>Download mirror for kubectl</Trans>}
options={this.downloadMirrorOptions} options={this.downloadMirrorOptions}
value={preferences.downloadMirror} value={preferences.downloadMirror}
onChange={({ value }: SelectOption) => preferences.downloadMirror = value} onChange={({ value }: SelectOption) => preferences.downloadMirror = value}
/> />
<h2><Trans>Helm</Trans></h2> <h2><Trans>Helm</Trans></h2>
<div className="helm"> <Select
// todo: added helm repos placeholder={<Trans>Repositories</Trans>}
isLoading={this.helmLoading}
isDisabled={this.helmUpdating}
options={this.helmOptions}
onChange={this.onRepoSelect}
formatOptionLabel={this.formatHelmOptionLabel}
controlShouldRenderValue={false}
/>
<div className="repos flex gaps align-center">
<div className="title">
<Trans>Added repos:</Trans>
</div>
<div className="repos-list">
{this.helmLoading && <Spinner/>}
{Array.from(this.helmAddedRepos).map(([name, repo]) => {
return (
<Badge key={name} className="added-repo flex gaps align-center">
<span className="repo">{name}</span>
<Icon
material="remove_circle_outline"
onClick={() => this.removeRepo(repo)}
tooltip={<Trans>Remove</Trans>}
/>
</Badge>
)
})}
</div>
</div> </div>
<h2><Trans>HTTP Proxy</Trans></h2> <h2><Trans>HTTP Proxy</Trans></h2>

View File

@ -5,8 +5,8 @@ import { cssNames } from "../../utils/cssNames";
import { TooltipDecoratorProps, withTooltip } from "../tooltip"; import { TooltipDecoratorProps, withTooltip } from "../tooltip";
interface Props extends React.HTMLAttributes<any>, TooltipDecoratorProps { interface Props extends React.HTMLAttributes<any>, TooltipDecoratorProps {
label: React.ReactNode;
small?: boolean; small?: boolean;
label?: React.ReactNode;
} }
@withTooltip @withTooltip

View File

@ -7,9 +7,13 @@
display: grid; display: grid;
grid-template-columns: 1fr 40%; grid-template-columns: 1fr 40%;
> .content-col { > * {
@include hidden-scrollbar;
--flex-gap: #{$spacing}; --flex-gap: #{$spacing};
padding: $spacing; padding: $spacing;
}
> .content-col {
margin-right: $spacing; margin-right: $spacing;
background-color: var(--clusters-menu-bgc); background-color: var(--clusters-menu-bgc);
border-radius: $radius; border-radius: $radius;
@ -22,9 +26,6 @@
} }
> .info-col { > .info-col {
@include hidden-scrollbar;
--flex-gap: #{$spacing};
padding: $spacing;
border-left: 1px solid #353a3e; border-left: 1px solid #353a3e;
} }

View File

@ -1,126 +1,20 @@
import { action, autorun, computed, observable, reaction } from "mobx"; import { action, autorun, computed, observable, reaction } from "mobx";
import { autobind, createStorage } from "./utils"; import { autobind, createStorage } from "./utils";
import { Notifications } from "./components/notifications"; import { Notifications } from "./components/notifications";
import { Theme, ThemeType } from "../common/user-store";
interface ITheme {
name: string;
type: "dark" | "light";
author?: string;
colors?: {
[key: string]: string;
blue: string;
magenta: string;
golden: string;
halfGray: string;
primary: string;
textColorPrimary: string;
textColorSecondary: string;
textColorAccent: string;
borderColor: string;
borderFaintColor: string;
mainBackground: string;
contentColor: string;
layoutBackground: string;
layoutTabsBackground: string;
layoutTabsActiveColor: string;
layoutTabsLineColor: string;
sidebarLogoBackground: string;
sidebarActiveColor: string;
sidebarSubmenuActiveColor: string;
sidebarBackground: string;
buttonPrimaryBackground: string;
buttonDefaultBackground: string;
buttonAccentBackground: string;
buttonDisabledBackground: string;
tableBgcStripe: string;
tableBgcSelected: string;
tableHeaderBackground: string;
tableHeaderBorderWidth: string;
tableHeaderBorderColor: string;
tableHeaderColor: string;
tableSelectedRowColor: string;
helmLogoBackground: string;
helmImgBackground: string;
helmStableRepo: string;
helmIncubatorRepo: string;
helmDescriptionHr: string;
helmDescriptionBlockqouteColor: string;
helmDescriptionBlockqouteBorder: string;
helmDescriptionBlockquoteBackground: string;
helmDescriptionHeaders: string;
helmDescriptionH6: string;
helmDescriptionTdBorder: string;
helmDescriptionTrBackground: string;
helmDescriptionCodeBackground: string;
helmDescriptionPreBackground: string;
helmDescriptionPreColor: string;
colorSuccess: string;
colorOk: string;
colorInfo: string;
colorError: string;
colorSoftError: string;
colorWarning: string;
colorVague: string;
colorTerminated: string;
dockHeadBackground: string;
dockInfoBackground: string;
dockInfoBorderColor: string;
terminalBackground: string;
terminalForeground: string;
terminalCursor: string;
terminalCursorAccent: string;
terminalSelection: string;
terminalBlack: string;
terminalRed: string;
terminalGreen: string;
terminalYellow: string;
terminalBlue: string;
terminalMagenta: string;
terminalCyan: string;
terminalWhite: string;
terminalBrightBlack: string;
terminalBrightRed: string;
terminalBrightGreen: string;
terminalBrightYellow: string;
terminalBrightBlue: string;
terminalBrightMagenta: string;
terminalBrightCyan: string;
terminalBrightWhite: string;
dialogTextColor: string;
dialogBackground: string;
dialogHeaderBackground: string;
dialogFooterBackground: string;
drawerTogglerBackground: string;
drawerTitleText: string;
drawerSubtitleBackground: string;
drawerItemNameColor: string;
drawerItemValueColor: string;
boxShadow: string;
iconActiveColor: string;
iconActiveBackground: string;
filterAreaBackground: string;
chartLiveBarBackgound: string;
chartStripesColor: string;
chartCapacityColor: string;
pieChartDefaultColor: string;
selectOptionHoveredColor: string;
lineProgressBackground: string;
radioActiveBackground: string;
};
}
@autobind() @autobind()
export class ThemeStore { export class ThemeStore {
protected style = document.createElement("style"); protected style = document.createElement("style");
readonly defaultTheme: ITheme = { readonly defaultTheme: Theme = {
name: "kontena-dark", name: "kontena-dark",
type: "dark", type: ThemeType.DARK,
colors: {} as any, colors: {},
}; };
@observable activeThemeId = this.defaultTheme.name; // theme's filename without extension @observable activeThemeId = this.defaultTheme.name; // theme's filename without extension
@observable themes = observable.map<string, ITheme>([], { deep: false }); @observable themes = observable.map<string, Theme>([], { deep: false });
@computed get activeTheme() { @computed get activeTheme() {
return this.themes.get(this.activeThemeId) || this.defaultTheme; return this.themes.get(this.activeThemeId) || this.defaultTheme;
@ -157,7 +51,7 @@ export class ThemeStore {
}) })
} }
protected onChange = (theme: ITheme) => { protected onChange = (theme: Theme) => {
let cssText = "\n" let cssText = "\n"
Object.entries(theme.colors).forEach(([propName, color]) => { Object.entries(theme.colors).forEach(([propName, color]) => {
cssText += `--${propName}: ${color} !important;\n` cssText += `--${propName}: ${color} !important;\n`
@ -165,12 +59,12 @@ export class ThemeStore {
this.style.textContent = `:root {${cssText}} `; this.style.textContent = `:root {${cssText}} `;
} }
async load(themeId: string, { showErrorNotification = true } = {}): Promise<ITheme> { async load(themeId: string, { showErrorNotification = true } = {}): Promise<Theme> {
if (this.themes.has(themeId)) { if (this.themes.has(themeId)) {
return this.themes.get(themeId); return this.themes.get(themeId);
} }
try { try {
const theme: ITheme = require( // eslint-disable-line @typescript-eslint/no-var-requires const theme: Theme = require( // eslint-disable-line @typescript-eslint/no-var-requires
/* webpackMode: "lazy", webpackChunkName: "theme/[request]" */ /* webpackMode: "lazy", webpackChunkName: "theme/[request]" */
`./themes/${themeId}.json` `./themes/${themeId}.json`
); );