-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a145c87
commit 2fcfc1b
Showing
15 changed files
with
259 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
argilla-frontend/components/features/datasets/datasets-empty/useDatasetEmptyViewModel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { useRunningEnvironment } from "~/v1/infrastructure/services/useRunningEnvironment"; | ||
import { useUser } from "~/v1/infrastructure/services/useUser"; | ||
|
||
const HF_PREFIX = "[hf_]"; | ||
const LOCAL_PREFIX = "[local_]"; | ||
const HF_OWNER = "[HF_OWNER]"; | ||
const HF_SPACE_NAME = "[HF_SPACE_NAME]"; | ||
const USER_API_KEY = "[USER_API_KEY]"; | ||
const LOCAL_HOST = "[LOCAL_HOST]"; | ||
|
||
export const useDatasetEmptyViewModel = () => { | ||
const { isRunningOnHuggingFace, getHuggingFaceSpace } = | ||
useRunningEnvironment(); | ||
const { getUser } = useUser(); | ||
|
||
const replaceLocalData = (rows) => { | ||
const content = []; | ||
const user = getUser(); | ||
|
||
for (const row of rows) { | ||
if (row.includes(HF_PREFIX)) continue; | ||
|
||
if (row.includes(LOCAL_PREFIX)) { | ||
content.push( | ||
row | ||
.replace(LOCAL_PREFIX, "") | ||
.replace(LOCAL_HOST, window.location.origin) | ||
); | ||
continue; | ||
} | ||
|
||
if (row.includes(USER_API_KEY)) { | ||
content.push(row.replace(USER_API_KEY, user.apiKey)); | ||
continue; | ||
} | ||
|
||
content.push(row); | ||
} | ||
|
||
return Promise.resolve(content.join("\n")); | ||
}; | ||
|
||
const replaceHFData = async (rows) => { | ||
const user = getUser(); | ||
const hfEnvironment = await getHuggingFaceSpace(); | ||
|
||
const content = []; | ||
|
||
for (const row of rows) { | ||
if (row.includes(LOCAL_PREFIX)) continue; | ||
|
||
if (row.includes(HF_PREFIX)) { | ||
content.push( | ||
row | ||
.replace(HF_PREFIX, "") | ||
.replace(HF_OWNER, hfEnvironment.user) | ||
.replace(HF_SPACE_NAME, hfEnvironment.space) | ||
); | ||
|
||
continue; | ||
} | ||
|
||
if (row.includes(USER_API_KEY)) { | ||
content.push(row.replace(USER_API_KEY, user.apiKey)); | ||
continue; | ||
} | ||
|
||
content.push(row); | ||
} | ||
|
||
return content.join("\n"); | ||
}; | ||
|
||
const preFillData = (startPage) => { | ||
const rows = startPage.body.split("\n"); | ||
|
||
if (isRunningOnHuggingFace()) return replaceHFData(rows); | ||
|
||
return replaceLocalData(rows); | ||
}; | ||
|
||
return { | ||
preFillData, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
argilla-frontend/components/features/global/user/userAvatarTooltipViewModel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useRoutes } from "~/v1/infrastructure/services/useRoutes"; | ||
import { useUser } from "~/v1/infrastructure/services/useUser"; | ||
|
||
export const useAvatarTooltipViewModel = () => { | ||
const { goToSignIn } = useRoutes(); | ||
const { user } = useUser(); | ||
|
||
return { | ||
goToSignIn, | ||
user, | ||
}; | ||
}; |
107 changes: 0 additions & 107 deletions
107
argilla-frontend/components/features/user-settings/EditionUserInfo.vue
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.