Skip to content

chore: Update API key functionality when creating model#5601

Merged
steverydz merged 1 commit intomainfrom
WD-30817-api-key-updates-when-creating-model
Feb 24, 2026
Merged

chore: Update API key functionality when creating model#5601
steverydz merged 1 commit intomainfrom
WD-30817-api-key-updates-when-creating-model

Conversation

@steverydz
Copy link
Copy Markdown
Contributor

@steverydz steverydz commented Feb 23, 2026

Done

Addresses UX improvements around the "API key" field when creating a new model. The requirements were:

  • the field should not be pre-populated
  • the field should be required
  • the user should be able to type or paste an existing key into the form

How to QA

Testing

  • This PR has tests
  • No testing required (explain why):

Security

  • Security considerations for review (list them):
    • Examples:
    • Access control: users can only access their own data
    • Input: user input is validated and sanitised
    • Sensitive data: secret or private data is not exposed in any way
    • ...
  • This PR has no security considerations (explain why):

Issue / Card

Fixes https://warthogs.atlassian.net/browse/WD-30817

Screenshots

n/a

UX Approval

  • This PR does not require UX approval
  • This PR does require UX approval (add context): This was a feature discussed at the last engineering sprint in Gothenburg where the user shouldn't be able to create a model without an API key and should also be able to type or paste an existing key into the field.

Copilot AI review requested due to automatic review settings February 23, 2026 11:53
@webteam-app
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the publisher “Create model” flow to require an API key before a model can be created, and adjusts the React unit tests to reflect the new validation behavior.

Changes:

  • Make the API key field editable/required and include API key presence in the submit button disable logic.
  • Update CreateModelForm tests to cover the new “name + API key required” behavior.
  • Wrap the tested component with a Jotai provider in the test setup.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
static/js/publisher/pages/Models/CreateModelForm.tsx Makes API key required/editable and blocks submit unless API key is present.
static/js/publisher/pages/Models/tests/CreateModelForm.test.tsx Expands test coverage for the new submit-disable conditions and adds Jotai provider wrapping.

Comment thread static/js/publisher/pages/Models/__tests__/CreateModelForm.test.tsx
Comment thread static/js/publisher/pages/Models/__tests__/CreateModelForm.test.tsx
Comment thread static/js/publisher/pages/Models/CreateModelForm.tsx
Comment thread static/js/publisher/pages/Models/CreateModelForm.tsx
Comment thread static/js/publisher/pages/Models/__tests__/CreateModelForm.test.tsx Outdated
@steverydz steverydz force-pushed the WD-30817-api-key-updates-when-creating-model branch from c3b8bd5 to 7f88be3 Compare February 23, 2026 14:15
@steverydz steverydz force-pushed the WD-30817-api-key-updates-when-creating-model branch from 7f88be3 to 6ff4295 Compare February 24, 2026 14:32
!newModel.name ||
checkModelNameExists(newModel.name, modelsList)
!newModelName ||
apiKey.length !== 50 ||
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we create a constant and use that constant instead of 50?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good shout - done

@edisile edisile self-requested a review February 24, 2026 15:23
@steverydz steverydz force-pushed the WD-30817-api-key-updates-when-creating-model branch from 6ff4295 to 3a62d53 Compare February 24, 2026 15:23
setShowNotification,
setShowErrorNotification,
}: Props): React.JSX.Element {
const API_KEY_LENGTH = 50;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can ignore this comment: i think it would be nice if we can move it outside of the function as its not a state or ref.

Copy link
Copy Markdown
Contributor

@edisile edisile left a comment

Choose a reason for hiding this comment

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

lgtm

value={newModel.apiKey}
placeholder="yx6dnxsWQ3XUB5gza8idCuMvwmxtk1xBpa9by8TuMit5dgGnv"
value={apiKey}
className="read-only-dark"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

className isn't needed anymore

@steverydz steverydz force-pushed the WD-30817-api-key-updates-when-creating-model branch from 3a62d53 to eb0fe34 Compare February 24, 2026 15:32
@steverydz steverydz merged commit 01d2924 into main Feb 24, 2026
14 checks passed
@steverydz steverydz deleted the WD-30817-api-key-updates-when-creating-model branch February 24, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants