Work Item Attachments

IssueAttachmentsWidget

class IssueAttachmentsWidget

Bases: textual.containers.VerticalScroll

A container for displaying the files attached to a work item.

This widget is responsible for the following:

  • opening the modal screen that allows users to attach files.

  • processing the result from the modal screen and attaching a file to the work item via the API.

  • deleting attachments from the work item via the API when the message jiratui.widgets.attachments.attachments.AttachmentsDataTable.Deleted is posted.

  • updating the list of attachments when an attachment is deleted.

The config variable config.fetch_attachments_on_delete controls whether the widget retrieves the attachments from the work item after an attachment is deleted.

See Also:

Initialization

Construct a scrollable container.

Parameters:
  • children – Child widgets.

  • name – The name of the widget.

  • id – The ID of the widget in the DOM.

  • classes – The CSS classes for the widget.

  • disabled – Whether the widget is disabled or not.

  • can_focus – Can this container be focused?

  • can_focus_children – Can this container’s children be focused?

  • can_maximized – Allow this container to maximize? None to use default logic.,

on_attachments_data_table_deleted(message: jiratui.widgets.attachments.attachments.AttachmentsDataTable) None

Schedules a task to delete an attachment.

action_add_attachment() None

Opens a screen to attach a file to the issue.

upload_attachment(content: str) None

Uploads a file as an attachment to the work item.

Parameters:

content – the name of the file to attach.

Returns:

None

watch_attachments(data: jiratui.widgets.attachments.attachments.WorkItemAttachments | None) None

Updates the table that displays the attached files with new attachments.

FileAttachmentWidget

class FileAttachmentWidget

A factory to build Widgets to view different types of files attached to a work item.

static build_widget(file_type: str, content: bytes) textual.widget.Widget | None

Builds a textual.widget.Widget for visualizing a specific type of file/content.

Parameters:
  • file_type – the file’s MIME type.

  • content – the bytes representation of the file’s content to display.

Returns:

A textual.widget.Widget to display the contents or None if the file’s content is not supported.

AttachmentsDataTable

class AttachmentsDataTable(work_item_key: str)

Bases: textual.widgets.DataTable

A data table to list the files attached to a work item.

Initialization

Initializes a widget to display tabular data.

Parameters:
  • show_header – Whether the table header should be visible or not.

  • show_row_labels – Whether the row labels should be shown or not.

  • fixed_rows – The number of rows, counting from the top, that should be fixed and still visible when the user scrolls down.

  • fixed_columns – The number of columns, counting from the left, that should be fixed and still visible when the user scrolls right.

  • zebra_stripes – Enables or disables a zebra effect applied to the background color of the rows of the table, where alternate colors are styled differently to improve the readability of the table.

  • header_height – The height, in number of cells, of the data table header.

  • show_cursor – Whether the cursor should be visible when navigating the data table or not.

  • cursor_foreground_priority – If the data associated with a cell is an arbitrary renderable with a set foreground color, this determines whether that color is prioritized over the cursor component class or not.

  • cursor_background_priority – If the data associated with a cell is an arbitrary renderable with a set background color, this determines whether that color is prioritized over the cursor component class or not.

  • cursor_type – The type of cursor to be used when navigating the data table with the keyboard.

  • cell_padding – The number of cells added on each side of each column. Setting this value to zero will likely make your table very hard to read.

  • name – The name of the widget.

  • id – The ID of the widget in the DOM.

  • classes – The CSS classes for the widget.

  • disabled – Whether the widget is disabled or not.

class Deleted(work_item_key: str, attachment_id: str)

Bases: textual.message.Message

Posted when the user deletes an attachment.

It holds the key of the work item whose attachment we deleted and the ID of the deleted attachment.

Initialization

highlighted(event: textual.widgets.DataTable.RowHighlighted) None

Handles the event when a user highlights a row.

We want to store the id of the attachment, the file name of the attachment and the file type. This data will be used for displaying images and opening links in the browser.

Parameters:

event – the event triggered when the user highlights a row.

Returns:

None

selected(event: textual.widgets.DataTable.RowSelected) None

Handles the event when a user selects a row.

We want to store the id of the attachment, the file name of the attachment and the file type. This data will be used for displaying images and opening links in the browser.

Parameters:

event – the event triggered when the user selects a row.

Returns:

None

async action_open_attachment() None

Opens the currently selected attached file in the default browser.

async action_delete_attachment() None

Opens up a modal screen to prompt the user before attempting to delete an attachment.

async handle_delete_choice(result: bool) None

Attempts to delete an attachment if the user agrees.

Parameters:

result – the choice of the user that decides to delete or not an attachment.

Returns:

None