Skip to content

Commit 7b1980f

Browse files
feat: Standardize runtime environment status handling (#8026)
1 parent aae839f commit 7b1980f

File tree

9 files changed

+60
-38
lines changed

9 files changed

+60
-38
lines changed

frontend/src/api/modules/files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const computeDirSize = (params: File.DirSizeReq) => {
8686
};
8787

8888
export const fileWgetKeys = () => {
89-
return http.get<File.FileKeys>('files//wget/process/keys');
89+
return http.get<File.FileKeys>('files/wget/process/keys');
9090
};
9191

9292
export const getRecycleList = (params: ReqPage) => {

frontend/src/utils/runtime.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Runtime } from '@/api/interface/runtime';
2+
3+
export function disabledButton(row: Runtime.Runtime, type: string): boolean {
4+
switch (type) {
5+
case 'stop':
6+
return row.status === 'Recreating' || row.status === 'Stopped' || row.status === 'Building';
7+
case 'start':
8+
return (
9+
row.status === 'Starting' ||
10+
row.status === 'Recreating' ||
11+
row.status === 'Running' ||
12+
row.status === 'Building'
13+
);
14+
case 'restart':
15+
return row.status === 'Recreating' || row.status === 'Building';
16+
case 'edit':
17+
return row.status === 'Recreating' || row.status === 'Building';
18+
case 'extension':
19+
case 'config':
20+
return row.status != 'Running';
21+
default:
22+
return false;
23+
}
24+
}

frontend/src/views/website/runtime/dotnet/index.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ import AppResources from '@/views/website/runtime/php/check/index.vue';
108108
import { ElMessageBox } from 'element-plus';
109109
import { GlobalStore } from '@/store';
110110
import RuntimeStatus from '@/views/website/runtime/components/runtime-status.vue';
111+
import { disabledButton } from '@/utils/runtime';
111112
112113
let timer: NodeJS.Timer | null = null;
113114
const loading = ref(false);
@@ -142,7 +143,7 @@ const buttons = [
142143
operateRuntime('down', row.id);
143144
},
144145
disabled: function (row: Runtime.Runtime) {
145-
return row.status === 'recreating' || row.status === 'stopped';
146+
return disabledButton(row, 'stop');
146147
},
147148
},
148149
{
@@ -151,7 +152,7 @@ const buttons = [
151152
operateRuntime('up', row.id);
152153
},
153154
disabled: function (row: Runtime.Runtime) {
154-
return row.status === 'starting' || row.status === 'recreating' || row.status === 'running';
155+
return disabledButton(row, 'start');
155156
},
156157
},
157158
{
@@ -160,7 +161,7 @@ const buttons = [
160161
operateRuntime('restart', row.id);
161162
},
162163
disabled: function (row: Runtime.Runtime) {
163-
return row.status === 'recreating';
164+
return disabledButton(row, 'restart');
164165
},
165166
},
166167
{
@@ -169,7 +170,7 @@ const buttons = [
169170
openDetail(row);
170171
},
171172
disabled: function (row: Runtime.Runtime) {
172-
return row.status === 'recreating';
173+
return disabledButton(row, 'edit');
173174
},
174175
},
175176
{

frontend/src/views/website/runtime/go/index.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ import PortJumpDialog from '@/components/port-jump/index.vue';
107107
import AppResources from '@/views/website/runtime/php/check/index.vue';
108108
import { ElMessageBox } from 'element-plus';
109109
import RuntimeStatus from '@/views/website/runtime/components/runtime-status.vue';
110+
import { disabledButton } from '@/utils/runtime';
110111
111112
let timer: NodeJS.Timer | null = null;
112113
const loading = ref(false);
@@ -136,7 +137,7 @@ const buttons = [
136137
operateRuntime('down', row.id);
137138
},
138139
disabled: function (row: Runtime.Runtime) {
139-
return row.status === 'recreating' || row.status === 'stopped';
140+
return disabledButton(row, 'stop');
140141
},
141142
},
142143
{
@@ -145,7 +146,7 @@ const buttons = [
145146
operateRuntime('up', row.id);
146147
},
147148
disabled: function (row: Runtime.Runtime) {
148-
return row.status === 'starting' || row.status === 'recreating' || row.status === 'running';
149+
return disabledButton(row, 'start');
149150
},
150151
},
151152
{
@@ -154,7 +155,7 @@ const buttons = [
154155
operateRuntime('restart', row.id);
155156
},
156157
disabled: function (row: Runtime.Runtime) {
157-
return row.status === 'recreating';
158+
return disabledButton(row, 'restart');
158159
},
159160
},
160161
{
@@ -163,7 +164,7 @@ const buttons = [
163164
openDetail(row);
164165
},
165166
disabled: function (row: Runtime.Runtime) {
166-
return row.status === 'recreating';
167+
return disabledButton(row, 'edit');
167168
},
168169
},
169170
{

frontend/src/views/website/runtime/java/index.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ import PortJumpDialog from '@/components/port-jump/index.vue';
107107
import AppResources from '@/views/website/runtime/php/check/index.vue';
108108
import { ElMessageBox } from 'element-plus';
109109
import RuntimeStatus from '@/views/website/runtime/components/runtime-status.vue';
110+
import { disabledButton } from '@/utils/runtime';
110111
111112
let timer: NodeJS.Timer | null = null;
112113
const loading = ref(false);
@@ -136,7 +137,7 @@ const buttons = [
136137
operateRuntime('down', row.id);
137138
},
138139
disabled: function (row: Runtime.Runtime) {
139-
return row.status === 'recreating' || row.status === 'stopped';
140+
return disabledButton(row, 'stop');
140141
},
141142
},
142143
{
@@ -145,7 +146,7 @@ const buttons = [
145146
operateRuntime('up', row.id);
146147
},
147148
disabled: function (row: Runtime.Runtime) {
148-
return row.status === 'starting' || row.status === 'recreating' || row.status === 'running';
149+
return disabledButton(row, 'start');
149150
},
150151
},
151152
{
@@ -154,7 +155,7 @@ const buttons = [
154155
operateRuntime('restart', row.id);
155156
},
156157
disabled: function (row: Runtime.Runtime) {
157-
return row.status === 'recreating';
158+
return disabledButton(row, 'restart');
158159
},
159160
},
160161
{
@@ -163,7 +164,7 @@ const buttons = [
163164
openDetail(row);
164165
},
165166
disabled: function (row: Runtime.Runtime) {
166-
return row.status === 'recreating';
167+
return disabledButton(row, 'edit');
167168
},
168169
},
169170
{

frontend/src/views/website/runtime/node/index.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ import PortJumpDialog from '@/components/port-jump/index.vue';
109109
import AppResources from '@/views/website/runtime/php/check/index.vue';
110110
import { ElMessageBox } from 'element-plus';
111111
import RuntimeStatus from '@/views/website/runtime/components/runtime-status.vue';
112+
import { disabledButton } from '@/utils/runtime';
112113
113114
let timer: NodeJS.Timer | null = null;
114115
const loading = ref(false);
@@ -139,7 +140,7 @@ const buttons = [
139140
openModules(row);
140141
},
141142
disabled: function (row: Runtime.Runtime) {
142-
return row.status === 'recreating' || row.status === 'stopped';
143+
return disabledButton(row, 'stop');
143144
},
144145
},
145146
{
@@ -148,7 +149,7 @@ const buttons = [
148149
operateRuntime('down', row.id);
149150
},
150151
disabled: function (row: Runtime.Runtime) {
151-
return row.status === 'recreating' || row.status === 'stopped';
152+
return disabledButton(row, 'stop');
152153
},
153154
},
154155
{
@@ -157,7 +158,7 @@ const buttons = [
157158
operateRuntime('up', row.id);
158159
},
159160
disabled: function (row: Runtime.Runtime) {
160-
return row.status === 'starting' || row.status === 'recreating' || row.status === 'running';
161+
return disabledButton(row, 'start');
161162
},
162163
},
163164
{
@@ -166,7 +167,7 @@ const buttons = [
166167
operateRuntime('restart', row.id);
167168
},
168169
disabled: function (row: Runtime.Runtime) {
169-
return row.status === 'recreating';
170+
return disabledButton(row, 'restart');
170171
},
171172
},
172173
{
@@ -175,7 +176,7 @@ const buttons = [
175176
openDetail(row);
176177
},
177178
disabled: function (row: Runtime.Runtime) {
178-
return row.status === 'recreating';
179+
return disabledButton(row, 'edit');
179180
},
180181
},
181182
{

frontend/src/views/website/runtime/php/index.vue

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ import ComposeLogs from '@/components/compose-log/index.vue';
127127
import Config from '@/views/website/runtime/php/config/index.vue';
128128
import Supervisor from '@/views/website/runtime/php/supervisor/index.vue';
129129
import RuntimeStatus from '@/views/website/runtime/components/runtime-status.vue';
130+
import { disabledButton } from '@/utils/runtime';
130131
131132
const paginationConfig = reactive({
132133
cacheSizeKey: 'runtime-page-size',
@@ -160,7 +161,7 @@ const buttons = [
160161
openExtensionsManagement(row);
161162
},
162163
disabled: function (row: Runtime.Runtime) {
163-
return row.status != 'running';
164+
return disabledButton(row, 'extension');
164165
},
165166
},
166167
{
@@ -169,7 +170,7 @@ const buttons = [
169170
operateRuntime('down', row.id);
170171
},
171172
disabled: function (row: Runtime.Runtime) {
172-
return row.status === 'recreating' || row.status === 'stopped' || row.status === 'building';
173+
return disabledButton(row, 'stop');
173174
},
174175
},
175176
{
@@ -178,12 +179,7 @@ const buttons = [
178179
operateRuntime('up', row.id);
179180
},
180181
disabled: function (row: Runtime.Runtime) {
181-
return (
182-
row.status === 'starting' ||
183-
row.status === 'recreating' ||
184-
row.status === 'running' ||
185-
row.status === 'building'
186-
);
182+
return disabledButton(row, 'start');
187183
},
188184
},
189185
{
@@ -192,7 +188,7 @@ const buttons = [
192188
operateRuntime('restart', row.id);
193189
},
194190
disabled: function (row: Runtime.Runtime) {
195-
return row.status === 'recreating' || row.status === 'building';
191+
return disabledButton(row, 'restart');
196192
},
197193
},
198194
{
@@ -201,7 +197,7 @@ const buttons = [
201197
openDetail(row);
202198
},
203199
disabled: function (row: Runtime.Runtime) {
204-
return row.status === 'building';
200+
return disabledButton(row, 'edit');
205201
},
206202
},
207203
{
@@ -210,7 +206,7 @@ const buttons = [
210206
openConfig(row);
211207
},
212208
disabled: function (row: Runtime.Runtime) {
213-
return row.status === 'building';
209+
return disabledButton(row, 'config');
214210
},
215211
},
216212
{
@@ -219,14 +215,11 @@ const buttons = [
219215
openSupervisor(row);
220216
},
221217
disabled: function (row: Runtime.Runtime) {
222-
return row.status === 'building';
218+
return disabledButton(row, 'config');
223219
},
224220
},
225221
{
226222
label: i18n.global.t('commons.button.delete'),
227-
disabled: function (row: Runtime.Runtime) {
228-
return row.status === 'building';
229-
},
230223
click: function (row: Runtime.Runtime) {
231224
openDelete(row);
232225
},

frontend/src/views/website/runtime/python/index.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ import PortJumpDialog from '@/components/port-jump/index.vue';
107107
import AppResources from '@/views/website/runtime/php/check/index.vue';
108108
import { ElMessageBox } from 'element-plus';
109109
import RuntimeStatus from '@/views/website/runtime/components/runtime-status.vue';
110+
import { disabledButton } from '@/utils/runtime';
110111
111112
let timer: NodeJS.Timer | null = null;
112113
const loading = ref(false);
@@ -136,7 +137,7 @@ const buttons = [
136137
operateRuntime('down', row.id);
137138
},
138139
disabled: function (row: Runtime.Runtime) {
139-
return row.status === 'recreating' || row.status === 'stopped';
140+
return disabledButton(row, 'stop');
140141
},
141142
},
142143
{
@@ -145,7 +146,7 @@ const buttons = [
145146
operateRuntime('up', row.id);
146147
},
147148
disabled: function (row: Runtime.Runtime) {
148-
return row.status === 'starting' || row.status === 'recreating' || row.status === 'running';
149+
return disabledButton(row, 'start');
149150
},
150151
},
151152
{
@@ -154,7 +155,7 @@ const buttons = [
154155
operateRuntime('restart', row.id);
155156
},
156157
disabled: function (row: Runtime.Runtime) {
157-
return row.status === 'recreating';
158+
return disabledButton(row, 'restart');
158159
},
159160
},
160161
{
@@ -163,7 +164,7 @@ const buttons = [
163164
openDetail(row);
164165
},
165166
disabled: function (row: Runtime.Runtime) {
166-
return row.status === 'recreating';
167+
return disabledButton(row, 'edit');
167168
},
168169
},
169170
{

frontend/src/views/website/website/create/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ const runtimeResource = ref('appstore');
661661
const initRuntimeReq = () => ({
662662
page: 1,
663663
pageSize: 100,
664-
status: 'running',
664+
status: 'Running',
665665
type: 'php',
666666
});
667667
const runtimeReq = ref<Runtime.RuntimeReq>(initRuntimeReq());

0 commit comments

Comments
 (0)