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 #58

Conversation

jvallesm
Copy link
Collaborator

@jvallesm jvallesm commented Feb 6, 2024

Because

  • Several frontend clients will consume the operator definitions via the ListoperatorDefinitions 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 operator definitions.

Notes

🫥 start and end had an icon path that doesn't exist in console. The icons were imported as well, it was decided that all components should have the same icon treatment.

⚠️ 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:40
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 bbf3432 to 2f7d097 Compare February 7, 2024 08:32
Copy link

codecov bot commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (80df32e) 67.93% compared to head (0e29964) 67.93%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #58   +/-   ##
=======================================
  Coverage   67.93%   67.93%           
=======================================
  Files           6        6           
  Lines         658      658           
=======================================
  Hits          447      447           
  Misses        168      168           
  Partials       43       43           
Flag Coverage Δ
unittests 67.93% <ø> (ø)

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.

donch1989
donch1989 previously approved these changes Feb 8, 2024
@jvallesm jvallesm force-pushed the jvalles/ins-3621-move-component-icons-from-console-to-their-component-package branch from 2f7d097 to e047a7c Compare February 8, 2024 08:41
@jvallesm jvallesm changed the base branch from main to jvalles/ins-3620-add-version-to-existing-components February 8, 2024 08:41
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 e047a7c to 0e29964 Compare February 9, 2024 08:53
@EiffelFly
Copy link
Member

@jvallesm console will support this in this sprint, please merge the PR when you are ready

@donch1989 donch1989 merged commit 9fea343 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:14
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.8.0-beta](v0.7.0-beta...v0.8.0-beta)
(2024-02-16)


### Features

* implement jq task in JSON operator
([#61](#61))
([f38cd90](f38cd90))
* **json:** use `semi-structured/json` in TASK_MARSHAL and
TASK_UNMARSHAL ([#62](#62))
([acbe2db](acbe2db))
* set component versions to 0.1.0-alpha
([#59](#59))
([80df32e](80df32e))
* store icons next to the component definition
([#58](#58))
([9fea343](9fea343))

---
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