Skip to content

Commit

Permalink
New user & repository nested items design
Browse files Browse the repository at this point in the history
  • Loading branch information
arononak committed May 21, 2024
1 parent faf4c59 commit 5b358e2
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 40 deletions.
88 changes: 53 additions & 35 deletions github-actions@arononak.github.io/lib/status_bar_indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,29 @@ export class StatusBarIndicator extends PanelMenu.Button {
this.collaboratorsMenuItem?.setHeaderItemText(loadingText)
this.pullRequestsMenuItem?.setHeaderItemText(loadingText)
this.artifactsMenuItem?.setHeaderItemText(loadingText)

this.twoFactorItem?.label.set_text(loadingText)
this.minutesItem?.label.set_text(loadingText)
this.packagesItem?.label.set_text(loadingText)
this.sharedStorageItem?.label.set_text(loadingText)
this.bandwidthItem?.label.set_text(loadingText)
this.storageItem?.label.set_text(loadingText)

this.repositoryCreatedItem?.label.set_text(loadingText)
this.repositoryPrivateItem?.label.set_text(loadingText)
this.repositoryForkItem?.label.set_text(loadingText)
this.repositoryLanguageItem?.label.set_text(loadingText)
this.repositoryLicenseItem?.label.set_text(loadingText)

this.twoFactorItem?.updateEndButtonText(loadingText)
this.minutesItem?.updateEndButtonText(loadingText)
this.bandwidthItem?.updateEndButtonText(loadingText)
this.storageItem?.updateEndButtonText(loadingText)

this.repositoryCreatedItem?.updateEndButtonText(loadingText)
this.repositoryPrivateItem?.updateEndButtonText(loadingText)
this.repositoryForkItem?.updateEndButtonText(loadingText)
this.repositoryLanguageItem?.updateEndButtonText(loadingText)
this.repositoryLicenseItem?.updateEndButtonText(loadingText)

this.setTransferEmptyState()
}

Expand Down Expand Up @@ -461,38 +475,35 @@ export class StatusBarIndicator extends PanelMenu.Button {

// 2 FA
this.twoFactorCallback = () => this.twoFactorEnabled == false ? openUrl(`https://github.com/settings/two_factor_authentication/setup/intro`) : {}
this.twoFactorItem = new ChildMenuItem({
startIconName: `security-medium-symbolic`,
itemCallback: this.twoFactorCallback,
})
this.twoFactorItem = new ChildMenuItem({ startIconName: `security-medium-symbolic`, itemCallback: this.twoFactorCallback, endButtonText: ``, endButtonCallback: () => { } })
if (isGnome45()) {
this.userMenuItem.menuBox.add_actor(this.twoFactorItem)
} else {
this.userMenuItem.menuBox.add_child(this.twoFactorItem)
}

// Minutes
this.minutesItem = new ChildMenuItem({ startIconName: `alarm-symbolic` })
this.minutesItem = new ChildMenuItem({ startIconName: `alarm-symbolic`, endButtonText: ``, endButtonCallback: () => { } })
if (isGnome45()) {
this.userMenuItem.menuBox.add_actor(this.minutesItem)
} else {
this.userMenuItem.menuBox.add_child(this.minutesItem)
}

// Packages
this.packagesItem = new ChildMenuItem({ startIconName: `network-transmit-receive-symbolic` })
this.bandwidthItem = new ChildMenuItem({ startIconName: `network-transmit-receive-symbolic`, endButtonText: ``, endButtonCallback: () => { } })
if (isGnome45()) {
this.userMenuItem.menuBox.add_actor(this.packagesItem)
this.userMenuItem.menuBox.add_actor(this.bandwidthItem)
} else {
this.userMenuItem.menuBox.add_child(this.packagesItem)
this.userMenuItem.menuBox.add_child(this.bandwidthItem)
}

// Shared Storage
this.sharedStorageItem = new ChildMenuItem({ startIconName: `network-server-symbolic` })
this.storageItem = new ChildMenuItem({ startIconName: `network-server-symbolic`, endButtonText: ``, endButtonCallback: () => { } })
if (isGnome45()) {
this.userMenuItem.menuBox.add_actor(this.sharedStorageItem)
this.userMenuItem.menuBox.add_actor(this.storageItem)
} else {
this.userMenuItem.menuBox.add_child(this.sharedStorageItem)
this.userMenuItem.menuBox.add_child(this.storageItem)
}

if (this.simpleMode === false) {
Expand Down Expand Up @@ -533,39 +544,39 @@ export class StatusBarIndicator extends PanelMenu.Button {
this.menu.addMenuItem(this.repositoryMenuItem)

// Repository createdAt
this.repositoryCreatedItem = new ChildMenuItem({ startIconName: `x-office-calendar-symbolic` })
this.repositoryCreatedItem = new ChildMenuItem({ startIconName: `x-office-calendar-symbolic`, endButtonText: ``, endButtonCallback: () => { } })
if (isGnome45()) {
this.repositoryMenuItem.menuBox.add_actor(this.repositoryCreatedItem)
} else {
this.repositoryMenuItem.menuBox.add_child(this.repositoryCreatedItem)
}

// Repository isPrivate
this.repositoryPrivateItem = new ChildMenuItem({ startIconName: `changes-prevent-symbolic` })
this.repositoryPrivateItem = new ChildMenuItem({ startIconName: `changes-prevent-symbolic`, endButtonText: ``, endButtonCallback: () => { } })
if (isGnome45()) {
this.repositoryMenuItem.menuBox.add_actor(this.repositoryPrivateItem)
} else {
this.repositoryMenuItem.menuBox.add_child(this.repositoryPrivateItem)
}

// Repository isFork
this.repositoryForkItem = new ChildMenuItem({ startIconName: `system-software-install-symbolic` })
this.repositoryForkItem = new ChildMenuItem({ startIconName: `system-software-install-symbolic`, endButtonText: ``, endButtonCallback: () => { } })
if (isGnome45()) {
this.repositoryMenuItem.menuBox.add_actor(this.repositoryForkItem)
} else {
this.repositoryMenuItem.menuBox.add_child(this.repositoryForkItem)
}

// Repository language
this.repositoryLanguageItem = new ChildMenuItem({ startIconName: `preferences-desktop-locale-symbolic` })
this.repositoryLanguageItem = new ChildMenuItem({ startIconName: `preferences-desktop-locale-symbolic`, endButtonText: ``, endButtonCallback: () => { } })
if (isGnome45()) {
this.repositoryMenuItem.menuBox.add_actor(this.repositoryLanguageItem)
} else {
this.repositoryMenuItem.menuBox.add_child(this.repositoryLanguageItem)
}

// Repository license
this.repositoryLicenseItem = new ChildMenuItem({ startIconName: `accessories-text-editor-symbolic` })
this.repositoryLicenseItem = new ChildMenuItem({ startIconName: `accessories-text-editor-symbolic`, endButtonText: ``, endButtonCallback: () => { } })
if (isGnome45()) {
this.repositoryMenuItem.menuBox.add_actor(this.repositoryLicenseItem)
} else {
Expand Down Expand Up @@ -696,38 +707,40 @@ export class StatusBarIndicator extends PanelMenu.Button {
}

if (this.twoFactorItem != null) {
this.twoFactorItem.label.text = twoFactorEnabled == undefined
? `2FA: No permissions`
: `2FA: ${twoFactorEnabled == true ? `Enabled` : `Disabled`}`
this.twoFactorItem.label.text = `2FA`
this.twoFactorItem.updateEndButtonText(twoFactorEnabled == undefined ? `No permissions` : twoFactorEnabled == true ? `Enabled` : `Disabled`)
}
}

setUserBilling(minutes, packages, sharedStorage) {
let parsedMinutes
if (minutes != null) {
parsedMinutes = `Usage minutes: ${minutes[`total_minutes_used`]} of ${minutes[`included_minutes`]}, ${minutes[`total_paid_minutes_used`]} paid`
parsedMinutes = `${minutes[`total_minutes_used`]} of ${minutes[`included_minutes`]}, (${minutes[`total_paid_minutes_used`]} paid)`
}

let parsedPackages
if (packages != null) {
parsedPackages = `Data transfer out: ${packages[`total_gigabytes_bandwidth_used`]} GB of ${packages[`included_gigabytes_bandwidth`]} GB, ${packages[`total_paid_gigabytes_bandwidth_used`]} GB paid`
parsedPackages = `${packages[`total_gigabytes_bandwidth_used`]} GB of ${packages[`included_gigabytes_bandwidth`]} GB, ${packages[`total_paid_gigabytes_bandwidth_used`]} GB paid`
}

let parsedSharedStorage
let parsedStorage
if (sharedStorage != null) {
parsedSharedStorage = `Storage for month: ${sharedStorage[`estimated_storage_for_month`]} GB, ${sharedStorage[`estimated_paid_storage_for_month`]} GB paid`
parsedStorage = `${sharedStorage[`estimated_storage_for_month`]} GB, ${sharedStorage[`estimated_paid_storage_for_month`]} GB paid`
}

if (this.minutesItem != null) {
this.minutesItem.label.text = parsedMinutes == null ? `No permissions` : parsedMinutes
this.minutesItem.label.text = `Minutes`
this.minutesItem.updateEndButtonText(parsedMinutes == null ? `No permissions` : parsedMinutes)
}

if (this.packagesItem != null) {
this.packagesItem.label.text = parsedPackages == null ? `No permissions` : parsedPackages
if (this.bandwidthItem != null) {
this.bandwidthItem.label.text = `Bandwidth`
this.bandwidthItem.updateEndButtonText(parsedPackages == null ? `No permissions` : parsedPackages)
}

if (this.sharedStorageItem != null) {
this.sharedStorageItem.label.text = parsedSharedStorage == null ? `No permissions` : parsedSharedStorage
if (this.storageItem != null) {
this.storageItem.label.text = `Storage`
this.storageItem.updateEndButtonText(parsedStorage == null ? `No permissions` : parsedStorage)
}
}

Expand Down Expand Up @@ -881,23 +894,28 @@ export class StatusBarIndicator extends PanelMenu.Button {
}

if (this.repositoryCreatedItem != null) {
this.repositoryCreatedItem.label.text = `Created at: ${DateFormatController.format(repo[`created_at`])}`
this.repositoryCreatedItem.label.text = `Created at`
this.repositoryCreatedItem.updateEndButtonText(DateFormatController.format(repo[`created_at`]))
}

if (this.repositoryPrivateItem != null) {
this.repositoryPrivateItem.label.text = `Private: ${(repo[`private`] == true).toString()}`
this.repositoryPrivateItem.label.text = `Private`
this.repositoryPrivateItem.updateEndButtonText((repo[`private`] == true).toString())
}

if (this.repositoryForkItem != null) {
this.repositoryForkItem.label.text = `Fork: ${(repo[`fork`] == true).toString()}`
this.repositoryForkItem.label.text = `Fork`
this.repositoryForkItem.updateEndButtonText((repo[`fork`] == true).toString())
}

if (this.repositoryLanguageItem != null) {
this.repositoryLanguageItem.label.text = `Language: ${repo?.language || `null`}`
this.repositoryLanguageItem.label.text = `Language`
this.repositoryLanguageItem.updateEndButtonText(repo?.language || `null`)
}

if (this.repositoryLicenseItem != null) {
this.repositoryLicenseItem.label.text = `License: ${repo?.license?.spdx_id ?? `null`}`
this.repositoryLicenseItem.label.text = `License`
this.repositoryLicenseItem.updateEndButtonText(repo?.license?.spdx_id ?? `null`)
}
}

Expand Down
15 changes: 10 additions & 5 deletions github-actions@arononak.github.io/lib/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ export class ParentMenuItem extends PopupMenu.PopupSubMenuMenuItem {
}
}

// Child item
export class ChildMenuItem extends PopupMenu.PopupImageMenuItem {
static {
GObject.registerClass(this)
Expand All @@ -322,12 +321,12 @@ export class ChildMenuItem extends PopupMenu.PopupImageMenuItem {
this.insert_child_at_index(box, 100)

if (endButtonText != null) {
const button = new St.Button({ style_class: `button github-actions-text-button`, label: endButtonText })
button.connect(`clicked`, endButtonCallback)
this._endButton = new St.Button({ style_class: `button github-actions-text-button`, label: endButtonText })
this._endButton.connect(`clicked`, endButtonCallback)
if (isGnome45()) {
box.add(button)
box.add(this._endButton)
} else {
box.add_child(button)
box.add_child(this._endButton)
}
}

Expand Down Expand Up @@ -357,6 +356,12 @@ export class ChildMenuItem extends PopupMenu.PopupImageMenuItem {
y_align: Clutter.ActorAlign.CENTER,
})
}

updateEndButtonText(newText) {
if (this._endButton) {
this._endButton.label = newText;
}
}
}

export function showNotification(message, success) {
Expand Down

0 comments on commit 5b358e2

Please sign in to comment.