Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

feat: store icons next to the component definition #122

Conversation

jvallesm
Copy link
Collaborator

@jvallesm jvallesm commented Feb 6, 2024

Because

  • Several frontend clients will consume the connector definitions via the ListConnectorDefinitions endpoint.
  • The component source code should be the source of truth for the icon, not one of the frontends.

This commit

  • Copies the icons into the repo and updates the icon path in the connector definitions.

Notes

⚠️ Frontend should pull these icons in order to include a local version in the service build. Until this task is done, the frontend won't be able to find the icons and will break the component UX.

🪶 The icons aren't used in the backend code so we could exclude them from the image build to have lighter images.

👯 Copy was automated with the following script:

#!/usr/bin/env bash

set -eo pipefail

# This script copies the icon of a component, located in the `console`
# repository, into each component package.
#
# Usage: sh copyicon.sh ~/Code/go/src/github.com/instill-ai/console

CONSOLE_PATH=$1
ICONS_PATH=$CONSOLE_PATH/apps/console/public/icons

function defID() {
  jq -r '.[0].id' $1/config/definitions.json
}

function sourceIcon() {
  jq -r "(\"$ICONS_PATH/\" + .[0].icon)" $1/config/definitions.json
}

for p in $(fd definitions.json | cut -d '/' -f1-2 | sort | uniq); do
  compID=$(defID $p)
  iconPath=$(sourceIcon $p)

  # copy icon
  mkdir -p $p/assets
  cp "$iconPath" "./$p/assets/$compID.svg" || continue # continue if file doesn't exist. This occurs for start and end operators.

  # replace path in definition
  sed -i '' "s/\(\"icon\": \"\).*\(\",*\)/\1assets\/$compID.svg\2/g" $p/config/definitions.json
done;

@jvallesm jvallesm self-assigned this Feb 6, 2024
Copy link

linear bot commented Feb 6, 2024

@jvallesm jvallesm marked this pull request as ready for review February 6, 2024 14:37
@jvallesm jvallesm requested a review from EiffelFly February 6, 2024 14:49
donch1989
donch1989 previously approved these changes Feb 7, 2024
@jvallesm jvallesm force-pushed the jvalles/ins-3621-move-component-icons-from-console-to-their-component-package branch from 3888bb6 to 3b57098 Compare February 8, 2024 08:40
@jvallesm jvallesm changed the base branch from main to jvalles/ins-3620-add-version-to-existing-components February 8, 2024 08:42
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (81af1d5) 62.18% compared to head (95a4e38) 62.18%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #122   +/-   ##
=======================================
  Coverage   62.18%   62.18%           
=======================================
  Files          18       18           
  Lines        1489     1489           
=======================================
  Hits          926      926           
  Misses        440      440           
  Partials      123      123           
Flag Coverage Δ
unittests 62.18% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from jvalles/ins-3620-add-version-to-existing-components to main February 9, 2024 08:47
@jvallesm jvallesm force-pushed the jvalles/ins-3621-move-component-icons-from-console-to-their-component-package branch from 3b57098 to 95a4e38 Compare February 9, 2024 08:51
@donch1989
Copy link
Member

Hi @jvallesm @EiffelFly
Is this PR and instill-ai/operator#58 ready to be merged?

@jvallesm
Copy link
Collaborator Author

Hi @jvallesm @EiffelFly Is this PR and instill-ai/operator#58 ready to be merged?

👋 I QAd this with the main version of the console and the icons break in the component display, so it requires frontend changes to include the icons from this repo in the console image build

@EiffelFly
Copy link
Member

@jvallesm I will try to support this in this sprint, please merge this PR when you are ready.

@donch1989 donch1989 merged commit c67fc89 into main Feb 15, 2024
10 checks passed
@donch1989 donch1989 deleted the jvalles/ins-3621-move-component-icons-from-console-to-their-component-package branch February 15, 2024 04:12
EiffelFly added a commit to instill-ai/console that referenced this pull request Feb 15, 2024
Because

- backend have breaking changes related to icon path due to we try to
centralize the management of connector's icons
- instill-ai/connector#122
- instill-ai/operator#58

This commit

- support the backend breaking changes of icon path
donch1989 pushed a commit that referenced this pull request Feb 16, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.12.0-beta](v0.11.0-beta...v0.12.0-beta)
(2024-02-16)


### Features

* **restapi:** use `instillFormat: semi-structured/json` for request and
response body
([#126](#126))
([53606c1](53606c1))
* set component versions to 0.1.0-alpha
([#123](#123))
([81af1d5](81af1d5))
* store icons next to the component definition
([#122](#122))
([c67fc89](c67fc89))


### Bug Fixes

* **instill:** fix auth issue
([#128](#128))
([9908b3a](9908b3a))
* **pinecone:** fix issue that pinecone's icon padding is too big
([#127](#127))
([d27697e](d27697e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants