in ui/lib/modules/my_services/widgets/workstation_widget.dart [270:351]
Widget _getActionButton({
required BuildContext context,
required WidgetRef ref,
required Workstation workstation,
}) {
Widget actionButton = Container();
if (workstation.state.contains("STARTING")) {
//while (workstation.state.contains("STARTING")) {
// Future.delayed(const Duration(milliseconds: 1000), () {
// setState(() {});
// });
//}
final workstationStartingProgress = ref.watch(workstationStartingProgressProvider(projectId: widget.service.projectId,
clusterName: workstation.clusterName,
configName: workstation.configName,
instanceName: workstation.displayName,
region: widget.service.region,
));
actionButton = workstationStartingProgress.when(
data: (inProgress) {
if (!inProgress) {
return TextButton(
child: Text("Stop"),
onPressed: () async {
await ref.watch(cloudWorkstationsRepositoryProvider).stopInstance(
widget.service.projectId,
workstation.clusterName,
workstation.configName,
workstation.displayName,
widget.service.region);
ref.invalidate(workstationsProvider);
},
);
} else {
return Container();
}
},
loading: () => Container(),
error: (err, stack) {
print(err);
return Container();
},
);
}
if (workstation.state.contains("STOPPED")) {
actionButton = TextButton(
child: Text("Start"),
onPressed: () async {
await ref.watch(cloudWorkstationsRepositoryProvider).startInstance(
widget.service.projectId,
workstation.clusterName,
workstation.configName,
workstation.displayName,
widget.service.region);
ref.invalidate(workstationsProvider);
},
);
}
if (workstation.state.contains("RUNNING")) {
actionButton = TextButton(
child: Text("Stop"),
onPressed: () async {
await ref.watch(cloudWorkstationsRepositoryProvider).stopInstance(
widget.service.projectId,
workstation.clusterName,
workstation.configName,
workstation.displayName,
widget.service.region);
ref.invalidate(workstationsProvider);
},
);
}
return actionButton;
}