Skip to content

Commit

Permalink
refactor(uuid): move uuid extract method to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
brucetony committed Jul 26, 2024
1 parent aa763cb commit 9adc58d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
9 changes: 2 additions & 7 deletions components/data-stores/DetailedAnalysisTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { deleteAnalysisFromKong } from "~/composables/useAPIFetch";
import { useConfirm } from "primevue/useconfirm";
import type { Consumer } from "~/services/Api";
import { formatDataRow } from "~/utils/format-data-row";
import { extractUuid } from "~/utils/extract-uuid-from-kong-username";
const props = defineProps({
detailedAnalysisList: {
Expand Down Expand Up @@ -68,12 +69,6 @@ function onConfirmDeleteAnalysis(
}
}
function formatAnalysisUuid(kongAnalysisUsername: string) {
const analysisUuid = kongAnalysisUsername.split("-");
analysisUuid.pop();
return analysisUuid.join("-");
}
function compileAnalysisTable() {
let elongatedTableRows = new Array<analysisRow>();
const analysisNameMap = props.analysisNameMap;
Expand All @@ -83,7 +78,7 @@ function compileAnalysisTable() {
if (consumers && consumers.length > 0) {
consumers.forEach((consumer: Consumer) => {
const analysisUuid = formatAnalysisUuid(consumer.username!);
const analysisUuid = extractUuid(consumer.username!);
const analysisName = analysisNameMap.has(analysisUuid)
? analysisNameMap.get(analysisUuid)
: "N/A";
Expand Down
9 changes: 2 additions & 7 deletions components/data-stores/DetailedProjectTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { deleteProjectFromKong } from "~/composables/useAPIFetch";
import { useConfirm } from "primevue/useconfirm";
import type { DetailedService, Route } from "~/services/Api";
import { extractUuid } from "~/utils/extract-uuid-from-kong-username";
const props = defineProps({
detailedStoreList: Array<DetailedService>,
Expand All @@ -26,12 +27,6 @@ onBeforeMount(() => {
meltDataStoreTable();
});
function formatProjectUuid(kongProjectName: string) {
const projectUuid = kongProjectName.split("-");
projectUuid.pop();
return projectUuid.join("-");
}
const confirmDeleteProject = (event, projectUuid: string) => {
confirm.require({
target: event.currentTarget,
Expand Down Expand Up @@ -62,7 +57,7 @@ function meltDataStoreTable() {
const routes = store.routes;
if (routes && routes.length > 0) {
routes.forEach((proj: Route) => {
const projectUuid = formatProjectUuid(proj.name!);
const projectUuid = extractUuid(proj.name!);
const newRow = {
dataStore: store.name!,
kongProjectId: proj.id!,
Expand Down
5 changes: 5 additions & 0 deletions utils/extract-uuid-from-kong-username.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function extractUuid(kongName: string) {
const uuid = kongName.split("-");
uuid.pop();
return uuid.join("-");
}

0 comments on commit 9adc58d

Please sign in to comment.