Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Fix repo URLs in version information dialog #1464

Merged
merged 3 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/settings/VersionInformationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
</template>

<script lang="ts">
import type { ArtifactVersion, HashVersion, OSPackage } from '@/store/version/types'
import type { UpdatePackage } from '@/store/version/types'
import { Component, Vue, Prop, VModel } from 'vue-property-decorator'

@Component({})
Expand All @@ -100,7 +100,7 @@ export default class VersionInformationDialog extends Vue {
open?: boolean

@Prop({ type: Object })
readonly component!: HashVersion | ArtifactVersion | OSPackage
readonly component!: UpdatePackage

// For HashVersions or ArtifacVersions, show the commit history.
// For type system, show the packages available to update.
Expand All @@ -112,7 +112,7 @@ export default class VersionInformationDialog extends Vue {

get baseUrl () {
if ('owner' in this.component) {
return `https://github.com/${this.component.owner}/${this.component.key}`
return `https://github.com/${this.component.owner}/${this.component.repo_name || this.component.key}`
}
return ''
}
Expand Down
14 changes: 7 additions & 7 deletions src/components/settings/VersionSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ import VersionStatus from './VersionStatus.vue'
import VersionCommitHistoryDialog from './VersionInformationDialog.vue'
import StateMixin from '@/mixins/state'
import { SocketActions } from '@/api/socketActions'
import type { ArtifactVersion, HashVersion, OSPackage } from '@/store/version/types'
import type { VersionedUpdatePackage, UpdatePackage } from '@/store/version/types'

@Component({
components: {
Expand Down Expand Up @@ -219,7 +219,7 @@ export default class VersionSettings extends Mixins(StateMixin) {
})
}

packageTitle (component: HashVersion | OSPackage | ArtifactVersion) {
packageTitle (component: UpdatePackage) {
if (component.key === 'system') {
return this.$t('app.version.label.os_packages')
}
Expand All @@ -231,7 +231,7 @@ export default class VersionSettings extends Mixins(StateMixin) {
return this.$store.getters['version/hasUpdate'](component)
}

inError (component: HashVersion | OSPackage | ArtifactVersion) {
inError (component: UpdatePackage) {
const dirty = ('is_dirty' in component) ? component.is_dirty : false
const valid = ('is_valid' in component) ? component.is_valid : true
return (dirty || !valid)
Expand Down Expand Up @@ -262,7 +262,7 @@ export default class VersionSettings extends Mixins(StateMixin) {
}

// Will attempt to recover a component based on its type and current status.
handleRecoverComponent (component: HashVersion | OSPackage | ArtifactVersion) {
handleRecoverComponent (component: UpdatePackage) {
this.$store.dispatch('version/onUpdateStatus', { busy: true })
const dirty = ('is_dirty' in component) ? component.is_dirty : false
const valid = ('is_valid' in component) ? component.is_valid : true
Expand All @@ -282,17 +282,17 @@ export default class VersionSettings extends Mixins(StateMixin) {
}
}

getBaseUrl (component: HashVersion | ArtifactVersion) {
getBaseUrl (component: VersionedUpdatePackage) {
if ('remote_url' in component && component.remote_url) {
return component.remote_url
}
if ('owner' in component) {
return `https://github.com/${component.owner}/${component.key}`
return `https://github.com/${component.owner}/${component.repo_name || component.key}`
}
return ''
}

handleInformationDialog (component: HashVersion | OSPackage | ArtifactVersion) {
handleInformationDialog (component: UpdatePackage) {
if (
'commits_behind' in component ||
'package_list' in component
Expand Down
4 changes: 3 additions & 1 deletion src/store/version/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export const getters: GetterTree<VersionState, RootState> = {
}
} else if ('package_count' in componentVersionInfo) {
return componentVersionInfo.package_count > 0
} else {
}

if ('current_hash' in componentVersionInfo && 'remote_hash' in componentVersionInfo) {
return componentVersionInfo.current_hash !== componentVersionInfo.remote_hash
}

Expand Down
91 changes: 59 additions & 32 deletions src/store/version/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,83 @@ export interface VersionState {
fluidd: FluiddVersion;
}

export interface VersionComponents {
[key: string]: HashVersion | ArtifactVersion | OSPackage;
}
export type VersionComponents = Record<string, UpdatePackage>;

/** For klipper / moonraker */
export interface HashVersion {
/**
* Base interface for all versioned packages
*/
export interface VersionedPackage {
key: string;
configured_type?: string;
detected_type?: string;
channel?: string;
pristine?: boolean;
channel?: 'stable' | 'beta' | 'dev';
channel_invalid?: boolean;
detected_type?: 'git_repo'; // As far as I can tell, this is the only possible value that Moonraker can return for this field.
debug_enabled: boolean;
is_valid: boolean;
name: string;
repo_name?: string;
owner: string;
branch: string;
remote_alias: string;
version: string;
remote_version: string;
rollback_version?: string;
info_tags?: string[];
warnings?: string[];
anomalies?: string[];
}

/**
* Updates are deployed directly via git.
* Typical usage scenarios are to manage extensions installed a service.
* eg. KlipperScreen, repos containing configs, etc.
*
* See: https://moonraker.readthedocs.io/en/latest/configuration/#git-type-application-configuration
*/
export interface GitUpdatePackage extends VersionedPackage {
configured_type?: 'git_repo';
pristine?: boolean;
branch: string;
remote_alias: string;
full_version_string: string;
current_hash: string;
remote_hash: string;
is_valid: boolean;
corrupt?: boolean;
is_dirty: boolean;
detached: boolean;
debug_enabled: boolean;
commits_behind: CommitItem[];
commits_behind_count: number;
git_messages: string[];
info_tags?: string[];
recovery_url?: string;
remote_url?: string;
warnings?: string[];
anomalies?: string[];
}

/**
* `web` packages are simple packages that can be updated by downloading a zip of a github release.
* They are not capable of performing any additional actions.
* e.g. updating dependencies, building from source, managing services, etc
*
* See: https://moonraker.readthedocs.io/en/latest/configuration/#web-type-front-end-configuration
*/
export interface WebUpdatePackage extends VersionedPackage {
configured_type?: 'web';
/** Note: Can be an empty string */
last_error?: string;
}

/**
* `zip` packages are a combination of the `web` and `git_repo` types.
* Compared to `web` packages, `zip` packages have can perform actions such as
* updating of dependencies, building from source, managing services, etc.
*
* See: https://moonraker.readthedocs.io/en/latest/configuration/#zip-application-configuration
*/
export interface ZipUpdatePackage extends VersionedPackage {
configured_type?: 'zip';
/** Note: Can be an empty string */
last_error?: string;
}

export type VersionedUpdatePackage = GitUpdatePackage | WebUpdatePackage | ZipUpdatePackage;
export type UpdatePackage = VersionedUpdatePackage | OSPackage;

export interface CommitItem {
author: string;
date: string; // number
Expand All @@ -58,22 +101,6 @@ export interface OSPackage {
package_list: string[];
}

/** For clients */
export interface ArtifactVersion {
key: string;
channel?: string;
configured_type?: string;
name: string;
owner: string;
version: string;
remote_version: string;
rollback_version?: string;
info_tags?: string[];
is_valid: boolean;
warnings?: string[];
anomalies?: string[];
}

export interface FluiddVersion {
version: string;
hash: string;
Expand Down