Widget build()

in ui/lib/modules/my_services/widgets/build_history_widget.dart [46:122]


  Widget build(BuildContext context) {

    var triggerBuilds = ref.watch(triggerBuildsProvider(
        projectId: widget.service.projectId,
        serviceId: widget.service.serviceId));

    return triggerBuilds.when(
      loading: () => LinearProgressIndicator(),
      error: (err, stack) => Text('Error: $err'),
      data: (builds) {
        String triggerId = "";

        if (builds.isNotEmpty) {
          triggerId = builds.first.buildTriggerId;
        }

        return Column(
          children: [
            Row(
              children: [
                Text(
                  "Build History: ",
                  style: AppText.fontStyleBold,
                ),
                const SizedBox(height: 4),
                TextButton(
                  onPressed: () async {
                    Uri _url = Uri.parse(
                        "https://console.cloud.google.com/cloud-build/triggers?project=${widget.service.projectId}");
                    if (builds.isNotEmpty) {
                      _url = Uri.parse(
                          "https://console.cloud.google.com/cloud-build/triggers;region=global/edit/${triggerId}?project=${widget.service.projectId}");
                    }

                    if (!await launchUrl(_url)) {
                      throw 'Could not launch $_url';
                    }
                  },
                  child: Text(
                    "${widget.service.serviceId}-webhook-trigger",
                    overflow: TextOverflow.ellipsis,
                    maxLines: 1,
                    style: AppText.linkFontStyle,
                  ),
                ),
                const SizedBox(height: 4),
                TextButton(
                  onPressed: () async {
                    Uri _url = Uri.parse(
                        "https://console.cloud.google.com/cloud-build/triggers?project=${widget.service.projectId}");
                    if (builds.isNotEmpty) {
                      _url = Uri.parse(
                          "https://console.cloud.google.com/cloud-build/builds;region=global?query=trigger_id=${triggerId}&project=${widget.service.projectId}");
                    }

                    if (!await launchUrl(_url)) {
                      throw 'Could not launch $_url';
                    }
                  },
                  child: Text(
                    "View All",
                    overflow: TextOverflow.ellipsis,
                    maxLines: 1,
                    style: AppText.linkFontStyle,
                  ),
                )
              ],
            ),
            const SizedBox(height: 4),
            buildCloudBuildsSection(builds),
          ],
        );
      },
    );


  }