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

fix: publishReply has incorrect Event in reply #141

Merged
merged 9 commits into from
Sep 11, 2023

Conversation

gismya
Copy link
Contributor

@gismya gismya commented Sep 11, 2023

  • I have added automatic tests where applicable
  • The PR title is suitable as a release note
  • The PR contains a description of what has been changed
  • The description contains manual test instructions

Changes

The shape of the data in the Event sent by publishReply was incorrect since the TypeScript refactoring. target and inReplyToEvent ended up inside Event._data.data instead of Event._data This broke the ability to register actions. Another issue, where the source was incorrectly written over in publish was also fixed.

I also added tests for the Event creation, and a test to ensure the shape of the event data is correct in publishReply

Test

After linking the repo to an ftrack instance, you can create a dummy action with

let session = ftrackSpark.getSession?.() ?? FT.spark.getSharedSession();

session.eventHub.subscribe("topic=ftrack.action.discover", () => {
  return {
    items: [
      {
        label: "Test action",
        description: "Description",
        actionIdentifier: "test-action-id",
      },
    ],
  };
});

session.eventHub.subscribe("topic=ftrack.action.launch", () => {
  return {
    items: [
      {
        label: "My String",
        type: "text",
        value: "no string",
        name: "my_string",
      },
      {
        label: "My String2",
        type: "text",
        value: "no string2",
        name: "my_string2",
      },
      {
        label: "My Date",
        type: "date",
        name: "my_date",
        value: "2022-09-16",
      },
      {
        label: "My Number",
        type: "number",
        name: "my_number",
        empty_text: "Type a number here...",
      },
      {
        value: "## This is a label. ##",
        type: "label",
      },
      {
        label: "Enter your text",
        name: "my_textarea",
        value: "some text",
        type: "textarea",
      },
      {
        label: "My Boolean",
        name: "my_boolean",
        value: true,
        type: "boolean",
      },
      {
        value: "This field is hidden",
        name: "my_hidden",
        type: "hidden",
      },
      {
        label: "My Enum",
        type: "enumerator",
        name: "my_enumerator",
        data: [
          {
            label: "Option 1",
            value: "opt1",
          },
          {
            label: "Option 2",
            value: "opt2",
          },
        ],
      },
    ],
  };
});

Make sure it shows up in actions.

@gismya gismya requested a review from lucaas September 11, 2023 12:25
@gismya gismya requested a review from a team as a code owner September 11, 2023 12:25
Copy link
Contributor

@lucaas lucaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some minor comments/questions.

Looking at the code, it is very confusing with everything on the event stored as Event._data. I am not sure why, but it would be better to just have them defined as as e.g. Event.source and remove the useless getData method.

source/event.ts Show resolved Hide resolved
source/event.ts Outdated Show resolved Hide resolved
source/event_hub.ts Outdated Show resolved Hide resolved
source/event_hub.ts Outdated Show resolved Hide resolved
source/event_hub.ts Outdated Show resolved Hide resolved
test/event.test.ts Show resolved Hide resolved
gismya and others added 2 commits September 11, 2023 15:39
Co-authored-by: Lucas Stålner Correia <lucas.correia@ftrack.com>
@gismya gismya requested a review from lucaas September 11, 2023 13:44
@gismya
Copy link
Contributor Author

gismya commented Sep 11, 2023

@lucaas Thanks for the comments. Everything has been addressed.

regarding the structure of Event, I agree it's confusing. Something we might address in the future.

Copy link
Contributor

@lucaas lucaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!

@gismya gismya merged commit c4eb920 into main Sep 11, 2023
@gismya gismya deleted the publish-reply-incorrect-event-shape branch September 11, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants