github.com/hernad/nomad@v1.6.112/ui/app/controllers/jobs/job.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  // @ts-check
     7  import Controller from '@ember/controller';
     8  import { action } from '@ember/object';
     9  import { inject as service } from '@ember/service';
    10  
    11  export default class JobController extends Controller {
    12    @service router;
    13    @service notifications;
    14    @service store;
    15    queryParams = [
    16      {
    17        jobNamespace: 'namespace',
    18      },
    19    ];
    20    jobNamespace = 'default';
    21  
    22    get job() {
    23      return this.model;
    24    }
    25  
    26    @action notFoundJobHandler() {
    27      if (
    28        this.watchers.job.isError &&
    29        this.watchers.job.error?.errors?.some((e) => e.status === '404')
    30      ) {
    31        this.notifications.add({
    32          title: `Job "${this.job.name}" has been deleted`,
    33          message:
    34            'The job you were looking at has been deleted; this is usually because it was purged from elsewhere.',
    35          color: 'critical',
    36          sticky: true,
    37        });
    38        this.store.unloadRecord(this.job);
    39        this.router.transitionTo('jobs');
    40      }
    41    }
    42  }