-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i think i need to migrate the server card first
- Loading branch information
1 parent
7295b73
commit 54217ea
Showing
6 changed files
with
130 additions
and
98 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
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 was deleted.
Oops, something went wrong.
77 changes: 77 additions & 0 deletions
77
client/src/www/views/servers_view/server_list_item/server_card/server_rename_dialog/index.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,77 @@ | ||
/* | ||
Copyright 2024 The Outline Authors | ||
Licensed 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 | ||
http://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 {LitElement, html} from 'lit'; | ||
import {customElement, property, state} from 'lit/decorators.js'; | ||
import '@material/web/all.js'; | ||
|
||
@customElement('server-rename-dialog') | ||
export class ServerRenameDialog extends LitElement { | ||
@property({type: Boolean}) open: boolean = false; | ||
@property({type: Function}) localize!: (key: string) => string; | ||
@property({type: String}) serverId!: string; | ||
@property({type: String}) serverName!: string; | ||
|
||
@state() private editedServerName: string | null = null; | ||
|
||
render() { | ||
if (this.editedServerName === null) { | ||
this.editedServerName = this.serverName; | ||
} | ||
|
||
return html` | ||
<md-dialog .open="${this.open}"> | ||
<md-dialog-header slot="headline"> | ||
${this.localize('server-rename')} | ||
</md-dialog-header> | ||
<md-filled-text-field | ||
slot="content" | ||
maxlength="100" | ||
value="${this.editedServerName}" | ||
></md-filled-text-field> | ||
<md-dialog-actions slot="actions"> | ||
<md-text-button @click="${this.handleCancel}" | ||
>${this.localize('cancel')}</md-text-button | ||
> | ||
<md-filled-button @click="${this.handleRename}" | ||
>${this.localize('save')}</md-filled-button | ||
> | ||
</md-dialog-actions> | ||
</md-dialog> | ||
`; | ||
} | ||
|
||
private handleCancel() { | ||
this.dispatchEvent( | ||
new CustomEvent('CancelRenameRequested', {bubbles: true, composed: true}) | ||
); | ||
|
||
this.editedServerName = null; | ||
} | ||
|
||
private handleRename() { | ||
if (this.editedServerName === this.serverName) { | ||
return; | ||
} | ||
|
||
this.dispatchEvent( | ||
new CustomEvent('RenameRequested', { | ||
detail: {serverId: this.serverId, newName: this.editedServerName}, | ||
bubbles: true, | ||
composed: true, | ||
}) | ||
); | ||
|
||
this.editedServerName = null; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...t/src/www/views/servers_view/server_list_item/server_card/server_rename_dialog/stories.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,38 @@ | ||
/* | ||
Copyright 2024 The Outline Authors | ||
Licensed 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 | ||
http://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 {html} from 'lit'; | ||
|
||
import './index'; | ||
import {ServerRenameDialog} from './index'; | ||
import {localize} from '../../../../../testing/localize'; | ||
|
||
export default { | ||
title: 'Client/Servers View/Server List Item/Server Rename Dialog', | ||
args: { | ||
open: true, | ||
serverId: 'my-server-id', | ||
serverName: 'My Server', | ||
}, | ||
}; | ||
|
||
export const Example = ({open, serverId, serverName}: ServerRenameDialog) => { | ||
return html` | ||
<server-rename-dialog | ||
.open=${open} | ||
.localize=${localize} | ||
serverId=${serverId} | ||
serverName=${serverName} | ||
></server-rename-dialog> | ||
`; | ||
}; |
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