Skip to content

Commit

Permalink
👌 Updating button component to support anchor tag, removing unused i1…
Browse files Browse the repository at this point in the history
…8n entry
  • Loading branch information
MiloradFilipovic committed Nov 16, 2023
1 parent dda4a56 commit d3d29e5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
15 changes: 13 additions & 2 deletions packages/design-system/src/components/N8nButton/Button.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<template>
<button
<component
:is="element"
:class="classes"
:disabled="isDisabled"
:aria-disabled="ariaDisabled"
:aria-busy="ariaBusy"
:href="href"
aria-live="polite"
v-bind="$attrs"
>
Expand All @@ -14,7 +16,7 @@
<span v-if="label || $slots.default">
<slot>{{ label }}</slot>
</span>
</button>
</component>
</template>

<script setup lang="ts">
Expand Down Expand Up @@ -72,11 +74,20 @@ const props = defineProps({
type: Boolean,
default: false,
},
link: {
type: Boolean,
default: false,
},
href: {
type: String,
default: '#',
},
});
const ariaBusy = computed(() => (props.loading ? 'true' : undefined));
const ariaDisabled = computed(() => (props.disabled ? 'true' : undefined));
const isDisabled = computed(() => props.disabled || props.loading);
const element = computed(() => (props.link ? 'a' : 'button'));
const classes = computed(() => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`components > N8nButton > props > icon > should render icon button 1`] = `"<button class=\\"button button primary medium withIcon\\" aria-live=\\"polite\\"><span class=\\"icon\\"><n8n-icon-stub icon=\\"plus-circle\\" size=\\"medium\\" spin=\\"false\\"></n8n-icon-stub></span><span>Button</span></button>"`;
exports[`components > N8nButton > props > icon > should render icon button 1`] = `"<button class=\\"button button primary medium withIcon\\" href=\\"#\\" aria-live=\\"polite\\"><span class=\\"icon\\"><n8n-icon-stub icon=\\"plus-circle\\" size=\\"medium\\" spin=\\"false\\"></n8n-icon-stub></span><span>Button</span></button>"`;
exports[`components > N8nButton > props > loading > should render loading spinner 1`] = `"<button class=\\"button button primary medium loading withIcon\\" disabled=\\"\\" aria-busy=\\"true\\" aria-live=\\"polite\\"><span class=\\"icon\\"><n8n-spinner-stub size=\\"medium\\" type=\\"dots\\"></n8n-spinner-stub></span><span>Button</span></button>"`;
exports[`components > N8nButton > props > loading > should render loading spinner 1`] = `"<button class=\\"button button primary medium loading withIcon\\" disabled=\\"\\" aria-busy=\\"true\\" href=\\"#\\" aria-live=\\"polite\\"><span class=\\"icon\\"><n8n-spinner-stub size=\\"medium\\" type=\\"dots\\"></n8n-spinner-stub></span><span>Button</span></button>"`;
exports[`components > N8nButton > props > square > should render square button 1`] = `
"<button class=\\"button button primary medium square\\" aria-live=\\"polite\\">
"<button class=\\"button button primary medium square\\" href=\\"#\\" aria-live=\\"polite\\">
<!--v-if--><span>48</span>
</button>"
`;
exports[`components > N8nButton > should render correctly 1`] = `
"<button class=\\"button button primary medium\\" aria-live=\\"polite\\">
"<button class=\\"button button primary medium\\" href=\\"#\\" aria-live=\\"polite\\">
<!--v-if--><span>Button</span>
</button>"
`;
1 change: 0 additions & 1 deletion packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,6 @@
"templates.collectionsNotFound": "Collection could not be found",
"templates.connectionWarning": "⚠️ There was a problem fetching workflow templates. Check your internet connection.",
"templates.heading": "Workflow templates",
"templates.newButton": "New blank workflow",
"templates.shareWorkflow": "Share template",
"templates.noSearchResults": "Nothing found. Try adjusting your search to see more.",
"templates.searchPlaceholder": "Search workflows",
Expand Down
8 changes: 4 additions & 4 deletions packages/editor-ui/src/views/TemplatesSearchView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
<n8n-button
size="large"
type="secondary"
:link="true"
:href="creatorHubUrl"
:label="$locale.baseText('templates.shareWorkflow')"
@click="openNewWorkflow"
target="_blank"
/>
</div>
</div>
Expand Down Expand Up @@ -133,6 +135,7 @@ export default defineComponent({
search: '',
searchEventToTrack: null as null | ISearchEvent,
errorLoadingWorkflows: false,
creatorHubUrl: CREATOR_HUB_URL as string,
};
},
computed: {
Expand Down Expand Up @@ -225,9 +228,6 @@ export default defineComponent({
this.searchEventToTrack = null;
}
},
openNewWorkflow() {
window.open(CREATOR_HUB_URL, '_blank');
},
onSearchInput(search: string) {
this.loadingWorkflows = true;
this.loadingCollections = true;
Expand Down

0 comments on commit d3d29e5

Please sign in to comment.