Merge pull request 'feat: rename workspaces' (#9862) from naskya/calckey:feat/rename-workspaces into develop

Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9862
This commit is contained in:
Kainoa Kanter 2023-04-15 17:51:59 +00:00
commit de85e32b6b
6 changed files with 48 additions and 0 deletions

View file

@ -1806,7 +1806,9 @@ _deck:
popRight: "Pop column to the right" popRight: "Pop column to the right"
profile: "Workspace" profile: "Workspace"
newProfile: "New workspace" newProfile: "New workspace"
renameProfile: "Rename workspace"
deleteProfile: "Delete workspace" deleteProfile: "Delete workspace"
nameAlreadyExists: "This workspace name already exists."
introduction: "Create the perfect interface for you by arranging columns freely!" introduction: "Create the perfect interface for you by arranging columns freely!"
introduction2: "Click on the + on the right of the screen to add new colums whenever you want." introduction2: "Click on the + on the right of the screen to add new colums whenever you want."
widgetsIntroduction: "Please select \"Edit widgets\" in the column menu and add a widget." widgetsIntroduction: "Please select \"Edit widgets\" in the column menu and add a widget."

View file

@ -1803,7 +1803,9 @@ _deck:
popRight: "右に出す" popRight: "右に出す"
profile: "ワークスペース" profile: "ワークスペース"
newProfile: "新規ワークスペース" newProfile: "新規ワークスペース"
renameProfile: "ワークスペース名を変更"
deleteProfile: "ワークスペースを削除" deleteProfile: "ワークスペースを削除"
nameAlreadyExists: "この名前のワークスペースは既に存在します。"
introduction: "カラムを組み合わせて自分だけのインターフェイスを作りましょう!" introduction: "カラムを組み合わせて自分だけのインターフェイスを作りましょう!"
introduction2: "画面の右にある + を押して、いつでもカラムを追加できます。" introduction2: "画面の右にある + を押して、いつでもカラムを追加できます。"
widgetsIntroduction: "カラムのメニューから、「ウィジェットの編集」を選択してウィジェットを追加してください" widgetsIntroduction: "カラムのメニューから、「ウィジェットの編集」を選択してウィジェットを追加してください"

View file

@ -1731,7 +1731,9 @@ _deck:
popRight: "向右弹出" popRight: "向右弹出"
profile: "配置文件" profile: "配置文件"
newProfile: "新建配置文件" newProfile: "新建配置文件"
renameProfile: "重命名配置文件"
deleteProfile: "删除配置文件" deleteProfile: "删除配置文件"
nameAlreadyExists: "该配置文件名已存在。"
introduction: "将各列进行组合以创建您自己的界面!" introduction: "将各列进行组合以创建您自己的界面!"
introduction2: "您可以随时通过屏幕右侧的 + 来添加列" introduction2: "您可以随时通过屏幕右侧的 + 来添加列"
widgetsIntroduction: "从列菜单中,选择“小工具编辑”来添加小工具" widgetsIntroduction: "从列菜单中,选择“小工具编辑”来添加小工具"

View file

@ -1731,7 +1731,9 @@ _deck:
popRight: "向右彈出" popRight: "向右彈出"
profile: "個人檔案" profile: "個人檔案"
newProfile: "新建個人檔案" newProfile: "新建個人檔案"
renameProfile: "重新命名個人檔案"
deleteProfile: "刪除個人檔案" deleteProfile: "刪除個人檔案"
nameAlreadyExists: "該個人檔案名已經存在。"
introduction: "組合欄位來製作屬於自己的介面吧!" introduction: "組合欄位來製作屬於自己的介面吧!"
introduction2: "您可以隨時透過按畫面右方的 + 來添加欄位。" introduction2: "您可以隨時透過按畫面右方的 + 來添加欄位。"
widgetsIntroduction: "請從欄位的選單中,選擇「編輯小工具」來添加小工具" widgetsIntroduction: "請從欄位的選單中,選擇「編輯小工具」來添加小工具"

View file

@ -70,6 +70,14 @@
> >
<i class="ph-caret-down ph-bold ph-lg"></i> <i class="ph-caret-down ph-bold ph-lg"></i>
</button> </button>
<button
v-if="deckStore.state.profile !== 'default'"
v-tooltip.noDelay.left="i18n.ts._deck.renameProfile"
class="_button button"
@click="renameProfile"
>
<i class="ph-pencil ph-bold ph-lg"></i>
</button>
<button <button
v-if="deckStore.state.profile !== 'default'" v-if="deckStore.state.profile !== 'default'"
v-tooltip.noDelay.left="i18n.ts._deck.deleteProfile" v-tooltip.noDelay.left="i18n.ts._deck.deleteProfile"
@ -161,6 +169,7 @@ import {
addColumn as addColumnToStore, addColumn as addColumnToStore,
loadDeck, loadDeck,
getProfiles, getProfiles,
renameProfile as renameProfile_,
deleteProfile as deleteProfile_, deleteProfile as deleteProfile_,
} from "./deck/deck-store"; } from "./deck/deck-store";
import DeckColumnCore from "@/ui/deck/column-core.vue"; import DeckColumnCore from "@/ui/deck/column-core.vue";
@ -319,6 +328,23 @@ function changeProfile(ev: MouseEvent) {
os.popupMenu(items, ev.currentTarget ?? ev.target); os.popupMenu(items, ev.currentTarget ?? ev.target);
} }
async function renameProfile() {
const { canceled, result: newProfileName } = await os.inputText({
title: i18n.ts._deck.renameProfile,
allowEmpty: false,
});
if (canceled) return;
const profiles = await getProfiles();
if (profiles.includes(newProfileName)) {
os.alert({ type: "error", text: i18n.ts._deck.nameAlreadyExists });
return;
}
await renameProfile_(deckStore.state.profile, newProfileName);
unisonReload();
}
async function deleteProfile() { async function deleteProfile() {
const { canceled } = await os.confirm({ const { canceled } = await os.confirm({
type: "warning", type: "warning",

View file

@ -115,6 +115,20 @@ export async function deleteProfile(key: string): Promise<any> {
}); });
} }
export async function renameProfile(oldKey: string, newKey: string) {
if (oldKey === newKey) return;
await api("i/registry/set", {
scope: ["client", "deck", "profiles"],
key: newKey,
value: { columns: deckStore.state.columns, layout: deckStore.state.layout },
});
deckStore.set("profile", newKey);
saveDeck();
deleteProfile(oldKey);
}
export function addColumn(column: Column) { export function addColumn(column: Column) {
if (column.name === undefined) column.name = null; if (column.name === undefined) column.name = null;
deckStore.push("columns", column); deckStore.push("columns", column);