Skip to content

Commit

Permalink
LinkBadge component improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfboys committed Oct 14, 2023
1 parent c21ff06 commit e5b793d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import LinkBadge from './src/LinkBadge.vue';

export { LinkBadge };
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@

<script setup lang="ts">
import { computed } from 'vue';
interface ExternalLinkBadgeProps {
interface BadgeProps {
label: String;
message: String;
color?: string;
redirect?: string;
disabled?: boolean;
onBadgeClick?: () => void;
}
const props = defineProps<ExternalLinkBadgeProps>();
const props = defineProps<BadgeProps>();
const hasLabel = computed(() => !!props.label);
const isClickable = computed(() => !!props.redirect && !props.disabled);
function handleClick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import DetailTab from './components/AppDetail/DetailTab.vue';
import { createDetailProviderContext } from './hooks/useDetailContext';
import { useDrawer } from '/@/components/Drawer';
import { ExternalLinkBadge } from '/@/views/setting/externalLink/components';
import { LinkBadge } from '/@/components/LinkBadge';

const route = useRoute();
const router = useRouter();
Expand Down Expand Up @@ -245,7 +245,7 @@
<span class="app-bar">{{ t('flink.app.detail.detailTitle') }}</span>
<Space class="-mt-8px">
<div v-for="link in externalLinks" :key="link.id">
<ExternalLinkBadge
<LinkBadge
:label="link.badgeLabel"
:redirect="link.renderedLinkUrl"
:color="link.badgeColor"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import { PlusOutlined } from '@ant-design/icons-vue';
import { ColumnsType } from 'ant-design-vue/lib/table';
import { useModal } from '/@/components/Modal';
import { ExternalLinkModal, ExternalLinkBadge } from './components';
import { LinkBadge } from '/@/components/LinkBadge';
import { ExternalLinkModal } from './components';

import { PageWrapper } from '/@/components/Page';
import { Table, Popconfirm, Card } from 'ant-design-vue';
import { fetchExternalLink, fetchExternalLinkDelete } from '/@/api/setting/externalLink';
Expand Down Expand Up @@ -108,7 +110,7 @@
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'badgeColor'">
<ExternalLinkBadge
<LinkBadge
:color="record.badgeColor"
:label="record.badgeLabel"
:message="record.badgeName"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { default as ExternalLinkBadge } from './Badge.vue';
export { default as ExternalLinkModal } from './Modal.vue';
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

import { Input, Space } from 'ant-design-vue';

import ExternalLinkBadge from './Badge.vue';
import { LinkBadge } from '/@/components/LinkBadge';

import { useI18n } from '/@/hooks/web/useI18n';

const { t } = useI18n();
Expand All @@ -38,13 +39,13 @@ export const renderColorField = (formModel: Recordable, field: string) => {
value={formModel[field]}
onInput={(e) => (formModel[field] = e.target.value)}
/>
<ExternalLinkBadge
<LinkBadge
label={t('setting.externalLink.form.badgeLabel')}
message={t('setting.externalLink.form.badgeName')}
color={DEFAULT_GREEN_HEX}
onBadgeClick={handlePromptColorUpdate(DEFAULT_GREEN_HEX)}
/>
<ExternalLinkBadge
<LinkBadge
label="Fink"
message="Metrics"
color={DEFAULT_BLUE_HEX}
Expand All @@ -56,7 +57,7 @@ export const renderColorField = (formModel: Recordable, field: string) => {

export const renderPreview = (formModel: Recordable) => {
return (
<ExternalLinkBadge
<LinkBadge
label={formModel['badgeLabel']}
message={formModel['badgeName'] || t('setting.externalLink.form.badgeName')}
color={formModel['badgeColor']}
Expand Down

0 comments on commit e5b793d

Please sign in to comment.