import { action, computed } from '@ember/object';
import { inject as service } from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

export default class VersionRow extends Component {
  @service session;

  @tracked focused = false;

  get releaseTrackTitle() {
    let { version } = this.args;
    if (version.yanked) {
      return 'This version was yanked';
    }
    if (version.invalidSemver) {
      return `Failed to parse version ${version.num}`;
    }
    if (version.isFirst) {
      return 'This is the first version that was released';
    }

    let { releaseTrack } = version;

    let modifiers = [];
    if (version.isPrerelease) {
      modifiers.push('prerelease');
    }
    if (version.isHighestOfReleaseTrack) {
      modifiers.push('latest');
    }

    let title = `Release Track: ${releaseTrack}`;
    if (modifiers.length !== 0) {
      title += ` (${modifiers.join(', ')})`;
    }
    return title;
  }

  @computed('args.version.crate.owner_user', 'session.currentUser.id')
  get isOwner() {
    return this.args.version.crate?.owner_user?.findBy('id', this.session.currentUser?.id);
  }

  @action setFocused(value) {
    this.focused = value;
  }
}

@@ -12,18 +12,8 @@
 tion
-, computed
  %7D f
@@ -977,79 +977,8 @@
  %7D%0A%0A
-  @computed('args.version.crate.owner_user', 'session.currentUser.id')%0A
   ge

Remove unnecessary `@computed` decorator