mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Restart deployment (#1175)
Signed-off-by: Pavel Ashevskii <pashevskii@mirantis.com>
This commit is contained in:
parent
f9578ba407
commit
d074e0499f
@ -549,6 +549,14 @@ msgstr "Condition"
|
|||||||
msgid "Conditions"
|
msgid "Conditions"
|
||||||
msgstr "Conditions"
|
msgstr "Conditions"
|
||||||
|
|
||||||
|
#: src/renderer/components/+workloads-deployments/deployments.tsx: 118
|
||||||
|
msgid "Restart"
|
||||||
|
msgstr "Restart"
|
||||||
|
|
||||||
|
#: src/renderer/components/+workloads-deployments/deployments.tsx: 121
|
||||||
|
msgid "Are you sure you want to restart deployment <0>{0}</0>?"
|
||||||
|
msgstr "Are you sure you want to restart deployment <0>{0}</0>?"
|
||||||
|
|
||||||
#: src/renderer/components/+config-maps/config-maps.tsx:33
|
#: src/renderer/components/+config-maps/config-maps.tsx:33
|
||||||
msgid "Config Maps"
|
msgid "Config Maps"
|
||||||
msgstr "Config Maps"
|
msgstr "Config Maps"
|
||||||
|
|||||||
@ -545,6 +545,14 @@ msgstr ""
|
|||||||
msgid "Conditions"
|
msgid "Conditions"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/renderer/components/+workloads-deployments/deployments.tsx: 118
|
||||||
|
msgid "Restart"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/renderer/components/+workloads-deployments/deployments.tsx: 121
|
||||||
|
msgid "Are you sure you want to restart deployment <0>{0}</0>?"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/renderer/components/+config-maps/config-maps.tsx:33
|
#: src/renderer/components/+config-maps/config-maps.tsx:33
|
||||||
msgid "Config Maps"
|
msgid "Config Maps"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@ -550,6 +550,14 @@ msgstr "Состояние"
|
|||||||
msgid "Conditions"
|
msgid "Conditions"
|
||||||
msgstr "Состояния"
|
msgstr "Состояния"
|
||||||
|
|
||||||
|
#: src/renderer/components/+workloads-deployments/deployments.tsx: 118
|
||||||
|
msgid "Restart"
|
||||||
|
msgstr "Перезагрузка"
|
||||||
|
|
||||||
|
#: src/renderer/components/+workloads-deployments/deployments.tsx: 121
|
||||||
|
msgid "Are you sure you want to restart deployment <0>{0}</0>?"
|
||||||
|
msgstr "Выполнить перезагрузку деплоймента <0>{0}</0>?"
|
||||||
|
|
||||||
#: src/renderer/components/+config-maps/config-maps.tsx:33
|
#: src/renderer/components/+config-maps/config-maps.tsx:33
|
||||||
msgid "Config Maps"
|
msgid "Config Maps"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import moment from "moment";
|
||||||
|
|
||||||
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
|
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
|
||||||
import { autobind } from "../../utils";
|
import { autobind } from "../../utils";
|
||||||
import { KubeApi } from "../kube-api";
|
import { KubeApi } from "../kube-api";
|
||||||
@ -23,6 +25,25 @@ export class DeploymentApi extends KubeApi<Deployment> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restart(params: { namespace: string; name: string }) {
|
||||||
|
return this.request.patch(this.getUrl(params), {
|
||||||
|
data: {
|
||||||
|
spec: {
|
||||||
|
template: {
|
||||||
|
metadata: {
|
||||||
|
annotations: {"kubectl.kubernetes.io/restartedAt" : moment.utc().format()}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'content-type': 'application/strategic-merge-patch+json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
@ -38,6 +59,7 @@ export class Deployment extends WorkloadKubeObject {
|
|||||||
metadata: {
|
metadata: {
|
||||||
creationTimestamp?: string;
|
creationTimestamp?: string;
|
||||||
labels: { [app: string]: string };
|
labels: { [app: string]: string };
|
||||||
|
annotations?: { [app: string]: string };
|
||||||
};
|
};
|
||||||
spec: {
|
spec: {
|
||||||
containers: {
|
containers: {
|
||||||
|
|||||||
@ -64,7 +64,7 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
patch<T = D>(path: string, params?: P, reqInit: RequestInit = {}) {
|
patch<T = D>(path: string, params?: P, reqInit: RequestInit = {}) {
|
||||||
return this.request<T>(path, params, { ...reqInit, method: "patch" });
|
return this.request<T>(path, params, { ...reqInit, method: "PATCH" });
|
||||||
}
|
}
|
||||||
|
|
||||||
del<T = D>(path: string, params?: P, reqInit: RequestInit = {}) {
|
del<T = D>(path: string, params?: P, reqInit: RequestInit = {}) {
|
||||||
|
|||||||
@ -4,11 +4,12 @@ import React from "react";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { RouteComponentProps } from "react-router";
|
import { RouteComponentProps } from "react-router";
|
||||||
import { t, Trans } from "@lingui/macro";
|
import { t, Trans } from "@lingui/macro";
|
||||||
import { Deployment } from "../../api/endpoints";
|
import { Deployment, deploymentApi } from "../../api/endpoints";
|
||||||
import { KubeObjectMenuProps } from "../kube-object/kube-object-menu";
|
import { KubeObjectMenuProps } from "../kube-object/kube-object-menu";
|
||||||
import { MenuItem } from "../menu";
|
import { MenuItem } from "../menu";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { DeploymentScaleDialog } from "./deployment-scale-dialog";
|
import { DeploymentScaleDialog } from "./deployment-scale-dialog";
|
||||||
|
import { ConfirmDialog } from "../confirm-dialog";
|
||||||
import { deploymentStore } from "./deployments.store";
|
import { deploymentStore } from "./deployments.store";
|
||||||
import { replicaSetStore } from "../+workloads-replicasets/replicasets.store";
|
import { replicaSetStore } from "../+workloads-replicasets/replicasets.store";
|
||||||
import { podsStore } from "../+workloads-pods/pods.store";
|
import { podsStore } from "../+workloads-pods/pods.store";
|
||||||
@ -22,6 +23,8 @@ import kebabCase from "lodash/kebabCase";
|
|||||||
import orderBy from "lodash/orderBy";
|
import orderBy from "lodash/orderBy";
|
||||||
import { KubeEventIcon } from "../+events/kube-event-icon";
|
import { KubeEventIcon } from "../+events/kube-event-icon";
|
||||||
import { kubeObjectMenuRegistry } from "../../../extensions/registries/kube-object-menu-registry";
|
import { kubeObjectMenuRegistry } from "../../../extensions/registries/kube-object-menu-registry";
|
||||||
|
import { apiManager } from "../../api/api-manager";
|
||||||
|
import { Notifications } from "../notifications";
|
||||||
|
|
||||||
enum sortBy {
|
enum sortBy {
|
||||||
name = "name",
|
name = "name",
|
||||||
@ -96,10 +99,34 @@ export class Deployments extends React.Component<Props> {
|
|||||||
export function DeploymentMenu(props: KubeObjectMenuProps<Deployment>) {
|
export function DeploymentMenu(props: KubeObjectMenuProps<Deployment>) {
|
||||||
const { object, toolbar } = props;
|
const { object, toolbar } = props;
|
||||||
return (
|
return (
|
||||||
<MenuItem onClick={() => DeploymentScaleDialog.open(object)}>
|
<>
|
||||||
<Icon material="open_with" title={_i18n._(t`Scale`)} interactive={toolbar}/>
|
<MenuItem onClick={() => DeploymentScaleDialog.open(object)}>
|
||||||
<span className="title"><Trans>Scale</Trans></span>
|
<Icon material="open_with" title={_i18n._(t`Scale`)} interactive={toolbar}/>
|
||||||
</MenuItem>
|
<span className="title"><Trans>Scale</Trans></span>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem onClick={() => ConfirmDialog.open({
|
||||||
|
ok: async () =>
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
await deploymentApi.restart({
|
||||||
|
namespace: object.getNs(),
|
||||||
|
name: object.getName(),
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
Notifications.error(err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
labelOk: _i18n._(t`Restart`),
|
||||||
|
message: (
|
||||||
|
<p>
|
||||||
|
<Trans>Are you sure you want to restart deployment <b>{object.getName()}</b>?</Trans>
|
||||||
|
</p>
|
||||||
|
),
|
||||||
|
})}>
|
||||||
|
<Icon material="autorenew" title={_i18n._(t`Restart`)} interactive={toolbar}/>
|
||||||
|
<span className="title"><Trans>Restart</Trans></span>
|
||||||
|
</MenuItem>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,4 +137,3 @@ kubeObjectMenuRegistry.add({
|
|||||||
MenuItem: DeploymentMenu
|
MenuItem: DeploymentMenu
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user